-
Notifications
You must be signed in to change notification settings - Fork 14
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
Switching API to ints #83
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
26221d2
Int API
FayCarsons ddd6677
Int API
FayCarsons 46c47a1
applied some reviews
FayCarsons e8d7783
Merge branch 'main' into int_api
nikochiko 56f0d93
applying review suggestions
FayCarsons f46fbec
doc for set_line_width
FayCarsons File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
open Joy | ||
|
||
let size = 800. | ||
let interval = 16. | ||
let line_interval = 800. /. interval | ||
let rec range a b = if a > b then [] else a :: range (a +. 1.) b | ||
let inc x = x +. 1. | ||
let size = 800 | ||
let interval = 16 | ||
let line_interval = 800 / interval | ||
let rec range a b = if a > b then [] else a :: range (a + 1) b | ||
let inc x = x + 1 | ||
|
||
let _ = | ||
init ~size:(size, size) (); | ||
let half_size = size /. 2. in | ||
background (1., 1., 1., 1.); | ||
let half_size = size / 2 in | ||
background (255, 255, 255, 255); | ||
let lines = | ||
List.map | ||
(fun i -> | ||
let newx = i |> inc |> ( *. ) line_interval in | ||
let newx = i |> inc |> ( * ) line_interval in | ||
line | ||
~a:(point (newx -. half_size) (-.half_size)) | ||
(point (newx -. half_size) half_size)) | ||
(range 0. interval) | ||
~a:(point (newx - half_size) (-half_size)) | ||
(point (newx - half_size) half_size)) | ||
(range 0 interval) | ||
in | ||
set_color (0., 0., 0.); | ||
set_color (0, 0, 0); | ||
show lines; | ||
write ~filename:"line.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
open Joy | ||
|
||
let size = 100. | ||
let size = 100 | ||
|
||
let () = | ||
init (); | ||
background (1., 1., 1., 1.); | ||
background (255, 255, 255, 255); | ||
(* creating a rectangle from points *) | ||
let rect = rectangle size size in | ||
set_color (0., 0., 0.); | ||
set_color (0, 0, 0); | ||
render rect; | ||
write ~filename:"rectangle.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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we instead change pack_circles and make_concentric to give us ints?
Also, instead of shrink, can you try using transform.scale to have the same effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't use
Transform.scale
because I can't test the radii of the circles as they aren't exposed in the API. Also, that would require switching from the current representation of circles as (float * float) * float tuples.I can make
make_concentric
andpack_circles
take and return ints but that would require a lot of conversion back into floats because the math required to check if circles overlap is done with floats.I think that, in general, this sketch is illustrative of what an end-user writing a more complex sketch will look like.