-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathdraw_mask_animated.rs
More file actions
27 lines (22 loc) · 842 Bytes
/
Copy pathdraw_mask_animated.rs
File metadata and controls
27 lines (22 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use notan::{draw::*, prelude::*};
fn main() {
notan::init()
.add_config(WindowConfig::new().set_size(500, 500))
.add_config(DrawConfig)
.draw(|app: &mut App, gfx: &mut Graphics| {
let mut draw = gfx.create_draw();
draw.clear(Color::BLACK);
let elapsed = app.timer.elapsed_f32();
let pulse_progress = ((elapsed % 4.) - 2.).abs() / 2.; // 4s roundtrip pulse
let radius = 200. * (1. - pulse_progress);
let mut mask = gfx.create_draw();
mask.clear(Color::BLACK);
mask.circle(radius).position(250., 250.);
draw.mask(Some(&mask));
draw.rect((0., 0.), (500., 500.)).color(Color::GREEN);
draw.mask(None);
gfx.render(&draw);
})
.build()
.unwrap();
}