| Blockland Forums > Modification Help |
| Color Translation |
| << < (4/6) > >> |
| Nexus:
--- Quote from: jes00 on May 02, 2012, 02:24:39 PM ---Thank you this works perfectly. So I'm to use this method to translate it from the GuiSwatchCtrl to the GuiSlider controls? If so which one do I use? --- End quote --- What exactly are you trying to do? I still strongly feel that you might be wasting your time with working with 0-255 numbers at all unless your specific goal requires you to convert. Otherwise you can have the slider go from 0 to 1 and keep everything 0-1 as well. guiswatchcontrol.setcolor(); uses 0-1 input NOT 0-255 |
| jes00:
--- Quote from: Nexus on May 02, 2012, 04:08:10 PM ---What exactly are you trying to do? I still strongly feel that you might be wasting your time with working with 0-255 numbers at all unless your specific goal requires you to convert. Otherwise you can have the slider go from 0 to 1 and keep everything 0-1 as well. guiswatchcontrol.setcolor(); uses 0-1 input NOT 0-255 --- End quote --- I am having sliders that change the color of a swatch control (which you are wrong, it uses 0-255) and for the slider I am now using 0.000000 to 1.000000 for. |
| elm:
--- Quote from: jes00 on May 02, 2012, 04:35:35 PM ---I am having sliders that change the color of a swatch control (which you are wrong, it uses 0-255) and for the slider I am now using 0.000000 to 1.000000 for. --- End quote --- Ok, then set the range from 0 to 255 on the slider control, set snap to false, and use mfloor() to get rid of decimals. |
| Ipquarx:
--- Quote from: Port on May 02, 2012, 12:56:09 PM ---what set ticks to 0 and snap to false --- End quote --- No. Absolutely not. That will contain decimal values, which do not work with colours. Did you think it was just a coincidence that a byte has a maximum value of 255? and that each 2 hex characters have a maximum value of 255, and that 3 sets of those make up a rgb colour? No. It's like that for a reason. A colour is 3 values from 0 and 255, each one of those values taking up ONE byte. Decimal numbers take up MANY more bytes than 1. You need to round down. --- Quote from: jes00 on May 02, 2012, 02:24:39 PM ---So I'm to use this method to translate it from the GuiSwatchCtrl to the GuiSlider controls? If so which one do I use? --- End quote --- You don't have to convert. I'm just saying that if you wanted to convert it to hex, that's what you can use. --- Quote from: Nexus on May 02, 2012, 04:08:10 PM ---guiswatchcontrol.setcolor(); uses 0-1 input NOT 0-255 --- End quote --- You're probably thinking of bitmap controls. You know jes, I can just make an example of this for you if you want, using only answers obtained from this topic. |
| Nexus:
--- Quote from: jes00 on May 02, 2012, 04:35:35 PM ---I am having sliders that change the color of a swatch control (which you are wrong, it uses 0-255) and for the slider I am now using 0.000000 to 1.000000 for. --- End quote --- --- Quote from: Nexus on April 30, 2012, 07:15:01 PM ---Also, it may or may not be useful to note (depending on what you are exactly doing) that gui controls only need to be 0-255 when you are creating the gui object. After that, you can do gui.setcolor("r g b a"); and those use floats from 0 to 1 You can just have the slider control go 0 to 1 also and you never need to convert to the 0-255 version. --- End quote --- I have written serveral extensive mods that revolve around this. I know what I am talking about. You try to use .setcolor() with 0-255 inputs and you will be a sad panda. |
| Navigation |
| Message Index |
| Next page |
| Previous page |