AtlatestRepositorysigil-raylib
sigil-raylib / tree / examplesshapes.sgl
1
;;; Animated shapes demo — renders moving shapes and text at 60fps.3
(import (sigil core)4
(sigil math)5
(raylib core)6
(raylib window)7
(raylib input)8
(raylib graphics))10
(init-window 800 600 "Sigil Raylib — Animated Shapes")11
(set-target-fps 60)13
(let loop ()14
(unless (window-should-close?)15
(let* ((t (get-time))16
(rect-x (+ 350.0 (* 200.0 (sin t))))17
(circle-y (+ 400.0 (* 100.0 (cos (* t 1.5)))))18
(text-size (exact (floor (+ 30 (* 10 (sin (* t 2.0))))))))19
(begin-drawing)20
(clear-background RAYWHITE)22
;; Gradient bar across the top area23
(draw-rectangle-gradient-h 50 180 700 30 RED BLUE)25
;; Moving rectangle with rounded corners26
(draw-rectangle-rounded27
(make-rect rect-x 250.0 100.0 60.0) 0.3 6 BLUE)29
;; Bouncing circle30
(draw-circle-v (make-vec2 400.0 circle-y) 40.0 RED)31
(draw-circle-lines-v (make-vec2 400.0 circle-y) 42.0 MAROON)33
;; Horizontal reference line34
(draw-line-ex (make-vec2 0.0 300.0) (make-vec2 800.0 300.0) 2.0 LIGHTGRAY)36
;; Rotating triangle37
(let* ((angle (* t 1.2))38
(cx 650.0) (cy 200.0) (r 40.0)39
(v1 (make-vec2 (+ cx (* r (sin angle)))40
(+ cy (* r (cos angle)))))41
(v2 (make-vec2 (+ cx (* r (sin (+ angle 2.094))))42
(+ cy (* r (cos (+ angle 2.094))))))43
(v3 (make-vec2 (+ cx (* r (sin (+ angle 4.189))))44
(+ cy (* r (cos (+ angle 4.189)))))))45
(draw-triangle v1 v2 v3 PURPLE))47
;; Orbiting small circles48
(let orbit ((i 0))49
(when (< i 6)50
(let* ((a (+ (* t 0.8) (* i 1.047)))51
(ox (exact (floor (+ 150.0 (* 60.0 (cos a))))))52
(oy (exact (floor (+ 450.0 (* 60.0 (sin a)))))))53
(draw-circle ox oy 8.0 GOLD))54
(orbit (+ i 1))))56
;; Pulsing text57
(draw-text "Hello from Sigil!" 260 80 text-size DARKGRAY)59
;; FPS counter60
(draw-fps 10 10)62
(end-drawing))63
(loop)))65
(close-window)