xxxxxxxxxx
49
let randomY = [1,150,190,200];
function setup() {
createCanvas(400, 400);
// for(let i =0; i< 2; i++){
// randomY.push(random(100,300));
// }
}
function draw() {
background(0);
randomY.push(random(1,200));
drawLines(0,height/2,200,randomY);
}
function drawLines(posX,posY,s,points){
push();
//draw background
translate(posX,posY);
//rotate((3*PI)/2);
noStroke();
fill(255);
rect(0,0,s,s);
//find largest number
let record = 0;
for(let p of points){
if(p > record){
record = p;
}
}
stroke(0);
let px = 0;
let py = map(points[0],0,record,s,0);
for(let i =0; i < points.length; i++){
let x = i * (s / (points.length-1));
let y = map(points[i],0,record,s,0);
line(px, py, x, y);
px = x;
py = y;
}
pop();
}