Answered step by step
Verified Expert Solution
Question
1 Approved Answer
use the code ive made and add on to complete it. function setup() { createCanvas(800, 800); background(255); } function draw() { fill(255,0,0); noStroke(); square(1,0,30); //red
use the code ive made and add on to complete it.
Write a P5 sketch that works as a simple paint program... Draw a blank canvas with a color palette at the left including red, orange, yellow, green, cyan, blue, magenta, brown, white, and black boxes. Let the user click and drag the mouse on the canvas to apply paint. Let the user click on the color palette boxes to set the paint color. You will need to use mousePressed or mouselsPressed to determine whether a click is happening, and if so use mouseX and mouseY to determine whether this click should apply paint to the canvas or change the paint color. Paint lines instead of points. For full credit, ensure that the palette always remains visible even if the user tries to paint overtop it. Let the user click and drag the mouse on the canvas to apply paint. Let the user click on the color palette boxes to set the paint color. You will need to use mousePressed or mouselsPressed to determine whether a click is happening, and if so use mouseX and mouseY to determine whether this click should apply paint to the canvas or change the paint color. Paint lines instead of points. For full credit, ensure that the palette always remains visible even if the user tries to paint overtop it function setup() {
createCanvas(800, 800);
background(255);
}
function draw() {
fill(255,0,0);
noStroke();
square(1,0,30);
//red
fill(255,140,0);
noStroke();
square(1,31,30);
//orange
fill(255,255,0);
noStroke();
square(1,63,30);
//yellow
fill(0,255,0);
noStroke();
square(1,95,30);
//green
fill(0,255,255);
noStroke();
square(1,126,30);
//cyan
fill(0,0,255);
noStroke();
square(1,157,30);
//blue
fill(255,100,255);
noStroke();
square(1,188,30);
//magenta
fill(100,60,0);
noStroke();
square(1,219,30)
//brown
fill(255);
noStroke();
square(1,250,30);
//white
fill(0);
noStroke();
square(1,281,30);
//black
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started