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

Circle packing example #72

Merged
merged 4 commits into from
Dec 13, 2023
Merged

Conversation

FayCarsons
Copy link
Collaborator

I thought it would be nice to have an example of more complex use of this library, so I threw together a quick circle packing example. It has a couple of issues I would love some input on fixing - namely typing, accessing the point and radius of a circle, and doing destructuring of circles in function args isn't possible without the type declaration in shape.mli which brings up other issues. But that's the temporary fix I went with.

The result:
Screen Shot 2023-10-28 at 12 33 59 PM

I would have liked to fill each circle with concentric circles of changing colors using the repeat function or similar, but getting all the types to play nice was difficult and I feel like getting advice from someone more experienced with OCaml would be better than me wasting more time wrestling with type inference.

@FayCarsons
Copy link
Collaborator Author

Added concentric circles, the only glaring issue at this point (from my POV) is the typing issues and accessing circle fields.

Here's the current result:
Screen Shot 2023-10-28 at 8 15 08 PM

Copy link
Owner

@Sudha247 Sudha247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @FayCarsons! Looks fantastic. A minor comment below, otherwise good to go.

Comment on lines 13 to 19
(107, 108, 163);
(135, 188, 189);
(111, 153, 84);
(150, 155, 199);
(137, 171, 124);
(67, 68, 117);
(44, 45, 84);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it isn't too much work, it would be nice to add the color as a comment, so it's easier to use for future examples.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like add a comment above each tuple w/ the name of the color?

@FayCarsons
Copy link
Collaborator Author

I refactored this to remove the typing issues, and labeled the colors in the palette. I still think there's probably a better way to do this, currently it doesn't really use the library for anything except rendering, but I'm not super sure what the solution is.

@nikochiko nikochiko merged commit 704c2b6 into Sudha247:main Dec 13, 2023
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants