Creat per Isaac Muro
Les variables pmouseX i pmouseY s'utilitzen per saber el valor de les variables mouseX, mouseY anterior.
function setup() {
createCanvas(400, 400);
// Escrivim el background aquí perquè no canvii el fons.
background(255);
}
function draw() {
// Definim l'amplada de la línea
strokeWeight(3);
// pmouse és la posició anterior que tenia el ratolí abans.
line (mouseX, mouseY, pmouseX, pmouseY);
}
let ample = 3;
function setup() {
createCanvas(400, 400);
background(255);
}
function draw() {
strokeWeight(ample);
line (mouseX, mouseY, pmouseX, pmouseY);
// Fem coses si apretem alguna tecla
if (keyIsPressed){
if(key == '+'){
ample = ample + 1;
}
if(key == '-'){
ample = ample - 1;
}
if(key == 'r'){
background(255);
}
}
}
if (keyIsPressed){
if(key == '+'){
ample = ample + 1;
}
if(key == '-'){
ample = ample - 1;
}
if(key == 'r'){
background(255);
}
}
let ample = 3;
function setup() {
createCanvas(400, 400);
background(255);
}
function draw() {
if(mouseIsPressed){
strokeWeight(ample);
line (mouseX, mouseY, pmouseX, pmouseY);
}
if (keyIsPressed){
if(key == '+'){
ample = ample + 1;
}
if(key == '-'){
ample = ample - 1;
}
if (key=='e'){
stroke(0);
fill(random(255),random(255),random(255));
ellipse(mouseX, mouseY, pmouseX, pmouseY);
}
}
}
if(mouseIsPressed){
strokeWeight(ample);
line (mouseX, mouseY, pmouseX, pmouseY);
}