Created
January 6, 2014 19:01
-
-
Save learningjs/8287828 to your computer and use it in GitHub Desktop.
coursesites.com - genart_processing - Constellations Sketch Preface “Constellations have always been troublesome things to name. If you give one of them a fanciful name, it will always refuse to live up to it; it will always persist in not resembling the thing it has been named for. Ultimately, to satisfy the public, the fanciful name has to be …
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
// Gemini | |
// http://stardate.org/nightsky/constellations/gemini | |
void setup() { | |
// Sets sketch size | |
size(400, 400); | |
// Translates origin point (now "0, 0" are placed at "width / 5, height / 5" and not at upper left corner anymore) | |
translate(width / 5, height / 5); | |
// Sets background color | |
background(0); | |
// Disables all smoothing | |
noSmooth(); | |
// Draws the whole Costellation | |
drawCostellation(); | |
} | |
/** | |
* Draws a whole Costellation | |
*/ | |
void drawCostellation() { | |
// Starts at bottom left corner, continue clockwise | |
// 1 : | |
// point(150, 240); | |
drawStar(150, 240, 7, 4); | |
// 2 : Alhena | |
// point(175, 210); | |
drawStar(175, 210, 15, 5); | |
// 3 : | |
// point(120, 155); | |
drawStar(120, 155, 5, 2); | |
// 4 : Wasat | |
// point(85, 130); | |
drawStar(85, 130, 7, 3); | |
// 5 : Pollux | |
// point(50, 50); | |
drawStar(50, 50, 20, 7); | |
// 6 : Castor | |
// point(90, 25); | |
drawStar(90, 25, 15, 5); | |
// 7 | |
// point(180, 120); | |
drawStar(180, 120, 8, 3); | |
// 8 | |
// point(225, 155); | |
drawStar(225, 155, 12, 5); | |
// 9 | |
// point(240, 160); | |
drawStar(240, 160, 10, 4); | |
} | |
/* * | |
* Draws a single star with its halo | |
* | |
* @param x star x position | |
* @param y star y position | |
* @param dHalo star halo diameter | |
* @param dstar star diameter | |
*/ | |
void drawStar(int x, int y, int dHalo, int dStar) { | |
// Halo | |
// Sets halo color | |
stroke(235, 235, 45, 125); | |
// Sets halo diameter | |
strokeWeight(dHalo); | |
// Draws halo | |
point(x, y); | |
// Star | |
// Sets star color | |
stroke(255, 255, 255); | |
// Sets star diameter | |
strokeWeight(dStar); | |
// Draws star | |
point(x, y); | |
} | |
// Utilities | |
// Needed for key use | |
void draw() {} | |
// Saves a screenshot | |
void keyPressed() { | |
if (key == 's' || key == 'S') { | |
saveFrame("screenshot_##.png"); | |
} | |
} | |
// Useful to find stars coordinates | |
void drawImage() { | |
// http://stardate.org/sites/default/files/imagecache/node_display_small/images/resources/gemini.jpg | |
// Loads image | |
PImage img = loadImage("gemini.jpg"); | |
// Draws the actual image | |
image(img, 0, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment