-
Hex Colour From Colour Selector Object
Hi All,
I'm making a HTML editor but can't figure out how to get the colour from the Colour Selector object in to a Hex colour. The object doesn't seem to support giving you the RRGGBB values to use Hex$ in MMF2?
Any help would be greatly appreciated!
Thanks,
Steve
-
Re: Hex Colour From Colour Selector Object
Hex$(Red + (Green * 256) + ( Blue * 65536))
-
Re: Hex Colour From Colour Selector Object
How do I grab the reds, greens and blues?
-
Re: Hex Colour From Colour Selector Object
I thought that the number the selector returned would already be Red + (Green * 256) + ( Blue * 65536)
-
Re: Hex Colour From Colour Selector Object
If I get the colour from the object for pure red for instance all I get is 255. How do I know what the Green and Blue should be? Pure green gives you 65280 but again how do I know that the red and blue should be zero?
-
Re: Hex Colour From Colour Selector Object
GetRed(), GetGreen() and GetBlue().
-
Re: Hex Colour From Colour Selector Object
Thanks guys i'm getting there!
If I select pure red and convert that using Hex$(Red + (Green * 256) + ( Blue * 65536)) all I get back is FF?
Sorry for being such a pain!
Steve
-
Re: Hex Colour From Colour Selector Object
Hex$(colour) (no need for the red/green/blue functions) should get back the hex without 0s at the beginning. You need to use: left$("000000",6-len("hex"))+"hex" to add the right number of 0s to the beginning.
-
Re: Hex Colour From Colour Selector Object
That doesn't work though. MMF goes like [Blue * 65536 + Green * 256 + Red].
In other words, it would output the colours in the order Blue, Green, Red. On a website, you write them in the order Red, Green, Blue, the calculation will have to be [Red * 65536 + Green * 256 + Blue].
-
Re: Hex Colour From Colour Selector Object
Well then I guess you do need to do:
Hex$(GetRed(colour)*65536+GetGreen(colour)*256+Get Blue(colour))
And then:
left$("000000",6-len("hex"))+"hex"
to add the 0s to the beginning.
-
Re: Hex Colour From Colour Selector Object
Thank you very much everyone, it worked a treat :D
-
Re: Hex Colour From Colour Selector Object
Can't you use GetRGB() instead of Blue * 65536 + Green * 256 + Red?
-
Re: Hex Colour From Colour Selector Object
If you read the rest of the thread, you'd have noticed that MMF uses Blue * 65536 + Green * 256 + Red, and for Hex RGB you need Red * 65536 + Green * 256 + Blue.
-
Re: Hex Colour From Colour Selector Object
Or you can just do that :
Hex$(Red)+Hex$(Green)+Hex$(Blue)
:D
-
Re: Hex Colour From Colour Selector Object
That wouldn't put 0s in. (15,15,15) would be FFF not 0F0F0F.
-
Re: Hex Colour From Colour Selector Object
-
Re: Hex Colour From Colour Selector Object
You could probably use GetRGB(GetBlue(colour),GetGreen(colour),GetRed(col our))
To swap the colours over instead of the formula though.
-
Re: Hex Colour From Colour Selector Object
To easy fill the gaps with 0s, you can use "Sphax Formatted object". ;)
-
Re: Hex Colour From Colour Selector Object
Maybe someone could post an example of this? So many methods have been discussed its getting confusing which one is the actual working one.
-
Re: Hex Colour From Colour Selector Object
-
Re: Hex Colour From Colour Selector Object
-
Re: Hex Colour From Colour Selector Object
This example doesn't seem to work with colours like 'Bright Green'?
-
Re: Hex Colour From Colour Selector Object
If you add the colour generated in to a html script it does actually come out as bright green. Could only replicate this with bright blue as well. Might be worth adding 2 more lines like the black one.
Steve
EDIT: reuploaded .mfa with changes mentioned above.