Some P5 sketches I made.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

38 lines
838 B

param_array = [];
ratio = Math.sqrt(2);
function setup() {
// put setup code here
createCanvas(512,512)
param_array.push({
startx: width/4,
starty: height/2,
endx: width/2,
endy: height/2,
});
}
function draw() {
// put drawing code here
if (param_array.length > 0){
param = param_array.pop();
line(param.startx, param.starty, param.endx, param.endy);
xlen = (param.endx - param.startx)/ratio;
ylen = (param.endy - param.starty)/ratio;
if ( Math.max( Math.abs(xlen), Math.abs(ylen)) > 1 ){
param_array.splice(0,0,{
startx: param.endx,
starty: param.endy,
endx: param.endx-ylen,
endy: param.endy+xlen,
});
param_array.splice(0,0,{
startx: param.endx,
starty: param.endy,
endx: param.endx+ylen,
endy: param.endy-xlen,
});
}
}
else noLoop();
}