diff --git a/examples/dune b/examples/dune index c9927ac..535d5cc 100644 --- a/examples/dune +++ b/examples/dune @@ -48,6 +48,11 @@ (modules rotate) (libraries joy)) +(executable + (name rotate_ellipse) + (modules rotate_ellipse) + (libraries joy)) + (executable (name line) (modules line) @@ -127,4 +132,3 @@ (name smile) (modules smile) (libraries joy)) - \ No newline at end of file diff --git a/examples/rotate_ellipse.ml b/examples/rotate_ellipse.ml new file mode 100644 index 0000000..57b7eb4 --- /dev/null +++ b/examples/rotate_ellipse.ml @@ -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" ()