Created
March 31, 2013 21:16
-
-
Save lisawilliams/5282031 to your computer and use it in GitHub Desktop.
Easter Egg Sketch 2. This one uses a loop to change the color of the eggs.
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
// easter egg sketch! | |
// set up some variables for the egg colors. | |
// taken together, these are RGB purple | |
int r = 206; | |
int g = 93; | |
int b = 219 ; | |
// set the size of the background | |
size (400, 400); | |
// set the color of the background (robin's egg blue) | |
background (93, 199, 219); | |
// create a nested loop that repeats drawing eggs | |
for (int y = 0; y <= height; y += 40) { | |
for (int x = 0; x <= width; x += 40) { | |
// Let's set the color of the eggs, and then change them | |
// progressively each time the loop runs. | |
// first, we'll say if "r" -- the R value in our RGB is | |
// less than 255 (black), then we'll mess with the colors! | |
if (r < 255) | |
// if r is less than 255 | |
// take whatever the r(ed) value is and multiply by 1.3 | |
// add one to the g(reen) value | |
// and subtract one from the b(lue) value | |
fill ((r*1.5), g++, b--); | |
// no outer line around the eggs | |
noStroke(); | |
// draw an oval for the egg -- x and y are the horizontal | |
// and vertical start points; 40 and 30 | |
// are the dimensions | |
ellipse (x, y, 40, 30); | |
} | |
} | |
// Let's create a nice decorative font for our message | |
PFont easterFont; | |
easterFont = loadFont("BernardMT-Condensed-36.vlw"); | |
textFont(easterFont); | |
// Let's set the color of the text -- white (255) | |
fill(255); | |
// Let's print our holiday message | |
// and set where it appears on the canvas | |
// (90px from left edge, 200 from top edge) | |
text("Happy Easter", 110, 200); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To import fonts, use Tools > Font Creator in the Processing IDE. If not, it will just default to a standard font. You can change the size of the font using textSize(). So if you wanted the text of the greeting bigger, you could do something like:
textSize(48);