Color Conversion - RGB to HSV and back... (almost)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Color Conversion - RGB to HSV and back... (almost)

Mike Kerner via use-livecode
Hi Mike,

Many thanks for posting a link to your
compilation stack: Master Library.

How many new LiveCode users are aware of this
wonderful resource? Thanks again for posting this.

Sorry for replying so late, but recently I am not feeling well.
Food intoxication is my educated guess... :(
Because of this, I have been posting only to the forums,
where I could edit or delete my own messages that
do not say what I meant. :)

Your HSV and RGB conversion functions works great
with only a few changes:

In Function HSVtoRGB this line:

put var_2  var_R
should be
put var_2 into var_R

and

put abs(trunc(var_R * 255)) into R  //RGB results from 0 to 255
put abs(trunc(var_G * 255)) into G
put abs(trunc(var_B * 255)) into B

works better if we replace trunc() for round().

After this small change, HSV is converted
back to RGB with 100% precision. :D

By the way, I posted a stack in the forums
that converts RGB colors of an image to
HSV colors. After this conversion, JPEG
compression artifacts become much more
evident and some strange patches of color
appears in the most unexpected places. :o

You could download the stack from this forum thread:
http://forums.livecode.com/viewtopic.php?f=10&t=29172

Now, I am looking for some script that allows
users to replace all 6 HSV color and their 7 gradients
(red to orange, orange to yellow, yellow to green
green to cyan, cyan to blue, blue to magenta,
magenta to red ) with colors of their own selection.

Have a nice weekend.
Keep up your Great Work!

Al
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode