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

Handling optional properties of shapes #19

Open
AnonMiraj opened this issue May 27, 2024 · 1 comment · Fixed by #33
Open

Handling optional properties of shapes #19

AnonMiraj opened this issue May 27, 2024 · 1 comment · Fixed by #33
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@AnonMiraj
Copy link
Owner

Currently, when properties like 'stroke_color' are omitted in shapes, the code behaves unexpectedly by using a random value. This behavior is undesirable. We need a better approach to handle optional properties like 'stroke_color.'

I have two ideas in mind:

  • Using Default Values: Instead of relying on random values, we can set default values for optional properties like 'stroke_color.' If a property is not explicitly set, it defaults to a specific value (e.g., transparent or a predefined color).

  • Using Pair Structure: We can create a pair structure for each optional property. This structure would include the property itself and a logical flag indicating whether it has been set.

While the first one is easy and straightforward, it will involve a lot of unnecessary operations and will bloat the resulting SVG.

The second one would work better, but I feel like it is not a very clean approach.

I would like your opinion on how to handle them.

@AnonMiraj AnonMiraj added enhancement New feature or request help wanted Extra attention is needed labels May 27, 2024
@johandweber
Copy link
Contributor

Without having done a lot of research, the first solution appears more straightforward.
I do not know whether "bloated" SVGs are a serious problem. If so maybe you can transfer the logic of what attributes should be added into the method..
This would on the one hand increase the amout of source code in the canvas classes, but on the other hand this logic would be hidden from a user of the library.

Maybe you should wait for other suggestions.

@AnonMiraj AnonMiraj mentioned this issue May 30, 2024
@AnonMiraj AnonMiraj linked a pull request Jun 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants