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

Alejandro Tejada capellan2000 at gmail.com
Wed Apr 26 22:59:38 EDT 2017


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



More information about the use-livecode mailing list