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

[CSG]: consistent abstractions for primitives and colors #291

Open
martin-henz opened this issue Mar 14, 2024 · 5 comments
Open

[CSG]: consistent abstractions for primitives and colors #291

martin-henz opened this issue Mar 14, 2024 · 5 comments
Labels
Enhancement [Category] New feature request good project proposal Tentative suggestion inviting discussion

Comments

@martin-henz
Copy link
Member

The situation in csg and rune is quite similar. We have primitive shapes (including an empty special case) and a way to color things. The two libraries go different routes in this.

csg provides the colors as constants and the primitive shapes as functions that are applied to colors, and rune provides the primitive shapes as constants and the colors as functions that are applied to shapes.

I feel that consistency between the two is more important than which way we go. I would like to replace some rune missions/quests with csg missions/quests, so consistency across these two modules is particularly important.

@martin-henz martin-henz added Enhancement [Category] New feature request proposal Tentative suggestion inviting discussion labels Mar 14, 2024
@Cloud7050
Copy link
Contributor

Cloud7050 commented Mar 14, 2024

It's exciting to hear that CSG may see use in lessons. The way CSG handles colours has gone through a few changes, but it would definitely be feasible to make CSG match rune in terms of usage. That would probably also reduce the amount of work needed to update existing learning materials for rune. After which it would make even more sense to rename CSG's empty_shape to also be blank.

Just leaving a note here that the CSG module summary & sample snippets would also need updating to the new usage.

Another note, we could bring back silver as the default colour.

See also previous PR comment.

@martin-henz
Copy link
Member Author

There may actually be good reasons for the difference between rune and csg: The design of csg does not support making a new shape that is derived from an existing shape but has a different color. The design of rune explicitly supports this: red(whatever_rune) returns a rune that is entirely red, regardless of the colors in whatever_rune.

So in order to provide a consistent handling of colors, we would need to limit the functionality of rune. Any comments whether we should do that?

@Cloud7050
Copy link
Contributor

Iirc, CSG used to have such functionality in an earlier version. That is, taking in a shape as well as a colour, and returning a new shape entirely in that colour. It should not be too hard to bring back as a feature using JSCAD's colorize(). Perhaps by (re)adding a function to CSG called color(), alongside the mentioned change in syntax to have its default colours be functions and its primitives be values. That would make CSG match rune, without having to limit rune's functionality.

@martin-henz
Copy link
Member Author

@Cloud7050 raises the prospect of a color() function for CSG. With that, we could make CSG consistent with runes. How much work would that be?

@Cloud7050
Copy link
Contributor

Barring unforeseen challenges, I'm thinking some hours to update the existing colours/primitives, add the colour function (probably a few lines), bring back the default colour, and update documentation. This is assuming the JSCAD functions and the current design of CSG doesn't require us to do extra work to ensure colouring the passed shape returns a new shape without mutating the existing shape. There is also interactions with colouring groups to consider.

It would then take more hours to do testing and to update the existing samples. In all, maybe 1-2 days of dedicated work for a modules developer with some familiarity.

@martin-henz martin-henz changed the title [rune and csg]: consistent abstractions for primitives and colors [CSG]: consistent abstractions for primitives and colors Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement [Category] New feature request good project proposal Tentative suggestion inviting discussion
Projects
None yet
Development

No branches or pull requests

2 participants