|
//Jenny Macy
task03
//Programming For Artists
//10-10-02
// create canvas object to access drawCommands
//
var C = new Canvas();
//
// call canvas methods via dot syntax
C.setBackgroundColor(.3, .3,.3);
C.setPenColor(.9,.9,.9);
C.setPenWeight(Math.random()*.02);//randomize
the penweight between 0 and .03
// make the grid funcion to control the # of columns
and rows
function Grid (C,rows,columns){
//make variables scaleable/paramaterize width and
height of grid boxes
if (rows > 12){//setting
a max input value for rows
rows = 12;
}
if (columns > 12){//setting
a max input value for columns
columns = 12;
}
if (rows < 1){
rows=1;
}
if (columns < 1){
columns=1;
}
var BBoxW = 1/rows;
var BBoxH = 1/columns;
var x = BBoxW;
var y = BBoxH;
//make function for small boxes to use in loops
function BOX(C,scale,i,j){
C.setPenColor(Math.random(),y,x);//randomize
pencolor and make relative to row width and column
C.drawLine (((x*i)-x) + scale, ((y*j)-y)+scale, (x*i)-scale, ((y*j)-y)+scale);//TOP
C.drawLine ((x*i)-scale, ((y*j)-y)+scale, (x*i)-scale, (y*j)-scale);//RIGHT
C.drawLine ((x*i)-scale, (y*j)-scale, ((x*i)-x)+scale, (y*j)-scale);//BOTTOM
C.drawLine (((x*i)-x)+scale, (y*j)-scale, ((x*i)-x)+scale, ((y*j)-y)+scale);//LEFT
}
// double for loop to draw many boxed in a grid
format
for (var j=1;
j<columns+1; j++){//loop to make columns
for (var i=1;
i<rows+1; i++){//subloop to make rows
BOX(C,.02*Math.random(),i,j);//calling
BOX function to make a box in the grid
BOX(C,.08*Math.random(),i,j);
BOX(C,.05*Math.random(),i,j);
}
}
}
//call grid function
Grid(C,10,10);
//
//
//
// stop playback head to prevent continuous redrawing
//
stop();
|
|