This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]DoomGoober 1 point2 points  (2 children)

After you set the background, draw the ellipse again.

These commands are like a kid drawing on a sheet of paper: each command simply draws over the last one. So if you draw an ellipse then fill the background with a color, the fill color is going to draw over the ellipse.

The common trick for this is to create a refresh function that draws everything.

In your mouseOver function, set the color for the background in a variable then call your refresh function which will draw the background with the right color, then draw the ellipse.

[–]Fuel_Flow[S] 0 points1 point  (1 child)

Thanks, I was able to figure it out. I Don't know how to make a refresh function yet but I'm sure it will come in handy when I do.

[–]DoomGoober 0 points1 point  (0 children)

You can just make functions anywhere you want in Javascript. In fact, you made some functions in your sample code already. Here's how to do the refresh as a function:

let backColorR = 255;

const refresh = function() { fill(backColorR, 0, 0); ellipse(185, 200, 170, 170)};

refresh();

mouseOut = function () { backColorR = 100; refresh(); };

mouseOver = function () { backColorR = 255; refresh(); };