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

Support for serde (de)serialization of color types #83

Closed
mitchmindtree opened this issue Mar 15, 2018 · 3 comments
Closed

Support for serde (de)serialization of color types #83

mitchmindtree opened this issue Mar 15, 2018 · 3 comments
Milestone

Comments

@mitchmindtree
Copy link
Contributor

I'm currently using palette in a downstream crate where I'd like to allow the user to serialize and deserialize custom Themes - a set of styling defaults including some color types from palette. I'm hoping to avoid writing custom implementations of the serde traits in favour of adding the necessary derives to palette itself where others may also find this useful. Perhaps this could be added as an opt-in feature similarly to cgmath, petgraph and others do?

@Ogeon
Copy link
Owner

Ogeon commented Mar 15, 2018 via email

@Ogeon Ogeon added this to the 0.4.0 milestone Apr 3, 2018
@Ogeon
Copy link
Owner

Ogeon commented Apr 22, 2018

I'm adding this in #90. It will be just straight (de)serialization without anything too fancy. The only exceptions are the alpha types that will be flattened, so a JSON serialization of RGB with transparency will be {"red":0.1,"green":0.2,"blue":0.3,"alpha":0.4}.

Let me know if any of this doesn't work with your use case and maybe we can tweak it a bit. If you need other field names or a non-struct format, I would recommend creating a custom types for those representations and convert to and from palette types.

@Ogeon
Copy link
Owner

Ogeon commented Apr 22, 2018

To clarify: it's fine to reopen or continue the conversation even after it's merged. 🙂

bors bot added a commit that referenced this issue Apr 22, 2018
90: Add serde support as an optional feature r=Ogeon a=Ogeon

This add serialization support to the color spaces, with and without transparency.

Closes #83

Co-authored-by: Erik Hedvall <erikwhedvall@gmail.com>
@bors bors bot closed this as completed in #90 Apr 22, 2018
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

No branches or pull requests

2 participants