public void drawApp() { p.background(255); float percentComplete = ((float) (p.frameCount % _frames) / _frames); float easedPercent = Penner.easeInOutSine(percentComplete, 0, 1, 1); // float easedPercentHard = Penner.easeInOutQuad(percentComplete, 0, 1, 1); // texture feedback float feedback = 10f; // * P.sin(percentComplete * P.TWO_PI); _texture.copy( _texture, 0, 0, _texture.width, _texture.height, P.round(-feedback / 2f), P.round(-feedback / 2f), P.round(_texture.width + feedback), P.round(_texture.height + feedback)); // start texture drawing _texture.beginDraw(); DrawUtil.setDrawCenter(_texture); _texture.noStroke(); // fade out _texture.fill(255, 15f); _texture.translate(p.width / 2f, p.height / 2f); _texture.rect(0, 0, p.width, p.height); // rotating circles float arms = 260; float circleInc = P.TWO_PI / arms; float radius = width / 6f; for (int i = 0; i < arms; i++) { float curRads = circleInc * i; float moreRads = curRads + easedPercent * P.TWO_PI; float radiuz = radius + radius / 2f * P.sin(moreRads + percentComplete * 1f * P.TWO_PI); _texture.pushMatrix(); _texture.translate(P.sin(moreRads) * radiuz, P.cos(moreRads) * radiuz); _texture.rotate(moreRads); _texture.fill( 60 + 50 * P.sin(moreRads), 127 + 80 * P.sin(curRads), 100 + 80 * P.sin(curRads), 200); _texture.ellipse(0, 0, 5, 5); _texture.popMatrix(); } // finish drawing _texture.endDraw(); // draw texture to stage DrawUtil.setColorForPImage(p); p.image(_texture, 0, 0); }
protected void drawGraphicsSunflow(PApplet pg) { p.noStroke(); DrawUtil.setDrawCenter(p); _jw.jr.background(JoonsWrapper.BACKGROUND_AO); _jw.jr.background(0, 0, 0); float frameRadians = P.TWO_PI / _frames; float percentComplete = ((float) (p.frameCount % _frames) / _frames); float radiansComplete = P.TWO_PI * percentComplete; float easedPercent = Penner.easeInOutCubic(percentComplete, 0, 1, 1); float easedPercentHard = Penner.easeInOutQuad(percentComplete, 0, 1, 1); setUpRoom(); p.translate(0, p.height * 0.1f, -480); // white bg block // p.pushMatrix(); // p.translate(0,0,-1500); // DrawUtil.setDrawCenter(p); // p.fill(255); // _jw.jr.fill( JoonsWrapper.MATERIAL_SHINY, 255, 255, 255 ); // p.box(p.width*10, p.width*10, 2); // p.popMatrix(); p.rotateX(4.6f + P.sin(radiansComplete) * 0.01f); int numDiscs = 30; float spacing = p.width * 0.019f; p.translate(0, 0, spacing * numDiscs * 0.3f); for (int i = 0; i < numDiscs; i++) { float percentDone = percentComplete + ((float) i / numDiscs); float size = p.width * 0.3f + p.width * 0.01f * P.sin(percentDone * P.TWO_PI); int discColor = p.color(200 + (i * 5), 100 + (i * 5), 170 - (i * 5), 0.3f); p.fill(discColor); p.translate(0, 0, -spacing); _jw.jr.fill( JoonsWrapper.MATERIAL_SHINY, ColorHax.redFromColorInt(discColor), ColorHax.greenFromColorInt(discColor), ColorHax.blueFromColorInt(discColor)); drawDisc3D( size, size * 0.9f - size * (P.sin(percentDone * P.TWO_PI) + 1) * 0.15f, spacing * 0.25f, 140, discColor, discColor); // drawDisc(size, size * 0.9f - size * (P.sin(percentDone * P.TWO_PI)+1) * 0.15f, 140); } }
public void drawApp() { buff.update((float) Math.sin(p.frameCount / 20f) * 10f); P.println( MathUtil.roundToPrecision(buff.sum(), 2), " | ", MathUtil.roundToPrecision(buff.sumPos(), 2), " | ", MathUtil.roundToPrecision(buff.sumNeg(), 2)); }
protected void drawGraphicsNative(PGraphics pg) { DrawUtil.setDrawCenter(pg); pg.beginDraw(); pg.clear(); DrawUtil.setBasicLights(pg); float frameRadians = P.TWO_PI / _frames; float percentComplete = ((float) (p.frameCount % _frames) / _frames); float radiansComplete = P.TWO_PI * percentComplete; float easedPercent = Penner.easeInOutCubic(percentComplete, 0, 1, 1); float easedPercentHard = Penner.easeInOutQuad(percentComplete, 0, 1, 1); // pg.background(0); pg.translate(p.width / 2, p.height / 2 + p.height * 0.04f); pg.blendMode(P.SCREEN); // pg.blendMode(P.MULTIPLY); // pg.rotateY(p.mouseX * 0.01f); // pg.rotateX(p.mouseY * 0.01f); pg.rotateX(4.3f + 0.01f * P.sin(percentComplete * P.TWO_PI)); // pg.rotateX(4.3f); pg.noStroke(); int numDiscs = 25; float spacing = p.width * 0.019f; pg.translate(0, 0, spacing * numDiscs * 0.3f); for (int i = 0; i < numDiscs; i++) { float percentDone = percentComplete + ((float) i / numDiscs); float size = p.width * 0.3f + p.width * 0.01f * P.sin(percentDone * P.TWO_PI); int discColor = p.color(200 + (i * 5), 100 + (i * 5), 170 - (i * 5), 60); pg.fill(discColor); pg.translate(0, 0, -spacing); // Shapes.drawDisc3D(pg, size, size * 0.9f - size * (P.sin(percentDone * P.TWO_PI)+1) * // 0.15f, spacing, 40, discColor, discColor); Shapes.drawDisc( pg, size, size * 0.9f - size * (P.sin(percentDone * P.TWO_PI) + 1) * 0.15f, 6); } pg.endDraw(); }
public void update() { // move camera _curX = p.width / 2.0f + cameraXSpeed * curFrameCount; _curY = p.height / 2.0f + cameraYSpeed * curFrameCount; _curZ = (p.height / 2.0f) / P.tan(PConstants.PI * 60.0f / 360.0f) + cameraZSpeed * curFrameCount; // aim camera super.update(); // curFrameCount++; if (curFrameCount >= recycleAfterNumFrames) { curFrameCount = 0; // init(); } }
public static void drawDisc3D( float radius, float innerRadius, float cylinderHeight, int numSegments, int color, int wallcolor) { float segmentCircumference = (2f * P.PI) / numSegments; float halfHeight = cylinderHeight / 2; // top/bottom discs p.pushMatrix(); p.translate(0, 0, halfHeight); drawDisc(radius, innerRadius, numSegments); p.popMatrix(); p.pushMatrix(); p.translate(0, 0, -halfHeight); drawDisc(radius, innerRadius, numSegments); p.popMatrix(); p.beginShape(P.TRIANGLES); for (int i = 0; i < numSegments; i++) { // if( wallcolor > 0 ) p.fill( wallcolor ); // outer wall p.vertex( P.sin(i * segmentCircumference) * radius, P.cos(i * segmentCircumference) * radius, halfHeight); p.vertex( P.sin(i * segmentCircumference) * radius, P.cos(i * segmentCircumference) * radius, -halfHeight); p.vertex( P.sin((i + 1) * segmentCircumference) * radius, P.cos((i + 1) * segmentCircumference) * radius, halfHeight); p.vertex( P.sin(i * segmentCircumference) * radius, P.cos(i * segmentCircumference) * radius, -halfHeight); p.vertex( P.sin((i + 1) * segmentCircumference) * radius, P.cos((i + 1) * segmentCircumference) * radius, halfHeight); p.vertex( P.sin((i + 1) * segmentCircumference) * radius, P.cos((i + 1) * segmentCircumference) * radius, -halfHeight); // only draw inner radius if needed if (innerRadius > 0) { // if( wallcolor > 0 ) p.fill(wallcolor); // inner wall p.vertex( P.sin(i * segmentCircumference) * innerRadius, P.cos(i * segmentCircumference) * innerRadius, halfHeight); p.vertex( P.sin(i * segmentCircumference) * innerRadius, P.cos(i * segmentCircumference) * innerRadius, -halfHeight); p.vertex( P.sin((i + 1) * segmentCircumference) * innerRadius, P.cos((i + 1) * segmentCircumference) * innerRadius, halfHeight); p.vertex( P.sin(i * segmentCircumference) * innerRadius, P.cos(i * segmentCircumference) * innerRadius, -halfHeight); p.vertex( P.sin((i + 1) * segmentCircumference) * innerRadius, P.cos((i + 1) * segmentCircumference) * innerRadius, halfHeight); p.vertex( P.sin((i + 1) * segmentCircumference) * innerRadius, P.cos((i + 1) * segmentCircumference) * innerRadius, -halfHeight); } } p.endShape(); }
public static void drawDisc(float radius, float innerRadius, int numSegments) { p.pushMatrix(); // draw triangles for (int i = 0; i < numSegments; i++) { p.beginShape(P.TRIANGLES); float segmentCircumference = (2f * P.PI) / numSegments; p.vertex( P.sin(i * segmentCircumference) * innerRadius, P.cos(i * segmentCircumference) * innerRadius, 0); p.vertex( P.sin(i * segmentCircumference) * radius, P.cos(i * segmentCircumference) * radius, 0); p.vertex( P.sin((i + 1) * segmentCircumference) * radius, P.cos((i + 1) * segmentCircumference) * radius, 0); p.vertex( P.sin(i * segmentCircumference) * innerRadius, P.cos(i * segmentCircumference) * innerRadius, 0); p.vertex( P.sin((i + 1) * segmentCircumference) * innerRadius, P.cos((i + 1) * segmentCircumference) * innerRadius, 0); p.vertex( P.sin((i + 1) * segmentCircumference) * radius, P.cos((i + 1) * segmentCircumference) * radius, 0); p.endShape(); } p.popMatrix(); }