xxxxxxxxxx
//p5.js shader basic structure ref from https://www.openprocessing.org/sketch/920144
let theShader;
function preload(){
theShader = new p5.Shader(this.renderer,vert,frag)
}
function setup() {
createCanvas(1112, 834, WEBGL);
noStroke()
background(80);//元の数字100
mouseX = width/2;
mouseY = height/2;
}
function draw() {
shader(theShader)
theShader.setUniform('u_resolution',[width/800,height/600])
theShader.setUniform('u_time',millis()/1000)
theShader.setUniform('u_mouse',[mouseX/width,mouseY/height])
rect(0,0,width,height)
// ellipse(mouseX, mouseY, 20, 20);
}
// save jpg
let lapse = 0; // mouse timer
function mousePressed(){
if (millis() - lapse > 400){
save("img_" + month() + '-' + day() + '_' + hour() + '-' + minute() + '-' + second() + ".jpg");
lapse = millis();
}
}