200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 22 Dec 2013 09:42 AM |
I'm creating a GUI API that includes a Color Picker container, and I am wondering which of Hue & Saturation I can mix to get the color of the value bar correctly? (For an example, look at the color picker in studio; I'm trying to make it like that, and all I am missing is the value bar's color)
I've been fiddling with it for a couple of hours now, and yes, I have searched around for source code of other color pickers, but all I can find for HSV are ones that use a hue bar, and not a value bar.
(Reposted from SH... I don't know why I ever thought anyone there would know) |
|
|
| Report Abuse |
|
|
oysi92
|
  |
| Joined: 20 Nov 2008 |
| Total Posts: 361 |
|
|
| 22 Dec 2013 10:38 AM |
I'm not sure what you're asking. You can't mix hue and saturation to get value? They are all independent properties, and you need all three to make up the colors. Also, HSV is not at all the same as HSL. Anyway, this is how HSV works:
H = 000 --> (255, 000, 000) H = 060 --> (255, 255, 000) H = 120 --> (000, 255, 000) H = 180 --> (000, 255, 255) H = 240 --> (000, 000, 255) H = 300 --> (255, 000, 255) H = 360 --> (255, 000, 000)
Interpolate between those colors, depending on H.
Now interpolate to (255, 255, 255) with S.
Now interpolate to (0, 0, 0) with V. |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 22 Dec 2013 11:01 AM |
| Sorry, I guess I wasnt clear. I have a function that gets hue, sat, and value, I just am just trying to figure out what to use for the color of the value bar. The value bar should change based on the current HSL everytime its changed. Like how it does in studios color picker. |
|
|
| Report Abuse |
|
|
oysi92
|
  |
| Joined: 20 Nov 2008 |
| Total Posts: 361 |
|
|
| 22 Dec 2013 11:06 AM |
That's simply what the color for that value (along with the hue and sat which you already have) would be. For example:
for i = 1, 100 do The button that sets value to i, should have the color hsv(h, s, i) end |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 22 Dec 2013 11:23 AM |
@oysi I think you are still not understanding what I'm asking. Either that, or I just am horribly misunderstanding you.
The value bar's color should be independent of the actual value, else it would be constantly changing while you are sliding it up/down, and that would be very confusing, and give the wrong colors. It needs to somehow use hue and sat to determine it's color. |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 22 Dec 2013 01:21 PM |
So it seems that the problem is with my HS map, it seems to be sort of off-set for some reason. I hate asking for help here, but most people on SH can barely script, so... help? pastebin/X3nFi6h6
Search "ColorPicker" (it's the last function) |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
| |
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
| |
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
| |
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 22 Dec 2013 08:45 PM |
| Is noone replying because of the API? I can seperate it from that, I guess. Though, I dont see why, because you dont need to examine any other parts of the API other than the ColorPicker function. |
|
|
| Report Abuse |
|
|
MettaurSp
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 3179 |
|
|
| 22 Dec 2013 08:50 PM |
| I think it is because not many people have ever done something like this and understand RGB vs HSV. That is why I am not replying (until now) at least, doesn't mean I haven't tried to figure it out to help though. |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 22 Dec 2013 11:16 PM |
@mett Yeah, I hadn't either until a couple of days ago when I started work on this API. I knew pretty much nothing about it, and still don't know too much (which is why I'm needing help). What I DO know, though, is from research on HSV (When I said HSV/HSL I meant HSV/HSB... that shows just how much I know :c), and a couple of ColorPicker sources I found on github, but both of them use a hue bar. (I've found it's IMPOSSIBLE to find sources of a colorpicker using a value bar) |
|
|
| Report Abuse |
|
|
MettaurSp
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 3179 |
|
|
| 22 Dec 2013 11:21 PM |
| Value just seems like darkness. Try getting how close a color is to 0,0,0 in RGB for V. |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 22 Dec 2013 11:32 PM |
@mett I'll try that, but that's not even the only problem anymore (I wish it was), I've found that for some reason the HS map (the actual color picking part) is off-set by about 60, if you use the ColorPicker function along with the callback function to update the background color of a GUI object with the R,G,B generated, then you'll see it's not quite right. I have no clue why. HS is from a 0-1 value like it should be by dividing the relative position to the HS map by the size of it like it should be (and the value bar's by it's size), so I don't know how it's possible for it to be off-set like that. :/ |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 22 Dec 2013 11:34 PM |
| I don't even know exactly what's wrong at this point. It's frustrating. |
|
|
| Report Abuse |
|
|
MettaurSp
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 3179 |
|
|
| 22 Dec 2013 11:55 PM |
| I guess I can give a crack at this too when I am done playing a game. Ima open repl.it in another tab to give it a shot. |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 23 Dec 2013 09:15 AM |
So I'm guessing you had no luck? o; Maybe I should just move on for now. |
|
|
| Report Abuse |
|
|
MettaurSp
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 3179 |
|
|
| 23 Dec 2013 10:22 AM |
| No, I just had to get off for the night. Ima start again right now. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 08:40 AM |
| Not quite sure what you are looking for here but I think if you mean the "base" colour of the value bar then it should just be the hue and saturation with maximum value and you can add a black gradient overlay? |
|
|
| Report Abuse |
|
|