Pages

Friday, February 21, 2014

Khan Academy code.

Someone on Khan Academy said I could make a repeating function.
So now i must try.



//CAUSE I LOVE RAINBOWS, they are pretty. No real other reason.

var RAINBOW = (random(0,175 ), random(0, 75), random(0, 175));
strokeWeight(2);
stroke(RAINBOW);

//make lines!

var draw = function() {
   
     background(223, 225, 237);
    //trying to make a line repeat without typing code for each line
    //I made a list for colors, but the OH NOES!!! guy keeps prompting me to use
    //the blue() command, so apparently you can't use the word blue!!!
    //i is for the plottinglist... or repeat function I plan on making
    //empty plotting list, so you can make it whatever length you want
    
     var plottinglist = [];
     plottinglist.length = 40; //so here you could ask for user input.
    for (var i = 0; i < plottinglist.length; i+=1) {
        var x1 = 0;
        var x2 = 400;
        var y1 = 10;  
        var y2 = 10;
        var change = i * 10;
        line(x1, y1 + change, x2, y2 + change);}
     for (var i = 0; i < plottinglist.length; i+=1) {
        var change = i * 10; 
        var x = 10;
        var y = 10;
        var xa = 10;
        var ya = 400;
        line(x + change, y, xa + change, ya);}
       
    
    
       
   
};

No comments:

Post a Comment