Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to use HSL color table insted of RGB

Author
Message
deathAngel
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 12th Feb 2003 05:00
Hi, is there any way in DarkBasic Pro to use HSL(Hue,SatLum) color table, insted of RGB(Red,Green,Blue) to color an object ?
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 12th Feb 2003 11:52
There is a way to convert between them (I think) - which is what you'll have to do...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 12th Feb 2003 11:59
I'll see if I can get a plug-in done for it later.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 12th Feb 2003 13:05


Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 12th Feb 2003 22:58
You beat me to it!

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
deathAngel
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 12th Feb 2003 23:20
MrTAToad Please let me know when tou will get plug-in for it.

MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 12th Feb 2003 23:22
You still want a plug-in after Raven posted some code ? If so, I'll get one done.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 12th Feb 2003 23:26
i only beat ya cause i'd made that like 20mins before the request - hehee

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 12th Feb 2003 23:32
ahh...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
deathAngel
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 16th Feb 2003 09:41
Guys the code you gave me converts RGB to YBR, but i need to convert RGB to HSL(Hue,Sat,Lum). for example in "Microsoft Paint"(WinXP, not sure about else) has 2 diferent color tables: 1st is RGB, 2nd is HSL. you can sea it when you go to "Edit Color" -> "Define Custum Color" ??

MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 16th Feb 2003 09:48
I'll see if I can get my routine up and running soon then.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 16th Feb 2003 15:43
did you even read my code?
YBR isn't a real colour format, its just what i called it - its still the same as Sat Hue Lum ... or rather its
Lumination Saturation Hue that is the exact order it is saving within (^_^)

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 16th Feb 2003 15:44
remeber if all you want is to define this colour in hex format, then just use the HEX$() command and such

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
UberTuba
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Brittania
Posted: 16th Feb 2003 21:45
why do wannt hsl anyway? rgb is sooo much easier to use, and
uses the same amount of data.

Life is a terminal disease.
You never survive it.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 16th Feb 2003 21:51
Probably something to do with photo/image editing - that area tends to use HSL.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
deathAngel
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 16th Feb 2003 22:12
using HSL is much easier to make color morphs. or just darken some color for example if I want an object to change color from bright blue to dark-gray blue, I just need to lower the the Lumination value, while in RGB I need to work white all 3 of the colors, plus each of them need to be changed individually and in different timing in order to get smother color change.

Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 16th Feb 2003 22:14
Y = Lumination
Cr = Saturation
Cb = Contrast/Hue

as i said it works with the Internet style hex system, i have another one which uses the 5-5-5-1 system with the final bit being an alpha channel ... a 64 partition channel isn't exactly great depth but good enough

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
deathAngel
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 16th Feb 2003 23:24
Raven, Thanx for you're replays but I'm just a beginner and having trouble to understand this code could you give an example with this code, one that will input HSL color and output 3 values of RGB.

Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 17th Feb 2003 02:02
the buttom function is just for that really...
in my own .h file for this the colour types are constants

so
#constant ClrRed 1
#constant ClrGreen 2
#constant ClrBlue 3

as long as you constant what you use, then you can have any sceme you like for this ...

then all you do is take your HSL colour which should be a word value 0-65535

i'd make a simple buffer function to store the values like this



you'll see that now you have Red, Green & Blue from White

if you want to just edit minor things about the format, remember that you must bitshift right (>> and go from the highest to lowest stopping at the point you wish to use, using that as the highest

this might seem confusing becuase this is because natively your graphcis cards don't support this form of colour spacing - so everything has to be edited to accustom for it.

basically the main sums above are what are needed to calculate these parts ... as long as you stick to these you'll be oki



lol forgot to unbitshift the value before use

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
deathAngel
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location:
Posted: 19th Feb 2003 20:34
Raven, thanx for the code but I still having trouble understanding few things(may be I’m stupid ,lol). How is the HSL color should be a ward value, doesn't it should be
3 different values and each of them a byte.(H: 0-255, S:0-255...)?

Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 20th Feb 2003 00:25
well basically because HSL colour ranges are different to the RGB - there isn't the same precision based on the colour ranges.

So really your working more to 128,128,128 for each but how the calculations are setup you can use HSL just like RGB with single byte values per calculation ... but for it to be in a useable form by other things you need to convert to 16bit 5-6-5 which is what the calculations do however for some reason i just combine it as a 24bit value there
and i can't remember why lol that might be the confusing part

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?

Login to post a reply

Server time is: 2025-05-18 13:11:24
Your offset time is: 2025-05-18 13:11:24