当前位置: 首页>>代码示例>>Java>>正文


Java PShape.stroke方法代码示例

本文整理汇总了Java中processing.core.PShape.stroke方法的典型用法代码示例。如果您正苦于以下问题:Java PShape.stroke方法的具体用法?Java PShape.stroke怎么用?Java PShape.stroke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在processing.core.PShape的用法示例。


在下文中一共展示了PShape.stroke方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addPoint

import processing.core.PShape; //导入方法依赖的package包/类
/**
 * Adds a point to the given shape
 * 
 * @param shape the shape where the point should be added
 * @param index the point index
 * @param addColors add the points colors to the shape if true
 * @param addNormals add the points normals to the shape if true
 */
protected void addPoint(PShape shape, int index, boolean addColors, boolean addNormals) {
	PVector point = points[index];

	if (addNormals && normals != null) {
		PVector normal = normals[index];

		if (addColors) {
			shape.stroke(colors[index]);
			shape.attribNormal("normal", normal.x, normal.y, normal.z);
			shape.vertex(point.x, point.y, point.z);
		} else {
			shape.attribNormal("normal", normal.x, normal.y, normal.z);
			shape.vertex(point.x, point.y, point.z);
		}
	} else if (addColors) {
		shape.stroke(colors[index]);
		shape.vertex(point.x, point.y, point.z);
	} else {
		shape.vertex(point.x, point.y, point.z);
	}
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:30,代码来源:Scan.java

示例2: createGridXY

import processing.core.PShape; //导入方法依赖的package包/类
public PShape createGridXY(int lines, float s){
  PShape shp_gridxy = createShape();
  shp_gridxy.beginShape(LINES);
  shp_gridxy.stroke(0);
  shp_gridxy.strokeWeight(1f);
  float d = lines*s;
  for(int i = 0; i <= lines; i++){
    shp_gridxy.vertex(-d,-i*s,0); shp_gridxy.vertex(d,-i*s,0);
    shp_gridxy.vertex(-d,+i*s,0); shp_gridxy.vertex(d,+i*s,0);
    
    shp_gridxy.vertex(-i*s,-d,0); shp_gridxy.vertex(-i*s,d,0);
    shp_gridxy.vertex(+i*s,-d,0); shp_gridxy.vertex(+i*s,d,0);
  }
  shp_gridxy.endShape();
  return shp_gridxy;
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:17,代码来源:DepthOfField_Demo.java

示例3: addLine

import processing.core.PShape; //导入方法依赖的package包/类
/**
 * Adds a line to the given shape if the two Kinect points are connected
 * 
 * @param shape the shape where the line should be added
 * @param index1 the first point index
 * @param index2 the second point index
 * @param addColors add the points colors to the shape if true
 * @param addNormals add the points normals to the shape if true
 */
protected void addLine(PShape shape, int index1, int index2, boolean addColors, boolean addNormals) {
	PVector point1 = points[index1];
	PVector point2 = points[index2];

	if (connected(point1, point2)) {
		if (addNormals && normals != null) {
			PVector normal1 = normals[index1];
			PVector normal2 = normals[index2];

			if (addColors) {
				shape.stroke(colors[index1]);
				shape.attribNormal("normal", normal1.x, normal1.y, normal1.z);
				shape.vertex(point1.x, point1.y, point1.z);
				shape.stroke(colors[index2]);
				shape.attribNormal("normal", normal2.x, normal2.y, normal2.z);
				shape.vertex(point2.x, point2.y, point2.z);
			} else {
				shape.attribNormal("normal", normal1.x, normal1.y, normal1.z);
				shape.vertex(point1.x, point1.y, point1.z);
				shape.attribNormal("normal", normal2.x, normal2.y, normal2.z);
				shape.vertex(point2.x, point2.y, point2.z);
			}
		} else if (addColors) {
			shape.stroke(colors[index1]);
			shape.vertex(point1.x, point1.y, point1.z);
			shape.stroke(colors[index2]);
			shape.vertex(point2.x, point2.y, point2.z);
		} else {
			shape.vertex(point1.x, point1.y, point1.z);
			shape.vertex(point2.x, point2.y, point2.z);
		}
	}
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:43,代码来源:Scan.java

示例4: createPolyhedronShapeNormals

import processing.core.PShape; //导入方法依赖的package包/类
static public void createPolyhedronShapeNormals(PShape shape, DwIndexedFaceSetAble ifs, float scale, float normal_len){

    shape.beginShape(PConstants.LINES);
    shape.stroke(0);
    
    int  [][] faces = ifs.getFaces();
    float[][] verts = ifs.getVerts();
    
    for(int[] face : faces){
      float nx = 0, ny = 0, nz = 0;

      int num_verts = face.length;
      
      // compute face normal
      for(int i = 0; i < num_verts; i++){
        int vi = face[i];
        nx += verts[vi][0];
        ny += verts[vi][1];
        nz += verts[vi][2];
      }
      nx /= num_verts;
      ny /= num_verts;
      nz /= num_verts;
      
      float ax = nx*scale;
      float ay = ny*scale;
      float az = nz*scale;
      float bx = ax + nx*normal_len;
      float by = ay + ny*normal_len;
      float bz = az + nz*normal_len;
      shape.vertex(ax, ay, az);
      shape.vertex(bx, by, bz);
    }
    shape.endShape();
  }
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:36,代码来源:DwMeshUtils.java

示例5: createParticleShape

import processing.core.PShape; //导入方法依赖的package包/类
public PShape createParticleShape(DwParticle2D particle, PImage sprite_img){
    
    final float rad = particle.rad;

    PShape shp_particle = papplet.createShape(PShape.GROUP);
    
    if( PARTICLE_SHAPE_IDX >= 0 && PARTICLE_SHAPE_IDX < 4){
      
      PShape sprite = papplet.createShape(PShape.GEOMETRY);
      sprite.beginShape(PConstants.QUAD);
      sprite.noStroke();
      sprite.noFill();
      sprite.textureMode(PConstants.NORMAL);
      sprite.texture(sprite_img);
      sprite.normal(0, 0, 1);
      sprite.vertex(-rad, -rad, 0, 0);
      sprite.vertex(+rad, -rad, 1, 0);
      sprite.vertex(+rad, +rad, 1, 1);
      sprite.vertex(-rad, +rad, 0, 1);
      sprite.endShape();
      
      shp_particle.addChild(sprite);
    }
    else if( PARTICLE_SHAPE_IDX == 4){   
      
      float threshold1 = 1;   // radius shortening for arc segments
      float threshold2 = 140; // arc between segments
      
      double arc1 = Math.acos(Math.max((rad-threshold1), 0) / rad);
      double arc2 = (180 - threshold2) * Math.PI / 180;
      double arc = Math.min(arc1, arc2);
      
      int num_vtx = (int)Math.ceil(2*Math.PI/arc);
      
//      System.out.println(num_vtx);

      PShape circle = papplet.createShape(PShape.GEOMETRY);
      circle.beginShape();
      circle.noStroke();
      circle.fill(200,100);
      for(int i = 0; i < num_vtx; i++){
        float vx = (float) Math.cos(i * 2*Math.PI/num_vtx) * rad;
        float vy = (float) Math.sin(i * 2*Math.PI/num_vtx) * rad;
        circle.vertex(vx, vy);
      }
      circle.endShape(PConstants.CLOSE);

      PShape line = papplet.createShape(PShape.GEOMETRY);
      line.beginShape(PConstants.LINES);
      line.stroke(0, 100);
      line.strokeWeight(1);
      line.vertex(0, 0);
      line.vertex(-(rad-1), 0);
      line.endShape();
      
//      PShape circle = papplet.createShape(PConstants.ELLIPSE, 0, 0, rad*2, rad*2);
//      circle.setStroke(false);
//      circle.setFill(papplet.color(200,100));
//
//      PShape line = papplet.createShape(PConstants.LINE, 0, 0, -(rad-1), 0);
//      line.setStroke(papplet.color(0,200));
//      line.setStrokeWeight(1); 
      
      shp_particle.addChild(circle);
      shp_particle.addChild(line);
    }
    
    return shp_particle;
    
  }
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:71,代码来源:ParticleSystem.java

示例6: displayAABB

import processing.core.PShape; //导入方法依赖的package包/类
public void displayAABB(float[] aabb){
  if(shp_aabb == null){
    float xmin = aabb[0], xmax = aabb[3];
    float ymin = aabb[1], ymax = aabb[4];
    float zmin = aabb[2], zmax = aabb[5];
    
    shp_aabb = createShape(GROUP);
    
    PShape plane_zmin = createShape();
    plane_zmin.beginShape(QUAD);
    plane_zmin.stroke(0);
    plane_zmin.strokeWeight(1);
    plane_zmin.fill(192);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymax, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymax, zmin);
    plane_zmin.endShape(CLOSE);
    shp_aabb.addChild(plane_zmin);
    
    PShape plane_zmax = createShape();
    plane_zmax.beginShape(QUAD);
    plane_zmax.noFill();
    plane_zmax.stroke(0);
    plane_zmax.strokeWeight(1);
    plane_zmax.vertex(xmin, ymin, zmax);
    plane_zmax.vertex(xmax, ymin, zmax);
    plane_zmax.vertex(xmax, ymax, zmax);
    plane_zmax.vertex(xmin, ymax, zmax);
    plane_zmax.endShape(CLOSE);
    shp_aabb.addChild(plane_zmax);
    
    PShape vert_lines = createShape();
    vert_lines.beginShape(LINES);
    vert_lines.stroke(0);
    vert_lines.strokeWeight(1);
    vert_lines.vertex(xmin, ymin, zmin);  vert_lines.vertex(xmin, ymin, zmax);
    vert_lines.vertex(xmax, ymin, zmin);  vert_lines.vertex(xmax, ymin, zmax);
    vert_lines.vertex(xmax, ymax, zmin);  vert_lines.vertex(xmax, ymax, zmax);
    vert_lines.vertex(xmin, ymax, zmin);  vert_lines.vertex(xmin, ymax, zmax);
    vert_lines.endShape();
    shp_aabb.addChild(vert_lines);
    
    PShape corners = createShape();
    corners.beginShape(POINTS);
    corners.stroke(0);
    corners.strokeWeight(7);
    corners.vertex(xmin, ymin, zmin);  corners.vertex(xmin, ymin, zmax);
    corners.vertex(xmax, ymin, zmin);  corners.vertex(xmax, ymin, zmax);
    corners.vertex(xmax, ymax, zmin);  corners.vertex(xmax, ymax, zmax);
    corners.vertex(xmin, ymax, zmin);  corners.vertex(xmin, ymax, zmax);
    corners.endShape();
    shp_aabb.addChild(corners);
  }
  shape(shp_aabb);
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:57,代码来源:Softbody3D_ParticleCollisionSystem.java

示例7: displayAABB

import processing.core.PShape; //导入方法依赖的package包/类
public void displayAABB(float[] aabb){
  if(shp_aabb == null){
    float xmin = aabb[0], xmax = aabb[3];
    float ymin = aabb[1], ymax = aabb[4];
    float zmin = aabb[2], zmax = aabb[5];
    
    shp_aabb = createShape(GROUP);
    
    PShape plane_zmin = createShape();
    plane_zmin.beginShape(QUAD);
    plane_zmin.stroke(0);
    plane_zmin.strokeWeight(1);
    plane_zmin.fill(64);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymax, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymax, zmin);
    plane_zmin.endShape(CLOSE);
    shp_aabb.addChild(plane_zmin);
    
    PShape plane_zmax = createShape();
    plane_zmax.beginShape(QUAD);
    plane_zmax.noFill();
    plane_zmax.stroke(0);
    plane_zmax.strokeWeight(1);
    plane_zmax.vertex(xmin, ymin, zmax);
    plane_zmax.vertex(xmax, ymin, zmax);
    plane_zmax.vertex(xmax, ymax, zmax);
    plane_zmax.vertex(xmin, ymax, zmax);
    plane_zmax.endShape(CLOSE);
    shp_aabb.addChild(plane_zmax);
    
    PShape vert_lines = createShape();
    vert_lines.beginShape(LINES);
    vert_lines.stroke(0);
    vert_lines.strokeWeight(1);
    vert_lines.vertex(xmin, ymin, zmin);  vert_lines.vertex(xmin, ymin, zmax);
    vert_lines.vertex(xmax, ymin, zmin);  vert_lines.vertex(xmax, ymin, zmax);
    vert_lines.vertex(xmax, ymax, zmin);  vert_lines.vertex(xmax, ymax, zmax);
    vert_lines.vertex(xmin, ymax, zmin);  vert_lines.vertex(xmin, ymax, zmax);
    vert_lines.endShape();
    shp_aabb.addChild(vert_lines);
    
    PShape corners = createShape();
    corners.beginShape(POINTS);
    corners.stroke(0);
    corners.strokeWeight(7);
    corners.vertex(xmin, ymin, zmin);  corners.vertex(xmin, ymin, zmax);
    corners.vertex(xmax, ymin, zmin);  corners.vertex(xmax, ymin, zmax);
    corners.vertex(xmax, ymax, zmin);  corners.vertex(xmax, ymax, zmax);
    corners.vertex(xmin, ymax, zmin);  corners.vertex(xmin, ymax, zmax);
    corners.endShape();
    shp_aabb.addChild(corners);
  }
  shape(shp_aabb);
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:57,代码来源:Softbody3D_Cloth.java

示例8: createParticleShape

import processing.core.PShape; //导入方法依赖的package包/类
public PShape createParticleShape(DwParticle2D particle){
  
  final float rad = particle.rad;

  PShape shp_particle = papplet.createShape(PShape.GROUP);
  
  // compute circle resolution, depending on the radius we reduce/increase
  // the number of vertices we need to render
  float threshold1 = 1;   // radius shortening for arc segments
  float threshold2 = 140; // arc between segments
  
  double arc1 = Math.acos(Math.max((rad-threshold1), 0) / rad);
  double arc2 = (180 - threshold2) * Math.PI / 180;
  double arc = Math.min(arc1, arc2);
  
  int num_vtx = (int)Math.ceil(2*Math.PI/arc);
  
  // actual circle
  PShape circle = papplet.createShape(PShape.GEOMETRY);
  circle.beginShape();
  circle.noStroke();
  circle.fill(200,100);
  for(int i = 0; i < num_vtx; i++){
    float vx = (float) Math.cos(i * 2*Math.PI/num_vtx) * 1;
    float vy = (float) Math.sin(i * 2*Math.PI/num_vtx) * 1;
    circle.vertex(vx, vy);
  }
  circle.endShape(PConstants.CLOSE);

  // line, to indicate the velocity-direction of the particle
  PShape line = papplet.createShape(PShape.GEOMETRY);
  line.beginShape(PConstants.LINES);
  line.stroke(255, 100);
  line.strokeWeight(1f/rad);
  line.vertex(0, 0);
  line.vertex(-1, 0);
  line.endShape();
  
  shp_particle.addChild(circle);
  shp_particle.addChild(line);
  
  return shp_particle;
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:44,代码来源:ParticleSystem.java

示例9: displayAABB

import processing.core.PShape; //导入方法依赖的package包/类
public void displayAABB(PGraphics3D canvas, float[] aabb){
  if(shp_aabb == null){
    float xmin = aabb[0], xmax = aabb[3];
    float ymin = aabb[1], ymax = aabb[4];
    float zmin = aabb[2], zmax = aabb[5];
    
    shp_aabb = createShape(GROUP);
    
    PShape plane_zmin = createShape();
    plane_zmin.beginShape(QUAD);
    plane_zmin.stroke(0);
    plane_zmin.strokeWeight(1);
    plane_zmin.fill(16,96,192);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymax, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymax, zmin);
    plane_zmin.endShape(CLOSE);
    shp_aabb.addChild(plane_zmin);
    
    PShape plane_zmax = createShape();
    plane_zmax.beginShape(QUAD);
    plane_zmax.noFill();
    plane_zmax.stroke(0);
    plane_zmax.strokeWeight(1);
    plane_zmax.vertex(xmin, ymin, zmax);
    plane_zmax.vertex(xmax, ymin, zmax);
    plane_zmax.vertex(xmax, ymax, zmax);
    plane_zmax.vertex(xmin, ymax, zmax);
    plane_zmax.endShape(CLOSE);
    shp_aabb.addChild(plane_zmax);
    
    PShape vert_lines = createShape();
    vert_lines.beginShape(LINES);
    vert_lines.stroke(0);
    vert_lines.strokeWeight(1);
    vert_lines.vertex(xmin, ymin, zmin);  vert_lines.vertex(xmin, ymin, zmax);
    vert_lines.vertex(xmax, ymin, zmin);  vert_lines.vertex(xmax, ymin, zmax);
    vert_lines.vertex(xmax, ymax, zmin);  vert_lines.vertex(xmax, ymax, zmax);
    vert_lines.vertex(xmin, ymax, zmin);  vert_lines.vertex(xmin, ymax, zmax);
    vert_lines.endShape();
    shp_aabb.addChild(vert_lines);
    
    PShape corners = createShape();
    corners.beginShape(POINTS);
    corners.stroke(0);
    corners.strokeWeight(7);
    corners.vertex(xmin, ymin, zmin);  corners.vertex(xmin, ymin, zmax);
    corners.vertex(xmax, ymin, zmin);  corners.vertex(xmax, ymin, zmax);
    corners.vertex(xmax, ymax, zmin);  corners.vertex(xmax, ymax, zmax);
    corners.vertex(xmin, ymax, zmin);  corners.vertex(xmin, ymax, zmax);
    corners.endShape();
    shp_aabb.addChild(corners);
  }
  canvas.shape(shp_aabb);
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:57,代码来源:Skylight_ClothSimulation.java


注:本文中的processing.core.PShape.stroke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。