Comments (6)
Hi @Trevoke. I like this idea, but I think baked in HTML serialization is out of the scope of this gem. However, I do like the idea of supporting custom serialization similar to supporting custom palettes, so I would be comfortable with something like:
# call define_color_serializer with name and block that is instance_eval'd by the color
Chroma.define_color_serializer :to_html do
%{<span class="color-swatch" style="background-color: #{to_hex}"></span>}
end
'red'.paint.to_html #=> <span class="color-swatch" style="background-color: #ff0000"></span>
Is that output kind of what you were referring to?
from chroma.
I admit that, being a web developer, I just can't imagine any context for hex colors beyond CSS, which is why I thought it would be a wonderful addition to the gem.
I imagined something like a pre-baked, HTML+CSS, version of a palette like this one (first available on the site when I went to it): http://www.colourlovers.com/palette/3621455/fewer .
Beyond this, my suggestion is to solve for one use case first, and then make it more generic when more use cases come up.
And finally, I understand that HTML serialization might deform and denature the gem, so I do understand if you leave that out. Maybe I'll just have to build a wrapper gem :D
from chroma.
Hey, @Trevoke. Sorry for the absence. I'm still not sure that I'm sold on this. It's a neat idea, but the main issue I see with serializing to HTML/CSS is the assumptions I need to make about what that looks like versus what others might want.
What is it you hope to achieve with this functionality? Do you want to just preview the colors and custom palettes? Or do you actually want some type of HTML/CSS output that you use directly in an app?
I have some ideas for either approach.
from chroma.
The main purpose I hope to achieve is to view the colors.
from chroma.
OK, so after thinking about this, I belive I'm good with this idea. It could be helpful to visualize the colors, especially for custom palettes you can define (in addition to the default palettes).
What I envision is a rack server for this that you can run locally to play with the colors. A command line binary could work as well, but the server would have the benefit of allowing you to type in the base color you want to try out instead of constantly rerunning a binary.
Does that sound like something you're looking for?
from chroma.
That sounds pretty awesome, yes!
from chroma.
Related Issues (20)
- Support directly outputting palette to array of serialized strings HOT 1
- Color initialization from Hsl instance screws up @rgb value HOT 2
- Implement equality methods HOT 1
- Equality is still off due to floating point math HOT 1
- Color should have a paint method like String HOT 1
- RGB generation not capturing alpha for hsla and hsva strings HOT 1
- Generated palette should use the same format as the seed color HOT 1
- Color created from rgba string is serializing to hex HOT 1
- Hook up CI HOT 1
- Moar tests
- Allow option passing to defined custom palettes
- Init with hsv formant bug HOT 1
- regenerating a palette HOT 7
- Change color opacity with chroma? HOT 1
- Generated palette sort order HOT 2
- Equivalent of tinyColor's toRgb HOT 1
- Brightness - sqrt(red^2 * 0.299 + green^2 * 0.587 + blue^2 * 0.114)
- Is this gem still maintained? HOT 1
- Define custom palettes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chroma.