Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HSB Colors #3

Open
nasser opened this issue Feb 18, 2011 · 4 comments
Open

Support HSB Colors #3

nasser opened this issue Feb 18, 2011 · 4 comments
Labels

Comments

@nasser
Copy link
Owner

nasser commented Feb 18, 2011

Not sure about the syntax. This OF forum post could serve as a jumping off point.

@judy-zz
Copy link

judy-zz commented Oct 21, 2012

This could be done pretty easily by copying lib/core/color/hsv.rb. The algorithm is slightly different for converting to/from RGB, but it shouldn't be too bad. There are other examples on the net of algorithms for doing that.

@nasser
Copy link
Owner Author

nasser commented Oct 24, 2012

@judy-zz
Copy link

judy-zz commented Oct 24, 2012

In pseudocode, with horrible VB.NET examples: http://www.devx.com/tips/Tip/41581
Java examples: http://www.docjar.com/html/api/java/awt/Color.java.html

In each example, the underlying algorithm is essentially the same. Hue calculations shouldn't change at all, and brightness/saturation/value calculations are pretty basic. In most cases, it looks like you take the maximum of any of the RGB values and set that as the brightness value. And your saturation is the distance of your highest/lowest R, G, or B value away from the average of all three... I think. Again, I'd just convert an existing, working algorithm into Ruby. :-)

@nasser
Copy link
Owner Author

nasser commented Oct 24, 2012

I'll bang this together

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants