Last active
August 29, 2015 13:56
-
-
Save francis36012/9149434 to your computer and use it in GitHub Desktop.
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
/* | |
Beautiful night landscape with a full moon and a clear sky that gives you a feeling of peace. | |
The mountains and the stars are generated dynamically | |
*/ | |
color[] colors = {#FFF8E3, #FFFDD6, #FFFDFC, #F3FFD6, #FDF6C7, #E2E2E2}; | |
color[] shades = {#18222B, #202E3B, #34495E}; | |
void setup() { | |
size(1000,707); | |
background(shades[2]); | |
smooth(); | |
noLoop(); | |
noStroke(); | |
} | |
void draw() { | |
float size; | |
for(int i = 0; i < 125; i++) { | |
fill(colors[int(random(4))], 125); | |
size = random(2, 3); | |
star(int(random(width)), int(random(height/2 + 150)) - 50, size, size + 5, 5); | |
} | |
fill(colors[5]); | |
ellipse(770, 120, 100, 100); | |
for(int i = 0; i < 3000; i+=20) { | |
fill(shades[int(random(2))], 230); | |
triangle(i, height/2 +300, i + 100, random(575, height/2 +300), random(i +100, width), height/2+300); | |
} | |
fill(shades[0]); | |
rect(0, height/2 +300, width, 500); | |
} | |
void star(float x, float y, float radius1, float radius2, int npoints) { | |
float angle = TWO_PI / npoints; | |
float halfAngle = angle/2.0; | |
beginShape(); | |
for (float a = 0; a < TWO_PI; a += angle) { | |
float sx = x + cos(a) * radius2; | |
float sy = y + sin(a) * radius2; | |
vertex(sx, sy); | |
sx = x + cos(a+halfAngle) * radius1; | |
sy = y + sin(a+halfAngle) * radius1; | |
vertex(sx, sy); | |
} | |
endShape(CLOSE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment