Java Code Examples for processing.core.PApplet#createShape()
The following examples show how to use
processing.core.PApplet#createShape() .
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: PShape.java From CPE552-Java with GNU General Public License v3.0 | 6 votes |
static protected PShape createShape(PApplet parent, PShape src) { PShape dest = null; if (src.family == GROUP) { dest = parent.createShape(GROUP); PShape.copyGroup(parent, src, dest); } else if (src.family == PRIMITIVE) { dest = parent.createShape(src.kind, src.params); PShape.copyPrimitive(src, dest); } else if (src.family == GEOMETRY) { dest = parent.createShape(src.kind); PShape.copyGeometry(src, dest); } else if (src.family == PATH) { dest = parent.createShape(PATH); PShape.copyPath(src, dest); } dest.setName(src.name); return dest; }
Example 2
Source File: DwSoftBody3D.java From PixelFlow with MIT License | 6 votes |
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: SoftBody2D_Trees.java From PixelFlow with MIT License | 5 votes |
public void createShape(PApplet papplet){ param.rand_leaf = new Random(0); if(shp_tree == null){ shp_tree = papplet.createShape(PConstants.GROUP); } root.createShape(papplet, shp_tree); }
Example 4
Source File: DwSoftBody3D.java From PixelFlow with MIT License | 5 votes |
@Override public void createShapeParticles(PApplet papplet, boolean icosahedron){ PShape shp = papplet.createShape(PShape.GROUP); for(int i = 0; i < particles.length; i++){ float radius = 1; // float radius = particles[i].rad; PShape shp_pa = createShape(papplet, radius, icosahedron); particles[i].setShape(shp_pa); shp.addChild(shp_pa); } setShapeParticles(papplet, shp); }
Example 5
Source File: DwSoftBody2D.java From PixelFlow with MIT License | 5 votes |
@Override public void createShapeParticles(PApplet papplet, boolean icosahedron){ PShape shp = papplet.createShape(PShape.GROUP); for(int i = 0; i < particles.length; i++){ float radius = 1; // float radius = particles[i].rad; PShape shp_pa = createShape(papplet, radius); particles[i].setShape(shp_pa); shp.addChild(shp_pa); } setShapeParticles(papplet, shp); }
Example 6
Source File: DwSoftBody.java From PixelFlow with MIT License | 5 votes |
protected void setShapeParticles(PApplet pg, PShape child){ if(shp_particles == null){ shp_particles = pg.createShape(PConstants.GROUP); shp_particles.setName("shp_particles (root)"); } else { removeChilds(shp_particles); } child.setName("shp_particles"); shp_particles.addChild(child); }
Example 7
Source File: DwSoftBody.java From PixelFlow with MIT License | 5 votes |
protected void setShapeMesh(PApplet pg, PShape child){ if(shp_mesh == null){ shp_mesh = pg.createShape(PConstants.GROUP); shp_mesh.setName("shp_mesh (root)"); } else { removeChilds(shp_mesh); } child.setName("shp_mesh"); shp_mesh.addChild(child); }
Example 8
Source File: DwSoftBody.java From PixelFlow with MIT License | 5 votes |
protected void setShapeWireframe(PApplet pg, PShape child){ if(shp_wireframe == null){ shp_wireframe = pg.createShape(PConstants.GROUP); shp_wireframe.setName("shp_wireframe (root)"); } else { removeChilds(shp_wireframe); } child.setName("shp_wireframe"); shp_wireframe.addChild(child); }
Example 9
Source File: Icosahedron.java From haxademic with MIT License | 5 votes |
public static PShape createIcosahedronGrouped(PApplet p, int level, PImage img, int fillColor, int strokeColor, float strokeWeight) { // the icosahedron is created with positions, normals and texture coordinates in the above class Icosahedron ico = new Icosahedron(level); p.textureMode(P.NORMAL); // set textureMode to normalized (range 0 to 1); PShape mesh = p.createShape(P.GROUP); // create the initial PShape // put all the vertices, uv texture coordinates and normals into the PShape PShape triangle = null; for (int i=0; i<ico.positions.size(); i++) { if(i % 3 == 0) { triangle = p.createShape(); triangle.beginShape(P.TRIANGLE); // define the PShape type: TRIANGLES if(fillColor != -1) { triangle.strokeWeight(strokeWeight); triangle.stroke(strokeColor); triangle.fill(fillColor); } if(img != null) mesh.texture(img); } PVector pos = ico.positions.get(i); PVector t = ico.texCoords.get(i); PVector n = ico.normals.get(i); triangle.normal(n.x, n.y, n.z); triangle.vertex(pos.x, pos.y, pos.z, t.x, t.y); if(i % 3 == 2) { triangle.endShape(); mesh.addChild(triangle); } } return mesh; }
Example 10
Source File: PShapeUtil.java From haxademic with MIT License | 5 votes |
public static PShape clonePShape(PApplet p, PShape tesselation) { PShape newShape = p.createShape(); newShape.beginShape(P.TRIANGLES); for (int i = 0; i < tesselation.getVertexCount(); i++) { PVector v = tesselation.getVertex(i); newShape.vertex(v.x, v.y); } newShape.endShape(P.CLOSE); newShape.setStroke(false); return newShape; }
Example 11
Source File: DwSoftBody2D.java From PixelFlow with MIT License | 4 votes |
private PShape createShape(PApplet papplet, float radius){ PShape shape = papplet.createShape(PConstants.ELLIPSE, 0, 0, radius*2, radius*2); shape.setStroke(false); shape.setFill(true); return shape; }