-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ellipse rotation to work correctly (#126)
* Fix ellipse rotation to work correctly Previously, we only rotated the center of the ellipse, similar to the circle. This commit adds a rotation field to the ellipse shape type which stores the rotation of the ellipse in radians. And we use Cairo's rotate function when rendering the ellipse. Fixes #116 along with #121. * Add example with ellipse rotation
- Loading branch information
Showing
8 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters