Move your pointer to change the offset.

0:01 / 0:30
Playback speed

Drop shadow

Bring the shadow close to the feet, then pull it away. Which version looks higher off the surface?

Interactive demo#Shadows#Shadow

A dark copy of a shape, nudged sideways and drawn behind it.

It makes things look like they float just above the surface. Common on text, interface panels and top-down sprites. The further the offset, the higher the thing appears to hover.

Code

src/demos/drop_shadow.goose
namespace drop_shadow_lesson;
import stage;
import std;
import math;

export "drop-shadow" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
    artwork("studio");
    let dx = floor((if hover { (px - 80) / 9.0 } else { 4 + cos(time) * 3 }) + 0.5);
    let dy = floor((if hover { (py - 50) / 7.0 } else { 4 + sin(time) * 2 }) + 0.5);
    rect(18 + dx, 34 + dy, 54, 32, "rgba(14,15,38,.5)");
    rect(18, 34, 54, 32, "#f5e1b5");
    artwork("coast", 20, 36, 50, 24);
    line(21, 63, 41, 63, "#93744d");
    draw_prop("compass", 62, 56, 7, 7);
    opacity(0.5);
    image(0, 94 + dx, 30 + dy, 4, "shade");
    opacity(1);
    image(0, 94, 30, 4);
}

Stage drawing helpers · All demos on GitHub

Comments

No comments yet.