Last active
July 14, 2020 15:08
-
-
Save RemyPorter/cdb44004583113dba1f4ba0e924c43ca to your computer and use it in GitHub Desktop.
A simple version of the Visual Phaser for Gisting Purposes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float FR = 60; | |
float SPEED = 2; | |
float STEP = 20; | |
float R = 40; | |
float DOT_SIZE = 4; | |
boolean RECORD = false; | |
boolean DRAW_CIRCLES = true; | |
float phase(float x, float y) { | |
return 0; | |
//return noise(x, y)*2*PI; | |
//return sin(x/width * 2 * PI)*2*PI; | |
//return smoothstep(0, 1, x/width * y/height)*2*PI*4; | |
} | |
void setup() { | |
size(640, 480, P3D); | |
//fullScreen(P3D); | |
ellipseMode(CENTER); | |
frameRate(FR); | |
noStroke(); | |
fill(255); | |
} | |
//no need to edit below this point | |
void draw() { | |
clear(); | |
float t = frameCount / FR * SPEED; | |
if (RECORD && t >= 2 * PI) exit(); | |
for (float x = -STEP-R; x < width + STEP+R; x+=STEP) { | |
for (float y = -STEP-R; y < height + STEP+R; y+=STEP) { | |
float p = phase(x,y); | |
drawPoint(x, y, R, p, t); | |
if (DRAW_CIRCLES) { | |
stroke(#0000FF); | |
strokeWeight(1); | |
noFill(); | |
ellipse(x, y, R*2, R*2); | |
noStroke(); | |
fill(255); | |
} | |
} | |
} | |
if (RECORD) saveFrame("###.tiff"); | |
} | |
void drawPoint(float x, float y, float r, float phase, float time) { | |
pushMatrix(); | |
translate(x, y); | |
ellipse( | |
r * sin(phase+time), | |
r * cos(phase+time), | |
DOT_SIZE, DOT_SIZE | |
); | |
popMatrix(); | |
} | |
public float smoothstep(float edge0, float edge1, float x) { | |
float t = constrain((x - edge0)/(edge1 - edge0), 0.0, 1.0); | |
return t * t * (3.0 - 2.0 * t); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment