task 03

product

code:

#include "Canvas.as"

// intended to be viewed at size: 600 by 600 pixels



/* This images contains the Star of David  
   in 1-point perspective. The background
   is a quilted pattern of varying shades
   of blue. I chose blue and white because
   they are the two colors most associated
   with the Star of David.
*/


// common parameters and variables
Canvas.setBackgroundColor(.00, .00, 1.0);
var penMax = .075;
// trace commands helped me monitor values



// background pattern


// vertical line loop
var xLine = 0;
var startLine = 0;
var endLine = 1;

Canvas.setPenWeight(penMax-.025);
Canvas.setPenColor(.0, .0, .5);
while(xLine <= 1.01) // goes off page without error
{
Canvas.drawLine(xLine, startLine, xLine, endLine);
trace(xLine);
xLine = xLine + .04;
}

// horizontal line loop
var yLine = 0;
var startLine = 0;
var endLine = 1;

Canvas.setPenWeight(.05);
Canvas.setPenColor(.0, .0, .7);
while(yLine <= 1.01) // goes off page without error
{
Canvas.drawLine(startLine, yLine, endLine, yLine);
trace(yLine);
yLine = yLine + .04;
}



// Star of David

//triangle b is inverted, triangle a is upright
Canvas.setPenWeight(penMax);


// triangle b, smallest

var bstartPoint = .475;
var bbaseLine = .475;
var bheight = .525;
var bcx = .50;

// triangle a, smallest

var astartPoint = .475;
var abaseLine = .525;
var aheight = .525;
var acx = .500;

// Star of David loop variables

var reps = 12; // no negative space
var n = 0; // [0, reps - 1]
var x = n/11 // normalizes n for color purposes
var bgrow = 1 / (reps * 2);
var bmgrow = bgrow - .02; // keeps triangle in proper proportions
var agrow = 1 / (reps * 2);
var amgrow = agrow - .02; // keeps triangle in proper proportions

// Star of David loop

while (n < reps) {
  
  // change color from dark to light
  Canvas.setPenColor(x, x, x);
  
  // draw b
  Canvas.drawLine(bstartPoint, bbaseLine, bheight, bbaseLine); // -
  Canvas.drawLine(bheight, bbaseLine, bcx, bheight); // /
  Canvas.drawLine(bcx, bheight, bstartPoint, bbaseLine); // \

  // draw a
  Canvas.drawLine(astartPoint, abaseLine, aheight, abaseLine); // -
  Canvas.drawLine(aheight, abaseLine, acx, astartPoint); // \
  Canvas.drawLine(acx, astartPoint, astartPoint, abaseLine); // /

  // move endpoints away from center
  bbaseLine -= bmgrow;
  bstartPoint -= bgrow;
  bheight += bgrow;
  abaseLine += amgrow;
  astartPoint -= agrow;
  aheight += agrow;

  // loop completed, add 1 to n
  trace(n);
  trace(x);
  n++;
  x = n/11; // reassign x with n's new normalized value
  
}

// Completed October 15, 2003 by Fran Kalal