jordanstephens / paleta Goto Github PK
View Code? Open in Web Editor NEWA gem for working with color palettes
Home Page: http://rubygems.org/gems/paleta
License: MIT License
A gem for working with color palettes
Home Page: http://rubygems.org/gems/paleta
License: MIT License
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!
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]
this method always return false on rails 4.2 ruby 2.2.1
just test with other gems
Would you like to transfer it?
Share the maintenance?
from gems/paleta-0.2.2/lib/paleta/palette.rb:158:in `similarity'
Receiving this error while calling the similarity method between two palettes.
Don't know how to work around this, any help would be greatly appreciated.
You can reproduce this with the following code:
color = Paleta::Color.new(:hex, "100a3e")
p = Paleta::Palette.generate(:type => :shades, :from => :color, :size => 5, color: color)
This happens because the lightness value for one of the colors is set at -5.882352941176471
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;
}
Hi,
Please consider removing the warning if I am not using Palette.generate
. It is excessive and gets in a way of console operations.
Thanks.
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:
Paleta::Palette
by removing the conditional dependency. (If users want the extra functionality, they will need to include the additional gem).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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.