TAD2011.03 Planetary Color Grid

Third TAD project. I intend to use the 2D array in future sketches.

Planetary Color Grid

Source code:

/**
 * PlanetaryColorGrid
 * by Joshua Madara, hyperRitual.com
 * This project displays a grid of the planetary colors
 * for each hour * day of the week, per "Table of the Planetary 
 * Hours" from the "Introduction" to Mathers' _The Key of 
 * Solomon the King_. The colors are specified in the 
 * same book: "Table of the Archangels, Angels, Metals, 
 * Days of the Week, and Colours Attributed to each Planet."
 */

// set color for each planet
color MER = #800080; // Mercury, Purple
color MOO = #FFFFFF; // Moon, White
color SAT = #000000; // Saturn, Black
color JUP = #0000FF; // Jupiter, Blue
color MAR = #FF0000; // Mars, Red
color SUN = #FFFF00; // Sun, Yellow
color VEN = #008000; // Venus, Green

// create 2D array to store color by hour (row) and day (column)
color[][] TBL = {
// SUN,MON,TUE,WED,THU,FRI,SAT
  {MER,JUP,VEN,SAT,SUN,MOO,MAR}, // 12 AM
  {MOO,MAR,MER,JUP,VEN,SAT,SUN}, // 1
  {SAT,SUN,MOO,MAR,MER,JUP,VEN}, // 2
  {JUP,VEN,SAT,SUN,MOO,MAR,MER}, // 3
  {MAR,MER,JUP,VEN,SAT,SUN,MOO}, // 4
  {SUN,MOO,MAR,MER,JUP,VEN,SAT}, // 5
  {VEN,SAT,SUN,MOO,MAR,MER,JUP}, // 6
  {MER,JUP,VEN,SAT,SUN,MOO,MAR}, // 7
  {MOO,MAR,MER,JUP,VEN,SAT,SUN}, // 8
  {SAT,SUN,MOO,MAR,MER,JUP,VEN}, // 9
  {JUP,VEN,SAT,SUN,MOO,MAR,MER}, // 10
  {MAR,MER,JUP,VEN,SAT,SUN,MOO}, // 11
  {SUN,MOO,MAR,MER,JUP,VEN,SAT}, // 12 PM
  {VEN,SAT,SUN,MOO,MAR,MER,JUP}, // 1
  {MER,JUP,VEN,SAT,SUN,MOO,MAR}, // 2
  {MOO,MAR,MER,JUP,VEN,SAT,SUN}, // 3
  {SAT,SUN,MOO,MAR,MER,JUP,VEN}, // 4
  {JUP,VEN,SAT,SUN,MOO,MAR,MER}, // 5
  {MAR,MER,JUP,VEN,SAT,SUN,MOO}, // 6
  {SUN,MOO,MAR,MER,JUP,VEN,SAT}, // 7
  {VEN,SAT,SUN,MOO,MAR,MER,JUP}, // 8
  {MER,JUP,VEN,SAT,SUN,MOO,MAR}, // 9
  {MOO,MAR,MER,JUP,VEN,SAT,SUN}, // 10
  {SAT,SUN,MOO,MAR,MER,JUP,VEN}, // 11
};

// variable x and y positions for each square in grid
int xPos = 0;
int yPos = 0;

void setup() {
  size(70, 240); // columns * 10, rows * 10
  noStroke(); // fill only
  noLoop(); // draw once
}

void draw() {
  yPos = 0;
  for(int i = 0; i < 24; i++) { // for all rows
    xPos = 0;
    for(int j = 0; j < 7; j++) { // for all columns
      fill(TBL[i][j]); // set color of square
      rect(xPos, yPos, 10, 10); // draw square
      xPos += 10; // move to draw next column
    }
    yPos += 10; // move to draw next row
  }
}

Leave a Reply