(Solved) : 1 Painter 5 Points Enhance Painter Program Developed Previous Homework New Features Allow Q26895137 . . .
1. Painter (5 points) Enhance the painter program you developedin the previous homework.
The new features should allow a user to use the keyboard toselect other brush shapes (i.e., 1 = circle, 2 = oval, 3 =oval);
increase/decrease the size of the brush by pressing the up /down arrow key;
press the ‘c’ key to clear the canvas; press the ‘e’ key toswitch to the “eraser” mode, where the paint color is thebackground color.
Press the ‘e’ key again to exit the eraser mode. see the”system status” in the upper right corner (i.e., is the user in theeraser mode or not? is the brush is painting or not).
Everything works in my code except the erasefunction.
Current Code:
function setup()
{
createCanvas(700 , 700);
}
// a boolean flag to indicate whether it is in the drawing
// mode or not
var isDrawing = false;
var value;
var symbol = {}
symbol.r = 5
symbol.rx = 5
symbol.ry = 5
symbol.dr = 1
var US = ‘ ‘;
var erase = false;
function drawMyName()
{
stroke(color(0, 255, 0));
fill(color(0, 255, 0));
textSize(32);
text(‘Student’, 20, 30); // Modify Me
}
function drawUserStatus()
{
stroke(color(0, 255, 255));
fill(color(255, 255, 255));
textSize(32);
text(US, 250, 30); // Modify Me
}
// draw the mouse cursor location
function drawSymbolAt(x, y)
{
push();
translate(x, y);
drawSymbol();
pop();
}
function drawSymbol()
{
noFill();
stroke(symbol.color);
ellipse(0, 0, symbol.rx, symbol.ry);
}
function updateSymbol()
{
if(erase === false)
{
symbol.color = color(random(0,255), random(0,255),random(0,255)); // Modify Me
}
}
function updateSymbolErase()
{
if(erase === true)
{
fill(255,255,255);
symbol.r = 50;
symbol.color = color(255,255,255); // Modify Me
}
}
function draw()
{
drawMyName();
drawUserStatus();
}
function keyPressed()
{
if (keyCode === UP_ARROW)
{
fill(255,255,255)
{
rect(300,0,300,50);
}
value = 255;
fill(0,0,0)
{
text(‘Up Arrow Pressed’, 300, 30);
}
symbol.rx = symbol.rx+10;
symbol.ry = symbol.ry+10;
}
else if (keyCode === DOWN_ARROW)
{
fill(255,255,255)
{
rect(300,0,300,50);
}
value = 0;
fill(0,0,0)
{
text(‘Down Arrow Pressed’,300,30);
}
symbol.rx = symbol.rx-10;
symbol.ry = symbol.ry-10;
}
else if (keyCode === 49)
{
fill(255,255,255)
{
rect(300,0,300,50);
}
value = 0;
fill(0,0,0)
{
text(‘Circle’,300,30);
}
symbol.rx= symbol.ry;
}
else if (keyCode === 50)
{
fill(255,255,255)
{
rect(300,0,300,50);
}
value = 0;
fill(0,0,0)
{
text(‘Oval’,300,30);
}
symbol.rx = symbol.rx+10;
}
else if (keyCode === 51)
{
fill(255,255,255)
{
rect(300,0,300,50);
}
value = 0;
fill(0,0,0)
{
text(‘Oval2’,300,30);
}
symbol.ry = symbol.ry+10;
}
else if (keyCode === 69)
{
fill(255,255,255)
{
rect(300,0,300,50);
}
value = 0;
fill(0,0,0)
{
text(‘Eraser Mode’,300,30);
eraser = true;
}
}
else if(keyCode === 67)
{
clear();
}
}
function mousePressed()
{
if (mousePressed() === True)
{
isDrawing = false;
}
}
// When the user clicks the mouse
function mouseMoved()
{
if (true)
{
if(erase === false)
{
updateSymbol();
drawSymbolAt(mouseX, mouseY);
}
else if(erase === true)
{
updateSymbolErase();
drawSymbolAt(mouseX, mouseY);
}
}
}
Expert Answer
Answer to 1 Painter 5 Points Enhance Painter Program Developed Previous Homework New Features Allow Q26895137 . . .
OR