Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a smiling emoji example using different shapes #124

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ()

Loading