Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Last active January 5, 2023 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdesl/a572a534fb1796955a3a2e6ca5d3ef8a to your computer and use it in GitHub Desktop.
Save mattdesl/a572a534fb1796955a3a2e6ca5d3ef8a to your computer and use it in GitHub Desktop.
example of Ryu syntax (all built-in APIs are unstable)
; a loop utility
(fn loop (n iter) (do
(var i 0)
(while (< i n) (do
(iter i)
(set i (+ 1 i))
))
))
(var BG 0xff)
(var FG 0x00)
(random/seed 5)
(canvas/fill BG)
(var count 20)
(loop count (fn (i) (do
(var y (random 0 width))
(var x (random 0 height))
(var len (random 0 (* 0.25 width)))
(var x2 (+ x len))
(var y2 (+ y len))
(canvas/line x y x2 y2 FG)
)))
; finally emit the canvas
(canvas/draw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment