Java Code Examples for processing.core.PShape#setStrokeWeight()

The following examples show how to use processing.core.PShape#setStrokeWeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PShapeUtil.java    From haxademic with MIT License 6 votes vote down vote up
public static void addTestStrokeToShape(PShape shape, float strokeWeight, float oscMult) {
	for (int i = 0; i < shape.getVertexCount(); i++) {
		PVector vertex = shape.getVertex(i);
		int strokeReplace = P.p.color(
				127 + 127f * P.sin(vertex.x * oscMult),
				127 + 127f * P.sin(vertex.y * oscMult),
				127 + 127f * P.sin(vertex.z * oscMult)
				);
		shape.noFill();
		shape.setStrokeWeight(i, 4);
		shape.setStroke(strokeReplace);
	}
	for (int j = 0; j < shape.getChildCount(); j++) {
		addTestStrokeToShape(shape.getChild(j), strokeWeight, oscMult);
	}
}
 
Example 2
Source File: DwSoftBody3D.java    From PixelFlow with MIT License 6 votes vote down vote up
private PShape createShape(PApplet papplet, float radius, boolean icosahedron){
    PShape shape;
    
    if(!icosahedron){
      shape = papplet.createShape(PConstants.POINT, 0, 0);
      shape.setStroke(true);
      shape.setStrokeWeight(1);
    } else {
      if(ifs == null){
        ifs = new DwIcosahedron(1);
//        ifs = new DwCube(1);
      }
      shape = papplet.createShape(PShape.GEOMETRY);
      shape.setStroke(false);
      shape.setFill(true);
      DwMeshUtils.createPolyhedronShape(shape, ifs, radius, 3, true);
    }

    return shape;
  }
 
Example 3
Source File: PShapeUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static PShape setBasicShapeStyles(PShape shape, int color, int stroke, float strokeWeight) {
	shape.setFill(color != 0);		// boolean turn on/off
	shape.setFill(color);
	shape.setStroke(stroke != 0);	// boolean turn on/off
	shape.setStroke(stroke);
	shape.setStrokeWeight(strokeWeight);
	return shape;
}
 
Example 4
Source File: Sampling_Poisson3D.java    From PixelFlow with MIT License 5 votes vote down vote up
void addShape(MyPoissonSample sample){
    PShape shp_point = createShape(POINT, sample.x(), sample.y(), sample.z());
    shp_point.setStroke(color(255));
    shp_point.setStrokeWeight(3);
    shp_samples_points.addChild(shp_point);
    

    if(ifs == null){
      ifs = new DwIcosahedron(2); verts_per_face = 3;
//      ifs = new DwCube(2); verts_per_face = 4;
    }
    PShape shp_sphere = createShape(PShape.GEOMETRY);
    shp_sphere.setStroke(false);
    shp_sphere.setFill(color(255));
    shp_sphere.resetMatrix();
    shp_sphere.translate(sample.x(), sample.y(), sample.z());
   
    DwMeshUtils.createPolyhedronShape(shp_sphere, ifs, sample.rad(), verts_per_face, true);
    
    shp_samples_spheres.addChild(shp_sphere);
    
    
//    PShape shp_sphere_normals = createShape(PShape.GEOMETRY);
//    shp_sphere_normals.setStroke(false);
//    shp_sphere_normals.setFill(color(255));
//    shp_sphere_normals.resetMatrix();
//    shp_sphere_normals.translate(sample.x(), sample.y(), sample.z());
//   
//    DwMeshUtils.createPolyhedronShapeNormals(shp_sphere_normals, ifs, sample.rad(), 10);
//    
//    shp_samples_spheres.addChild(shp_sphere_normals);
  }
 
Example 5
Source File: PShapeUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static void replaceShapeMaterial(PShape shape, float searchR, float searchG, float searchB, int fillReplace, int strokeReplace, float closenessThreshold) {
//		shape.setStrokeWeight(4);
//		shape.setStroke(strokeReplace);
		for (int i = 0; i < shape.getVertexCount(); i++) {
			if(colorMatchNormalized(searchR, searchG, searchB, shape.getFill(i), closenessThreshold)) {
				shape.setFill(i, fillReplace);
				shape.setStrokeWeight(i, 4);
				shape.setStroke(strokeReplace);
			}
		}
		for (int j = 0; j < shape.getChildCount(); j++) {
			replaceShapeMaterial(shape.getChild(j), searchR, searchG, searchB, fillReplace, strokeReplace, closenessThreshold);
		}
	}
 
Example 6
Source File: PShapeUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static void setWireframeColor(PShape shape, int faceColor, int lineColor) {
	for (int i = 0; i < shape.getVertexCount(); i++) {
		shape.setFill(true);
		shape.setFill(i, faceColor);
		shape.setStroke(true);
		shape.setStroke(i, lineColor);
		shape.setStrokeWeight(1.2f);
	}
	for (int j = 0; j < shape.getChildCount(); j++) {
		setWireframeColor(shape.getChild(j), faceColor, lineColor);
	}
}
 
Example 7
Source File: DwFoldingSoftBody.java    From PixelFlow with MIT License 5 votes vote down vote up
@Override
public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){
  PShape shp = createShape(pg);
  shp.setTexture(null);
  shp.setFill(false);
  shp.setStroke(true);
  shp.setStroke(style.stroke_color);
  shp.setStrokeWeight(style.stroke_weight);
  
  setShapeWireframe(pg.parent, shp);
}
 
Example 8
Source File: DwSoftGrid3D.java    From PixelFlow with MIT License 5 votes vote down vote up
@Override
public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){
  PShape shp = createShape(pg);
  
  shp.setTexture(null);
  shp.setFill(false);
  shp.setStroke(true);
  shp.setStroke(style.stroke_color);
  shp.setStrokeWeight(style.stroke_weight);
  
  setShapeWireframe(pg.parent, shp);
}
 
Example 9
Source File: DwSoftGrid2D.java    From PixelFlow with MIT License 5 votes vote down vote up
@Override
public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){
  PShape shp = pg.createShape();
  displayGridXY(shp, texture_XYp);
  shp.setTexture(null);
  shp.setFill(false);
  shp.setStroke(true);
  shp.setStroke(style.stroke_color);
  shp.setStrokeWeight(style.stroke_weight);
  
  setShapeWireframe(pg.parent, shp);
}
 
Example 10
Source File: DwSoftBall2D.java    From PixelFlow with MIT License 5 votes vote down vote up
@Override
public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){
  PShape shp = createShape(pg);
  
  shp.setTexture(null);
  shp.setFill(false);
  shp.setStroke(true);
  shp.setStroke(style.stroke_color);
  shp.setStrokeWeight(style.stroke_weight);
  setShapeWireframe(pg.parent, shp);
}
 
Example 11
Source File: DwSoftBall3D.java    From PixelFlow with MIT License 5 votes vote down vote up
@Override
public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){
  PShape shp = createShape(pg);
  shp.setTexture(null);
  shp.setFill(false);
  shp.setStroke(true);
  shp.setStroke(style.stroke_color);
  shp.setStrokeWeight(style.stroke_weight);
  
  setShapeWireframe(pg.parent, shp);
}
 
Example 12
Source File: Skylight_BulletPhysics_Breakable3.java    From PixelFlow with MIT License 5 votes vote down vote up
public PShape createBoxShape(Vector3f dim){
  PShape shp = createShape(BOX, dim.x, dim.y, dim.z);
  shp.setStroke(false);
  shp.setFill(true);
  shp.setFill(color(16));
  shp.setStrokeWeight(1);
  shp.setStroke(color(0));
  return shp;
}
 
Example 13
Source File: Skylight_BulletPhysics_Breakable_VideoExport.java    From PixelFlow with MIT License 5 votes vote down vote up
public PShape createBoxShape(Vector3f dim){
  PShape shp = createShape(BOX, dim.x, dim.y, dim.z);
  shp.setStroke(false);
  shp.setFill(true);
  shp.setFill(color(16));
  shp.setStrokeWeight(1);
  shp.setStroke(color(0));
  return shp;
}
 
Example 14
Source File: Skylight_BulletPhysics_Breakable.java    From PixelFlow with MIT License 5 votes vote down vote up
public PShape createBoxShape(Vector3f dim){
  PShape shp = createShape(BOX, dim.x, dim.y, dim.z);
  shp.setStroke(false);
  shp.setFill(true);
  shp.setFill(color(16));
  shp.setStrokeWeight(1);
  shp.setStroke(color(0));
  return shp;
}
 
Example 15
Source File: Skylight_PoissonSphereSamples.java    From PixelFlow with MIT License 5 votes vote down vote up
void addShape(MyPoissonSample sample){
    PShape shp_point = createShape(POINT, sample.x(), sample.y(), sample.z());
    shp_point.setStroke(color(255));
    shp_point.setStrokeWeight(3);
    shp_samples_points.addChild(shp_point);
    

    if(ifs == null){
      ifs = new DwIcosahedron(2); verts_per_face = 3;
//      ifs = new DwCube(3); verts_per_face = 4;
    }
    PShape shp_sphere = createShape(PShape.GEOMETRY);
    shp_sphere.setStroke(false);
    shp_sphere.setFill(color(255));
    
    colorMode(HSB, 360, 1, 1);
    float hsb_h = 15 + (float)(Math.random() - 0.5f) * 45 ;
    float hsb_s = (float) Math.random() * 0.99f + 0.01f;
    float hsb_b = hsb_s*3;
    
    shp_sphere.setFill(color(hsb_h, hsb_s, hsb_b));
    colorMode(RGB);
    
    shp_sphere.resetMatrix();
    shp_sphere.translate(sample.x(), sample.y(), sample.z());
    
    boolean flat_shading = random(1) > 0.5f;
   
    DwMeshUtils.createPolyhedronShape(shp_sphere, ifs, sample.rad(), verts_per_face, flat_shading);
    
    shp_samples_spheres.addChild(shp_sphere);
  }
 
Example 16
Source File: Sampling_Halton.java    From PixelFlow with MIT License 5 votes vote down vote up
void addShape(float[] position, float scale){
  PVector pos = new PVector().set(position).mult(scale);
  PShape shp_point = createShape(POINT, pos.x, pos.y, pos.z);
  shp_point.setStroke(color(255));
  shp_point.setStrokeWeight(3);
  shp_samples.addChild(shp_point);
}
 
Example 17
Source File: Sampling_Fibonacci.java    From PixelFlow with MIT License 5 votes vote down vote up
void addShape(float[] position, float scale){
  PVector pos = new PVector().set(position).mult(scale);
  PShape shp_point = createShape(POINT, pos.x, pos.y);
  shp_point.setStroke(color(255));
  shp_point.setStrokeWeight(3);
  shp_samples.addChild(shp_point);
}