Coder Social home page Coder Social logo

paleta's Issues

Support three character hex codes

Some of the hex codes I'm working with only have three characters (#ccc). It'd be great if Paleta::Color.new(:hex, color) could support this.

Thanks!

Similarity doesn't work properly

color = Paleta::Color.new(:hex, '000202')
color2 = Paleta::Color.new(:hex, '000102')
color.similarity(color2)
#=> 0.002264118702704415

And I think these colors are very similar :)
000202
screen shot 2015-12-16 at 18 49 10
000102
screen shot 2015-12-16 at 18 48 33
I don't understand or is this issue?
btw: thank you for very good gem

RGB colors does not seem right

Given a color #ff7fec it has actual RGB values: R:236, G:255, B:127 (http://www.colorhexa.com/ecff7f)
However:

Paleta::Color.new(:hex, 'ff7fec')

produces this object:

#<Paleta::Color:0x007fdfe9bf8058 @blue=236, @green=127, @hex="FF7FEC", @hue=308.90625, @lightness=74.90196078, @red=255, @saturation=100.0>

which has wrong red, green, blue values: ... @blue=236, @green=127... @red=255
and it's returned wrong when to_array is used:

[25] pry(main)> Paleta::Color.new(:hex, '#ff7fec').to_array
=> [255, 127, 236]

rmagick_available?

this method always return false on rails 4.2 ruby 2.2.1
just test with other gems

CMYK value

It will be nice to get CMYK as well.

Check this piece of code that converts from RGB to CMYK:

function (RGB){
        var result = {c: 0, m: 0, y: 0, k: 0};

        r = RGB.r / 255;
        g = RGB.g / 255;
        b = RGB.b / 255;

        result.k = Math.min( 1 - r, 1 - g, 1 - b );
        result.c = ( 1 - r - result.k ) / ( 1 - result.k );
        result.m = ( 1 - g - result.k ) / ( 1 - result.k );
        result.y = ( 1 - b - result.k ) / ( 1 - result.k );

        result.c = Math.round( result.c * 100 );
        result.m = Math.round( result.m * 100 );
        result.y = Math.round( result.y * 100 );
        result.k = Math.round( result.k * 100 );

        return result;
    }

Handle optional RMagick dependency more gracefully

Right now, Paleta has the functionality to generate a palette from an input image. This is handled in a method called Paleta::Palette.generate_from_image. Unfortunately, this method requires RMagick, which in turn requires ImageMagick, which is a rather large and often unwieldy dependency.

When writing this code originally, I wanted to try very hard to avoid requiring all users of Paleta to have ImageMagick installed when only one method in the library actually depended on it. In an attempt to accomplish this, I hacked together the situation you see at lib/paleta/palette.rb#L4-L29. Basically, we don't require RMagick at bundle time, but we do require it when we try to include a module of "MagickDependent" into Paleta::Palette at runtime. If RMagick is not successfully loaded, we print a message to the console to try to bring light to the situation.

I've been wanting to improve this for a long time, but after looking into #9, I wanted to open a new issue here to think about our options for moving forward.

I think the option that I would like to pursue at this point is to create a sort of "sister gem" to paleta, which will depend on RMagick and which will contain any "MagickDependent" methods. This gem will monkey-patch include these methods into Paleta::Palette at runtime. We will then replace the current "MagickDependent" methods with stubs which won't do anything other than print a line to the console to explain that they depend on this "sister gem" (these methods would be overwritten with the monkey-patch include if the sister gem is loaded in the bundle).

This would accomplish a number of things:

  • Offload conditional dependency management to users, and reduce complexity in Paleta::Palette by removing the conditional dependency. (If users want the extra functionality, they will need to include the additional gem).
  • Print warning messages when "MagickDependent" methods are called, rather than at module load-time.

In addition to this, though somewhat tangential, I'm going to look into replacing RMagick with MiniMagick.

If I don't hear anything on this in a while, I'll start to implement this vision when I have time.

cc @nadavshatz

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.