Java Code Examples for processing.core.PApplet#beginShape()
The following examples show how to use
processing.core.PApplet#beginShape() .
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: BFLinewaveRenderStatic.java From haxademic with MIT License | 5 votes |
public void update(PApplet pg, float frameOsc) { _x.update(); _y.update(); pg.noFill(); pg.stroke(0); pg.strokeWeight(HEIGHT); p.strokeCap(P.SQUARE); float third = 1f/3f; float twoThird = 2f/3f; float sixth = 1f/6f; float curveAdd = 1.25f; curveAdd = curveAdd/2f + frameOsc * curveAdd/2f; pg.beginShape(); pg.vertex(_x.value(), _y.value()); pg.bezierVertex( _x.value() + WIDTH * sixth, _y.value(), _x.value() + WIDTH * sixth, _y.value() + _index * curveAdd, _x.value() + WIDTH * third, _y.value() + _index * curveAdd ); pg.bezierVertex( _x.value() + WIDTH * (third + sixth), _y.value() + _index * curveAdd, _x.value() + WIDTH * (third + sixth), _y.value(), _x.value() + WIDTH * twoThird, _y.value() ); pg.bezierVertex( _x.value() + WIDTH * (twoThird + sixth), _y.value(), _x.value() + WIDTH * (twoThird + sixth), _y.value() + _index * curveAdd, _x.value() + WIDTH, _y.value() + _index * curveAdd ); pg.endShape(); }
Example 2
Source File: DrawToxiMesh.java From haxademic with MIT License | 5 votes |
public static void drawToxiMeshFacesNative( PApplet p, WETriangleMesh mesh ) { Face f; for( int i = 0; i < mesh.faces.size(); i++ ) { p.beginShape(P.TRIANGLES); f = mesh.faces.get( i ); p.vertex(f.a.x, f.a.y, f.a.z); p.vertex(f.b.x, f.b.y, f.b.z); p.vertex(f.c.x, f.c.y, f.c.z); p.endShape(); } }
Example 3
Source File: DrawToxiMesh.java From haxademic with MIT License | 5 votes |
public static void drawToxiMeshFacesNative2d( PApplet p, WETriangleMesh mesh ) { Face f; for( int i = 0; i < mesh.faces.size(); i++ ) { p.beginShape(P.TRIANGLES); f = mesh.faces.get( i ); p.vertex(f.a.x, f.a.y); p.vertex(f.b.x, f.b.y); p.vertex(f.c.x, f.c.y); p.endShape(); } }
Example 4
Source File: ConcentricPolygonsLast.java From haxademic with MIT License | 4 votes |
public void drawDisc( PApplet p, float radius, float innerRadius, int numSegments, float offsetRads, float childDistAmp, int level, float x, float y ) { p.pushMatrix(); float segmentRads = P.TWO_PI / numSegments; // float halfThickness = lineWeight.value() / 2f; float leveActiveAmp = (level < 20) ? levelsActive[level].value() : 0; float nextRadius = radius * iterateShrink.value() * leveActiveAmp; float nextInnerRadius = innerRadius * iterateShrink.value() * leveActiveAmp; nextInnerRadius = nextRadius - lineWeight.value() * leveActiveAmp; offsetRads = (offsetRads == 0) ? (segmentRads / 2f) * offsetRotation.value() : 0; if(level < 1) offsetRads = 0; for( int i = 0; i < numSegments; i++ ) { // calc vertex float curRads = startRads + i * segmentRads + offsetRads; float nextRads = startRads + (i + 1) * segmentRads + offsetRads; // draw polygon mesh p.beginShape(P.TRIANGLES); p.vertex( P.cos( curRads ) * innerRadius, P.sin( curRads ) * innerRadius ); p.vertex( P.cos( curRads ) * radius, P.sin( curRads ) * radius ); p.vertex( P.cos( nextRads ) * radius, P.sin( nextRads ) * radius ); p.vertex( P.cos( curRads ) * innerRadius, P.sin( curRads ) * innerRadius ); p.vertex( P.cos( nextRads ) * innerRadius, P.sin( nextRads ) * innerRadius ); p.vertex( P.cos( nextRads ) * radius, P.sin( nextRads ) * radius ); p.endShape(); // update analysis numVertices += 6; minY = P.min(minY, y + P.sin( curRads ) * radius); maxY = P.max(maxY, y + P.sin( curRads ) * radius); // draw radial sticks if(radialConnections.value() > 0 && level < 99) { p.pushStyle(); p.stroke(255); p.strokeWeight(lineWeight.value() * radialConnections.value()); p.line(0, 0, P.cos( curRads ) * innerRadius, P.sin( curRads ) * innerRadius); p.popStyle(); } // draw circle if(circleRadius.value() > 0.0f && (level == circleLevelDisplay.target() || circleLevelDisplay.target() == 0) && level < 99) { float circleR = radius * circleRadius.value(); float circleInnerR = circleR - lineWeight.value() / 2f; if((numVertices < 300000 || RENDERING == true) && circleR > 1) drawDisc(p, circleR, circleInnerR, circleResolution, offsetRads, 999, 999, x, y); } // draw children if(level < maxLevels.target() && radius > 1) { // draw child polygon at vertices float radiusFromParent = (radius - ((radius - innerRadius))); radiusFromParent *= childDistAmp; float xAdd = P.cos( curRads ) * radiusFromParent; float yAdd = P.sin( curRads ) * radiusFromParent; p.pushMatrix(); p.translate(xAdd, yAdd); // recursion makes this additive if(numVertices < 300000 || RENDERING == true) drawDisc(p, nextRadius, nextInnerRadius, numSegments, offsetRads, childDistAmp, level + 1, x + xAdd, y + yAdd); p.popMatrix(); // draw stick from parent to child // if(radialConnections.value() > 0 && level < 99) { // p.pushStyle(); // p.stroke(255); // p.strokeWeight(lineWeight.value() * radialConnections.value()); // p.line(0, 0, xAdd, yAdd); // p.popStyle(); // } } } p.popMatrix(); }
Example 5
Source File: ConcentricPolygonsEased.java From haxademic with MIT License | 4 votes |
public void drawPolygon( PApplet p, float radius, float innerRadius, int numSegments, float offsetRads, float childDistAmp, int level, float x, float y ) { p.pushMatrix(); float segmentRads = P.TWO_PI / numSegments; // float halfThickness = lineWeight.value() / 2f; float leveActiveAmp = (level < 20) ? levelsActive[level].value() : 0; float nextRadius = radius * iterateShrink.value() * leveActiveAmp; float nextInnerRadius = innerRadius * iterateShrink.value() * leveActiveAmp; nextInnerRadius = nextRadius - lineWeight.value() * leveActiveAmp; offsetRads = (offsetRads == 0) ? (segmentRads / 2f) * offsetRotation.value() : 0; if(level < 1) offsetRads = 0; for( int i = 0; i < numSegments; i++ ) { // calc vertex float curRads = startRads + i * segmentRads + offsetRads; float nextRads = startRads + (i + 1) * segmentRads + offsetRads; // draw polygon mesh p.beginShape(P.TRIANGLES); p.vertex( P.cos( curRads ) * innerRadius, P.sin( curRads ) * innerRadius ); p.vertex( P.cos( curRads ) * radius, P.sin( curRads ) * radius ); p.vertex( P.cos( nextRads ) * radius, P.sin( nextRads ) * radius ); p.vertex( P.cos( curRads ) * innerRadius, P.sin( curRads ) * innerRadius ); p.vertex( P.cos( nextRads ) * innerRadius, P.sin( nextRads ) * innerRadius ); p.vertex( P.cos( nextRads ) * radius, P.sin( nextRads ) * radius ); p.endShape(); // update analysis numVertices += 6; minY = P.min(minY, y + P.sin( curRads ) * radius); maxY = P.max(maxY, y + P.sin( curRads ) * radius); // draw circles at vertices if(level < maxLevels.target() - 1) { if(circleRadius.value() > 0.0f && (level == circleLevelDisplay.target() || circleLevelDisplay.target() == 0) && level < 99) { float circleR = radius * circleRadius.value(); float circleInnerR = circleR - lineWeight.value() / 2f; p.pushMatrix(); p.translate(P.cos( curRads ) * innerRadius, P.sin( curRads ) * innerRadius); if(circleR > 1) drawPolygon(p, circleR, circleInnerR, circleResolution, offsetRads, 999, 999, x, y); p.popMatrix(); } } // draw radial sticks if(radialConnections.value() > 0 && level < 99) { p.pushStyle(); p.stroke(255); p.strokeWeight(lineWeight.value() * radialConnections.value()); p.line(0, 0, P.cos( curRads ) * innerRadius, P.sin( curRads ) * innerRadius); p.popStyle(); } // draw children if(level < maxLevels.target() && radius > 1) { // draw child polygon at vertices float radiusFromParent = (radius - ((radius - innerRadius))); radiusFromParent *= childDistAmp; float xAdd = P.cos( curRads ) * radiusFromParent; float yAdd = P.sin( curRads ) * radiusFromParent; p.pushMatrix(); p.translate(xAdd, yAdd); // recursion makes this additive drawPolygon(p, nextRadius, nextInnerRadius, numSegments, offsetRads, childDistAmp, level + 1, x + xAdd, y + yAdd); p.popMatrix(); // draw stick from parent to child // if(radialConnections.value() > 0 && level < 99) { // p.pushStyle(); // p.stroke(255); // p.strokeWeight(lineWeight.value() * radialConnections.value()); // p.line(0, 0, xAdd, yAdd); // p.popStyle(); // } } // draw circle from center of shape // if(circleRadius.value() > 0.0f && (level == circleLevelDisplay.target() || circleLevelDisplay.target() == 0) && level < 99) { // float circleR = radius * circleRadius.value(); // float circleInnerR = circleR - lineWeight.value() / 2f; // if(circleR > 1) drawPolygon(p, circleR, circleInnerR, circleResolution, offsetRads, 999, 999, x, y); // } } p.popMatrix(); }