-
-
Save ip413/9a9c0a90dcefbf2ed5365e147e8e2783 to your computer and use it in GitHub Desktop.
Sketch of my generative art, "50 Lines"
This file contains hidden or 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 decel(float x) { // as an easing function | |
return 1-(x-1)*(x-1); | |
} | |
void setup() { | |
background(255); | |
size(750,750,P2D); | |
PImage img = loadImage("image.png"); | |
strokeWeight(2); | |
noFill(); | |
for(float y=0.0;y<50;y++) { | |
float l = 0; | |
beginShape(LINES); | |
for(float x=0;x<width*4;x++) { | |
float xx=x/4.0; | |
// using this version will generate a squished image due to using map(...) in line 26 | |
// color c = img.get(int(xx),int(y*height/50.0)); | |
color c = img.get(int(xx),int(map(y*height/50.0,0,height,50,height-50))); | |
l += (255-red(c))/255/4.0; // period of the wave | |
// 5*decel(m) sets the amplitude of the wave | |
// map(...) sets the position of the wave | |
float m = (255-red(c))/255.0; // separate it from an increasing variable (l) | |
vertex(xx,map((y+0.5)*height/50.0,0,height,50,height-50)+sin(l*PI/2.0)*5*decel(m)); | |
} | |
endShape(); | |
} | |
saveFrame("image-edit.png"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment