This is a snippet from my main code. I have two separate ellipses. I only want the central ellipse to have a shadowing effect. How do I limit the shadowing effect specifically to the central ellipse, and not to the smaller ellipse in the lower left?
function setup() {
createCanvas(400, 400);
background(255);
}
function draw() {
// lower left ellipse
noStroke();
fill(255,50,0);
ellipse(50, 375, 25, 25);
//shadow effect
drawingContext.shadowOffsetX = -2;
drawingContext.shadowOffsetY = 3;
drawingContext.shadowBlur = 1;
drawingContext.shadowColor = 'black';
// central ellipse (main)
let c = color(130, 130, 0); //COLOR = ATOMIC MASS
fill(c);
noStroke();
ellipse(200, 200, 150, 150);
}
The following, which is a modified version of your code, may help you observe what happened:
function setup() {
createCanvas(200, 200);
background(255);
frameRate(0.5);
noStroke();
textSize(20);
}
function draw() {
background(255);
text("Frame " + frameCount, width / 2, height - 25);
fill(255,50,0);
// smaller ellipse in the lower left
ellipse(50, height - 25, 25, 25);
// invoke shadowing
drawingContext.shadowOffsetX = -8;
drawingContext.shadowOffsetY = 8;
drawingContext.shadowBlur = 1;
drawingContext.shadowColor = 'blue';
let c = color(130, 130, 0); //COLOR = ATOMIC MASS
fill(c);
// central ellipse
ellipse(width / 2, height / 2, width / 3, height / 3);
}
Below are renderings of the sketch during the first two frames:
During frame 1, the smaller ellipse in the lower left and the text were drawn before shadowing was in effect. The central ellipse was drawn after shadowing had been activated.
Since you did not specify otherwise, shadowing was still in effect at the start of frame 2, and throughout the duration of every frame thereafter.