Hey, I want to make a terrain generator in p5. So, I need WebGL to rotate the canvas on X axis. But, even trying to render 500 lines makes the whole sketch extremely slow. If I remove the WEBGL
, the sketch runs pretty fast. Can someone please help?
let l = []
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
background(0)
for(let i=0; i<500; i++){
l.push([random(width), random(height)])
}
}
function draw() {
background(0)
//WebGL translates everything to the middle of the screen. This is to fix that
translate(-width, -height)
// I want the shape to follow my mouse
translate(mouseX, mouseY)
beginShape()
for (i of l){
vertex(i[0], i[1])
ellipse(i[0], i[1], 10, 10)
}
endShape(CLOSE)
}