xxxxxxxxxx
45
//Author: weidi zhang
//topic: week 1 demo customized brush
let xPos,yPos,dia;
let R,G,B,A=150;
let brush1 = true;
let brush2 = true;
//setup only run once
function setup(){
createCanvas(windowWidth,windowHeight);
//background is to change the background color
background(240);
}
//draw loops forever
function draw(){
xPos = mouseX;
yPos = mouseY;
// dia = 80;
noStroke();
R = 0;
G = 0;
B = 0;
A = map(mouseX,0,width,0,255);
fill(R,G,B,A);
if(brush1){
dia = map(mouseY, 0,height,0,50);
circle(xPos,yPos,dia);
}
if(brush2){
fill(R,G,B,A);
//stroke('black');
dia = map(mouseX,0,width,0,30);
circle(xPos,yPos,dia);
}
}
function keyTyped(){
if(key ==='1'){
brush1 = !brush1;
}
if(key ==='2'){
brush2 =!brush2;
}
}