Skip to content

Commit

Permalink
Add a smiling emoji example using different shapes (Sudha247#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshn-gh authored Mar 11, 2024
1 parent 04396d7 commit 0a91567
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/dune
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,9 @@
(name fill_rect)
(modules fill_rect)
(libraries joy))

(executable
(name smile)
(modules smile)
(libraries joy))

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

let make_nose () =
let l = line (point 0 50)|> translate 0 (-25) in
let l1 = l in
let l2 = l |> rotate 90|> translate 0 (-25) in
let nose = complex [l1; l2] in
nose

let make_arc rx ry =
let r = rectangle ~c:(point 0 (ry / 2)) (2 * rx) ry in
let col = r |> with_fill white |> with_stroke white in
let e = ellipse ~c:(point 0 0) rx ry in
complex [e; col]

let () =
init ();
let a = circle 200 in
let d = circle ~c:(point 50 50) 20 in
let b = circle ~c:(point (-50) 50) 20 in
let nose = make_nose () in
let leb = make_arc 26 14 |> rotate 180 |> translate 50 70 in
let reb = make_arc 26 14 |> rotate 180 |> translate (-50) 70 in
let mouth = make_arc 80 40 |>translate 0 (-60) in
show [mouth;leb;reb;a;d;b;nose];
write ()

0 comments on commit 0a91567

Please sign in to comment.