Last active
June 13, 2024 08:03
-
-
Save u-ndefine/8e4bc21be4275f87fefe7b2a68487161 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"); | |
} |
Hi there. I've made a Python version
https://github.com/AmantayAbdurakhmanov/misc/blob/master/50_Lines.ipynb
Hi, awesome script. I've made Telegram bot version on python
https://github.com/kill-your-soul/50_lines
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice script! I've made web version of this using canvas: https://loskir.github.io/50-lines