Comments (7)
Hi @bourb
Can you please post a code snippet of what you're trying to do so I can reproduce it?
from paleta.
Hi @nadavshatz,
I have an array of hashes which includes dominant colors for both images to compare (from a MiniMagick custom method):
img1 = [{:r=>96, :g=>82, :b=>57}, {:r=>152, :g=>113, :b=>76}, {:r=>196, :g=>146, :b=>103}, {:r=>208, :g=>178, :b=>144}]
img2 = [{:r=>94, :g=>79, :b=>59}, {:r=>151, :g=>109, :b=>79}, {:r=>200, :g=>150, :b=>106}, {:r=>232, :g=>180, :b=>140}]
I create an empty palette for each:
palette = Paleta::Palette.new
palette2 = Paleta::Palette.new
Then I add the colors from the arrays:
img1.each{ |c| palette << Paleta::Color.new(:rgb,c[:r],c[:g],c[:b]) }
img2.each{ |c| palette2 << Paleta::Color.new(:rgb,c[:r],c[:g],c[:b]) }
It looks like I get a correct Palette object in return:
> palette
=> #<Paleta::Palette:0x007febcd8215e8 @colors=[#<Paleta::Color:0x007febcd7dc2b8 @red=96, @hue=38.461538461538474, @saturation=25.49019607843137, @lightness=30.0, @hex="605239", @green=82, @blue=57>, #<Paleta::Color:0x007febcd7d6d68 @red=152, @hue=29.210526315789473, @saturation=33.333333333333336, @lightness=44.705882352941174, @hex="98714C", @green=113, @blue=76>, #<Paleta::Color:0x007febcd7d4e78 @red=196, @hue=27.741935483870957, @saturation=44.07582938388626, @lightness=58.62745098039216, @hex="C49267", @green=146, @blue=103>, #<Paleta::Color:0x007febcd7cec58 @red=208, @hue=31.874999999999993, @saturation=40.50632911392405, @lightness=69.01960784313725, @hex="D0B290", @green=178, @blue=144>]>
Calling similarity method like:
> palette.similarity(palette2)
NoMethodError: private method `fit' called for #<Paleta::Palette:0x007febcd8215e8>
Thanks a lot for your help.
from paleta.
We have a spec for Palette#similarity
, I'm surprised this wasn't caught there. I'll need to look into that further at another time. As a quick fix, I don't see any particular reason for Palette#fit
to be a private method; we can expose it and make it public.
@nadavshatz what do you think?
from paleta.
The spec for multiple regression, previous to the similarity one, apparently bypasses encapsulation using:
Paleta::Palette.send(:public, :fit)
It's what I'm doing by now, since I'm just testing around.
from paleta.
@jordanstephens I tend to agree - will have to dig deeper tho, haven't had the chance yet.
from paleta.
@bourb aha, that's what's going on. The state from that Paleta::Palette.send(:public, :fit)
is being carried over into other specs, and it looks like the similarity spec is always getting run after this.
I'm going to go ahead and expose Palette#fit
, and clear up that issue in the spec.
from paleta.
Thanks everyone. I'll cut a new version shortly.
from paleta.
Related Issues (10)
- Is this gem maintained? HOT 4
- generating a palette sometimes creates invalid negative numbers for lightness HOT 3
- CMYK value HOT 3
- Support three character hex codes HOT 3
- You must install RMagick to use Palette.generate(:from => :image, ...) HOT 2
- Handle optional RMagick dependency more gracefully HOT 3
- rmagick_available? HOT 1
- Similarity doesn't work properly HOT 1
- RGB colors does not seem right HOT 2
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 paleta.