Skip to content

Commit

Permalink
Add example with ellipse rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
punchagan committed Mar 11, 2024
1 parent eeca03a commit e7a0e84
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/dune
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
(modules rotate)
(libraries joy))

(executable
(name rotate_ellipse)
(modules rotate_ellipse)
(libraries joy))

(executable
(name line)
(modules line)
Expand Down Expand Up @@ -127,4 +132,3 @@
(name smile)
(modules smile)
(libraries joy))

15 changes: 15 additions & 0 deletions examples/rotate_ellipse.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
open Joy

let max = 32.
let rec range a b = if a > b then [] else a :: range (a +. 1.) b

let _ =
init ();
let rect = rectangle 100 50 |> translate 195 220 in
let ell = ellipse 100 50 |> translate 60 60 in
let nums = range 0. max in
let rotated =
List.map (fun i -> rotate (int_of_float (i /. max *. 360.0)) ell) nums
in
show (rect :: rotated);
write ~filename:"rotate_ellipse.png" ()

0 comments on commit e7a0e84

Please sign in to comment.