Blockland Forums > Modification Help
Color Translation
(1/6) > >>
jes00:
How do I translate colors from GuiSliderCtrl to GuiSwatchCtrl color and from GuiSwatchCtrl to the form that color sets use?
Port:
guiSwatchCtrl uses RGBA colors (red green blue alpha) in range 0 to 255. I've seen some colorsets that use that same range, however most (including default) seem to use range 0 to 1 (floating point). The conversion method is value / 255.

I'll research guiSliderCtrl in a moment.

guiSliderCtrl is not specifically for colors, you can use it for any type of value. In any case, it's as simple as setting the 'range' member field to '0 255' if you want it to use the same format that guiSwatchCtrl uses.
jes00:

--- Quote from: Port on April 30, 2012, 06:33:57 AM ---guiSwatchCtrl uses RGBA colors (red green blue alpha) in range 0 to 255. I've seen some colorsets that use that same range, however most (including default) seem to use range 0 to 1 (floating point). The conversion method is value / 255.

--- End quote ---
Thanks Port, so I just need to do %colorR = getWord(BlahBlah.color, 0) / 255; and so forth?

--- Quote from: Port on April 30, 2012, 06:33:57 AM ---guiSliderCtrl is not specifically for colors, you can use it for any type of value. In any case, it's as simple as setting the 'range' member field to '0 255' if you want it to use the same format that guiSwatchCtrl uses.

--- End quote ---
I tried that but whenever I change it to 0 255 it changes it to 0.000000 255.000000.

EDIT: Should I just change the snap to 255 (even though it just looks like one black line after that) and ignore the numbers after the point?
Port:

--- Quote from: jes00 on April 30, 2012, 06:41:37 AM ---Thanks Port, so I just need to do %colorR = getWord(BlahBlah.color, 0) / 255; and so forth?

--- End quote ---

Yes.


--- Quote from: jes00 on April 30, 2012, 06:41:37 AM ---I tried that but whenever I change it to 0 255 it changes it to 0.000000 255.000000.

EDIT: Should I just change the snap to 255 (even though it just looks like one black line after that) and ignore the numbers after the point?

--- End quote ---

range = 0 255

It doesn't matter whether the engine adds stuff like .000000 to the values.
jes00:

--- Quote from: Port on April 30, 2012, 06:55:34 AM ---Yes.

range = 0 255

It doesn't matter whether the engine adds stuff like .000000 to the values.

--- End quote ---
range = "0.200000 1.000000"
ticks = "0";
value = "0";
snap = "0";

Sometimes it skips a number or two : /
Navigation
Message Index
Next page

Go to full version