GithubHelp home page GithubHelp logo

chroma's People

Contributors

jfairbank avatar matildasmeds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chroma's Issues

Equivalent of tinyColor's toRgb

I know chroma has a to_rgb method, but it's actually a port of tinyColor's toRgbString.

I am interested in adding a method to this lib which will output a hash eg., {r: 255, g: 255, b: 255}.

This can be very useful to do some arithmetic on the r, g and b values individually.

Is this something that makes sense to be added to this lib?

Define custom palettes

Support syntax for defining custom palettes.

Something like:

Chroma.define_palette(:my_palette) do
  spin 60
  spin 180
  brighten 10
end

'red'.paint.palette.my_palette #=> ['#ff0000', '#ffff00', '#00ffff', '#ff1919']

Generated palette sort order

I just came across this gem in an attempt to autogenerate some colors for chart.js. It's very cool and working quite well so far. Thank you for all the hard work!

The only problem I'm having is the sort order for a generated palette, specifically the first / last color in the array. It's possible that I'm missing some config option or something, but, lemme break it down for you

I'm using this code to create my monochromatic palette:

"#ff6384".paint.palette.monochromatic(size: 16, as: :hex)

Which is generating this array (I've truncated it for brevity):

["#ff6384", "#100608", "#200c11", "#301319", "#401921", "#501f29", "#602532" ... ]

Which produces this color palette in my chart:

screen shot 2018-01-25 at 1 23 41 pm

As you can see, it looks like the first color needs to go to the end or the rest of the array (except for the first one) needs to be reversed.

I even checked your examples in the README, and I'm seeing the same problem:

'red'.paint.palette.monochromatic(as: :hex)
#=> ['#ff0000', '#2a0000', '#550000', '#800000', '#aa0000', '#d40000']

That goes from red to (basically) black and then works its way back toward red.

Is there a way to specify "direction" in a palette? Like, to be able to pass in an argument to the palette to start with my seed color or end with my seed color.

Thoughts on this? Am I missing something?

regenerating a palette

If I generate a custom palette, say "user_palette", then later, I want to regenerate it, I get:

Chroma::Errors::PaletteDefinedError (Palette `user_palette' already exists):

Is there a way to support regenerating an already existing palette?

Change color opacity with chroma?

On one hand it's easy to add alpha values to Strings manually. On the other hand, Chroma supports alpha values already, so adding a way to change opacity feels natural in some sense. Having done it manually, I don't think it looks pretty, and it would be nice if the gem could do it.

If there is support for the idea, it might be helpful to sketch the interface a bit, to start in the right direction. 🎨

If opacity/transparency concepts yielded easy, naturally paired verbs, such as "darken"/"lighten", it might make sense to model after that. As I can't find such a pair, I would suggest .opacity(20) which would the opacity to a percentage. Hence it would be a bit similar to .grayscale, but with a parameter.

How does this sound? Any considerations?
I can do it, but would be nice to get go ahead before contributing. 🙏

Need tests

Here's a beginning list to add on to:

  • Chroma.paint
  • Palettes
  • Chroma.hex_from_name and Chroma.name_from_hex
  • Color modification methods (i.e. brighten, darken, etc.)

Init with hsv formant bug

For example:

"hsv(100, 75%, 50%)".paint.to_hex # got: "#408020" expected: "#3F7F1F"

In fact #3F7F1F is hsv(100, 75%, 50.2%). Rounding error.

Color mode serialize methods should return same color with different format

For example, to_rgb shouldn't return the actual ColorModes::Rgb instance. It should return a new Color with a format of :rgb (or the same instance if the format is already :rgb).

This will require the current implementations to be private helpers for assisting the string serializers (i.e. to_rgb_s).

Equality is still off due to floating point math

irb(main):003:0> 'yellow'.paint.send(:rgb)
=> #<Chroma::ColorModes::Rgb:0x007fa088e1f1d8 @r=255, @g=255, @b=0, @a=1.0>
irb(main):004:0> 'red'.paint.spin(60).send(:rgb)
=> #<Chroma::ColorModes::Rgb:0x007fa088e25330 @r=254.99999999999994, @g=255.0, @b=0, @a=1>
irb(main):005:0> 'yellow'.paint == 'red'.paint.spin(60)
=> false

Moar tests

Need to test more colors in public API. Also, need to test internal classes and some private APIs.

Is this gem still maintained?

Hi,

This is my favorite color manipulation gem, but I see its development was halted some years ago.
It it still maintained? Will you accept pull requests?

export to HTML palette

It would be nice, for those of us who are hex-impaired, to be able to see it in a browser somehow. Maybe just export to HTML string for starters?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.