Jeff Ostergaard
Programming Concepts and Applications

ACCAD 756


Task# 03
Handling Ranges
Due Date October 10, 2002
As the value for "lineLink" increases between 1 and 900 the number of lines increases and teh color shifts proportionately.
Above: lineLink(900)
Above: lineLink(900) Demonstrating the color shift
Source Code

//
// Ostergaard, Task 03
//
function lineLink(input) {

     // instantance object
     var C = new Canvas();
     C.setBackgroundColor (.92, .92, .92);
     C.setPenWeight(.0065)

     // normalize
     var normI = input * (1.0 / 999);

     // variables for loop
     var p1x = normI * .55;
     var p1y = p1x * .75;
     var p2x = normI * .75;
     var p2y = p1y * .55;

     // create some loop counter variables
     var x = Math.random();

     // draw lines
     while (p1x < 1) {
     C.setPenColor (p1x / (normI + .25), p1y / normI, x); // color shift
     C.drawLine(p1x / normI, p1y + .4, p2x, p2y); //middle
     C.drawLine(p1x / normI, p1y, 0, normI); //top
     p1x += .015; // higher the input higher # lines
     }
}
//
lineLink(900);
Above: (L to R) lineLink(10), lineLink(100), lineLink(500), & (shown at top of page) lineLink(900) Demonstrating the increase in the number of lines.