Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- fullScreen(P3D);
- }
- void draw() {
- background(240);
- stroke(15);
- noFill();
- drawEulerSpiral(width/2, height/2, frameCount*0.01, 1000, 500.0);
- }
- void drawEulerSpiral(float centerX, float centerY, float range, int numPoints, float scale) {
- float ds=range/numPoints;
- float prevX=0;
- float prevY=0;
- float currentX=0;
- float currentY=0;
- float s=0;
- for (int i=0; i<numPoints; i++) {
- prevX=currentX;
- prevY=currentY;
- currentX+=scale*Math.cos(s*s)*ds;
- currentY+=scale*Math.sin(s*s)*ds;
- line(centerX+prevX, centerY+prevY, centerX+currentX, centerY+currentY);
- line(centerX-prevX, centerY-prevY, centerX-currentX, centerY-currentY);
- s+=ds;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement