Last active
December 16, 2015 08:19
-
-
Save ravicious/5404981 to your computer and use it in GitHub Desktop.
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 m; | |
void setup() { | |
size(500, 500); | |
frameRate(30); | |
} | |
void draw() { | |
background(176, 226, 206); | |
m = millis(); | |
drawSun(); | |
drawRobotAndGrass(); | |
} | |
void drawSun() { | |
// maksymalna wartość G dla żółtego słońca to 229 | |
fill(255, 199 + 60*sin(m/1440), 69); | |
stroke(255, 199 + 60*sin(m/1440), 69); | |
pushMatrix(); | |
translate(width/2, height/2); | |
rotate(radians(((m/-25) % 720))); | |
ellipse(200, 150, 65, 65); | |
popMatrix(); | |
} | |
void drawRobotAndGrass() { | |
// przesuń oś x na środek okna | |
pushMatrix(); | |
translate(width/2, 0); | |
// zmień tryb rysowania prostokątów i elips | |
rectMode(CENTER); | |
ellipseMode(CENTER); | |
// trawa | |
fill(184, 199, 168); | |
stroke(184, 199, 168); | |
rect(0, 400, 500, 200); | |
fill(200); | |
stroke(33); | |
// szyja | |
rect(0, 155, 15, 40); | |
// głowa | |
rect(0, 110, 60, 60); | |
// oczy | |
ellipse(-15, 100, 15, 15); | |
ellipse(-15, 100, 2, 2); | |
ellipse(15, 100, 15, 15); | |
ellipse(15, 100, 2, 2); | |
// usta | |
rect(0, 128, 40, 5); | |
// nogi | |
rect(-25, 370, 30, 140); | |
rect(25, 370, 30, 140); | |
// korpus | |
rect(0, 240, 120, 180); | |
// ręka po prawej | |
rect(60, 230, 20, 120); | |
popMatrix(); | |
// kod obracający rękę | |
pushMatrix(); | |
rectMode(CORNER); | |
translate(190, 168); | |
rotate(radians(20 * sin(m/500))); | |
rect(-10, -120, 20, 120); | |
popMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment