Skip to content

Commit

Permalink
examples: add a glow effect to spirograph.v
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Jul 5, 2024
1 parent 3ee95d1 commit 56d2ba6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/gg/spirograph.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pixel_count = 15000
const p = 3
const s = math.pi * 2 / f32(pixel_count)
const color = gg.Color{255, 255, 255, 255}
const background = gg.Color{20, 20, 64, 255}
const background = gg.Color{20, 20, 64, 5}
const colors = [
gg.Color{255, 255, 255, 255},
gg.Color{255, 0, 255, 255},
Expand All @@ -23,14 +23,18 @@ gg.start(
width: 900
height: 950
sample_count: 2
frame_fn: fn [mut k, mut scale] (ctx &gg.Context) {
frame_fn: fn [mut k, mut scale] (mut ctx gg.Context) {
wsize := gg.window_size()
ctx.begin()
ctx.draw_rect_filled(0, 0, wsize.width, wsize.height, gg.Color{10, 1, 30, 60})
t := f64(ctx.frame) / 300
d := math.sin(t)
if math.abs(d) < 0.0015 {
k++
}
if ctx.pressed_keys[int(gg.KeyCode._0)] {
ctx.frame = 475
}
if ctx.pressed_keys[int(gg.KeyCode.left)] {
k--
}
Expand Down Expand Up @@ -62,6 +66,6 @@ gg.start(
ctx.draw_text(wsize.width / 2 - 170, wsize.height - 15, 'frame: ${ctx.frame:06}, k: ${k:4}, scale: ${scale:4}, arrows to change',
color: colors[1]
)
ctx.end()
ctx.end(how: .passthru)
}
)

0 comments on commit 56d2ba6

Please sign in to comment.