Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float seed;
- float strokeWidth;
- void setup() {
- size(800,500);
- background(0);
- seed = random(10000);
- strokeWidth = 15f/800*width;
- }
- void draw() {
- if (strokeWidth > 1) {
- for (int i = 0; i < 100; i++)placeStroke(random(width), random(height), 15f/800*width, 15f/800*width);
- strokeWidth *= .85;
- }
- }
- void keyPressed() {
- if (key == 's') {
- saveFrame("this-####.jpg");
- } else {
- seed = random(10000);
- strokeWidth = 15f/800*width;
- }
- }
- void dobackground() {
- for (float x = 0; x < width; x++) {
- }
- }
- color backgroundColor(float x, float y) {
- color sky = color(#1339CE);
- color whitesky = color(#7993F0);
- float whiteskyfactor = noise(x*.005, y*.01, seed);
- whiteskyfactor -= .6;
- whiteskyfactor = smoothstep(-.1, .1, whiteskyfactor);
- sky = lerpColor(sky, whitesky, whiteskyfactor);
- color star = color(#EDED8B);
- float starfactor = noise(x*.005, y*.005, seed);
- starfactor = pow(starfactor, 1.7);
- starfactor = starfactor-.5;
- starfactor = smoothstep(-.03, .05, starfactor);
- sky = lerpColor(sky, star, starfactor);
- return sky;
- }
- void placeStroke(float x, float y, float w, float h) {
- float rw = random(1)*w;
- float t = random(PI*2);
- for (float i = 0; i < rw; i++) {
- t += PI*2/rw;
- pushMatrix();
- float rx, ry;
- rx = random(-w, w);
- ry = random(-h, h);
- translate(x, y);
- translate(rx, ry);
- rotate(t);
- strokeWeight(strokeWidth);
- translate(0, -h/2);
- color c =pickColor(rx+x, ry+y);
- color b = color(random(255));
- c = lerpColor(c,b,random(.2));
- stroke(c);
- line(0, 0, 0, h);
- popMatrix();
- }
- }
- float smoothstep(float edge0, float edge1, float t) {
- t =constrain((t-edge0)/(edge1-edge0), 0, 1);
- return t;
- }
- color pickColor(float x, float y) {
- color c;
- float ny = noise(x*.015, seed);
- ny *= height;
- float d = y-ny-height/4;
- float mountainvssky = smoothstep(-20, 20, d);
- mountainvssky = smoothstep(0, 1, mountainvssky);
- color sky = color(#1339CE);
- color whitesky = color(#7993F0);
- float whiteskyfactor = noise(x*.005, y*.01, seed);
- whiteskyfactor -= .6;
- whiteskyfactor = smoothstep(-.1, .1, whiteskyfactor);
- sky = lerpColor(sky, whitesky, whiteskyfactor);
- color star = color(#EDED8B);
- float starfactor = noise(x*.005, y*.005, seed);
- starfactor = pow(starfactor, 1.7);
- starfactor = starfactor-.5;
- starfactor = smoothstep(-.03, .05, starfactor);
- sky = lerpColor(sky, star, starfactor);
- color mountain = color(#4E5262);
- mountain = lerpColor(mountain, color(0), smoothstep(height/2, height, y));
- c = sky;
- c = lerpColor(sky, mountain, mountainvssky);
- c = lerpColor(c, color(random(255), random(255), random(255)), .02);
- return c;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement