LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 08 Aug 2016 08:04 PM |
Would it be possible to 'mix' Color3 Values?
Like yellow ( rgb: 255, 255, 0 ) and green ( rgb: 0, 255, 0) would make light green. (( Yellow and Green are just an example.. )) Just asking out of curiosity. |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 08 Aug 2016 08:10 PM |
r,g,b = 234, 32, 53 r1,g1,b1 = 42, 23, 123
newcolor = Color3.new(math.min(r+r1, 255), math.min(b+b1, 255), math.min(b+b1,255)) |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 08:15 PM |
@Dev, that is not how it works.
http://www.colorcube.com/articles/math/math.htm
That may help.
Matthew: "Scripting for ROBLOX intelligence? There is no intelligence in ROBLOX." Me: "LOL" |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 08 Aug 2016 08:15 PM |
r,g,b = 255, 255, 0; r1,g1,b1 = 0, 255, 0; print(Color3.new(math.min(r+r1, 255), math.min(b+b1, 255), math.min(b+b1,255)))
> 255, 0, 0
Last I checked yellow plus green wasn't red.. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 08:17 PM |
you could try this
local r,g,b = 255,255,0 local r2,g2,b2 = 0,255,0 local newColor = Color3.new(((r+r2)/2)/255,((g+g2)/2)/255,((b+b2)/2)/255) |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 08 Aug 2016 08:17 PM |
-- Example: function mixColors(c1, c2) return Color3.new(math.min(c1.r + c2.r, 255), math.min(c1.g + c2.g, 255), math.min(c1.b + c2.b, 255)) end
mixColors(Color3.new(123,45,34), Color3.new(23,123,54)) |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 08 Aug 2016 08:21 PM |
@Lord That returns 0.5, 1, 0.
@Dev That returns 255, 255, 0. Besides, it's the same thing you just posted but in a function.
|
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 08:22 PM |
"That returns 0.5,1,0"
it's supposed to
color3 values range from 0-1
silly |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 08 Aug 2016 08:23 PM |
@Lord
forgive me father, for I have sinned. I'm an idiot :P |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 08:23 PM |
does it do what you want?
i just averaged the rgb values and then divided by 255 to get it to eb from 0-1 |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 08 Aug 2016 08:25 PM |
| It does exactly what I want, thank you. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 08:26 PM |
"Would it be possible to 'mix' Color3 Values?" Did you totally copy this post? It sounds almost identical. https://forum.roblox.com/Forum/ShowPost.aspx?PostID=95543084 Don't do what they said in that post though, there's a better way now.
|
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 08 Aug 2016 08:27 PM |
| Just a small problem, it returns 127.5 when I convert it to the Color3 value (as in 0 - 255 ), but I can fix that on my own. That's what I get for using yellow and green as examples :P Thank you for helping. |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 08 Aug 2016 08:28 PM |
Here now you can still use the 255 format. :P
function mixColors(c1, c2) local function min(a,b) return math.min(a + b/2, 255) end return Color3.fromRGB(min(c1.r, c2.r), min(c1.g, c2.g), min(c1.b, c2.b)) end
mixColors(Color3.new(255, 0, 0), Color3.new(0, 255, 0)) |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Aug 2016 08:34 PM |
@Jarod
go away noob mine's better |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 08 Aug 2016 08:37 PM |
Why lerp when you just want to mix?
Plus why take the easy way out when you can learn how it works instead of just having it done for you. xD |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 08:41 PM |
It depends on what he means by mixing. In fact, the OP explicitly stated that your code did not do what he wanted.
|
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 08 Aug 2016 08:43 PM |
| Because I left out the part that gets 50% of it so it returned the wrong colors. xD |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 08 Aug 2016 08:46 PM |
| Well you can get the exact colour between two using lerp if the alpha is 0.5 |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 08:49 PM |
That's what my code does though, except mine is simpler and (a+b)/2 will never be more than 255. If it does result in more than 255, it won't matter because the original values need to have been more than 255 anyways.
Benchmarking! Your code: 22.244 My code: 14.479
|
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 08 Aug 2016 08:51 PM |
| Yeah I didn't read the whole thread just this "Why lerp when you just want to mix?" display of vast intelligence. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 08:52 PM |
mine is clearly superior
more lines = more efficiency
!!!
silly cretins
Formerly xXTheRobotXx, add 13,349 posts |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 08 Aug 2016 08:53 PM |
Takes your potato pc to run a simple math problem 22 secs? xD
Proof Plox? |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 08:53 PM |
I would benchmark yours too, but I assumed raw Color3 values and I don't want to alter your code for that, and I also don't remember the number of iterations I did.
|
|
|
| Report Abuse |
|
|