Getting the color of Liquid Fun mixed particles?

I can’t figure out how to get the color from mixed Liquid Fun particles. Is this even possible?

I wonder how to get the mixed color from the sample in Physics/LiquidFun/ColorFaucet somehow.

Any ideas how this can be done?

I need it for something like: Mix two colors and use the mixed color to color another object with it.

Thx for your help!

Daniela

Hi Daniela,

When would you do this? During a particle collision? I ask because, if you have blue and red liquids mixing, obviously that mix consists of many different particles, each one leaning slightly more toward blue or red. So, I can’t think of any way to “average” out the mixed color across a wider area. However, if you want to get color values on collision, you should experiment with the event values like this one:

http://docs.coronalabs.com/api/event/particleCollision/r.html

Of course, there’s one for “g” and “b” and “a” (alpha) as well:

http://docs.coronalabs.com/api/event/particleCollision/index.html

Hope this helps,

Brent

Thx Brent… this helps a lot!

I was searching for something which can give me the maximum mix color of two colors. So normally it would be enough to take the values and do some math on it I guess. But I have no idea how two colors can be combined to the “mixed” color like this. So your collision info is something which will help me a lot to achieve what I’m trying to do here.

I still have some problems with it… I can’t figure out how to use the collision detection (like explained here…http://coronalabs.com/blog/2014/06/24/tutorial-particle-collisions-in-liquidfun/) for getting the color of mixed particles because with all the particle collision detection you have to use “fixtureContactListener” as the flag value and NOT the “colorMixing”, right?

Another problem is: It seems I have to much particles and using the FixtureContactListener is stopping the application with an error. Without the flag the performance is great btw.

So is there maybe an easy way to get the color value of one specific particle? Or is it possible to use a static physics body (another object) to get a collision detection with some particles to get the info from them?

Any ideas?

Thx!

Daniela

I think I figured it out. I still have to test it carefully, but if anybody is interested in doing some tests for himself, here is the code to mix two colors:

    local colorMix=function(c1\_R,c1\_G,c1\_B, c2\_R,c2\_G,c2\_B)             local \_r = math.min((c1\_R + c2\_R),255)-1         local \_g = math.min((c1\_G + c2\_G),255)-1         local \_b = math.min((c1\_B + c2\_B),255)-1                  print ("r= ", \_r)         print ("g= ", \_g)         print ("b= ", \_b)                  drawcircle=display.newCircle(0,0,100,100)         drawcircle.x=300         drawcircle.y=200         drawcircle:setFillColor(\_r,\_g,\_b)          end     colorMix (255,0,0,0,0,255)

Best,

Daniela

This is still not working :frowning:

How is the Color Mixing done between liquid fun particles when using the flag “colorMixing”? This is something which should be possible to implement with ‘normal’ code in Corona somehow, isn’t it? I just need the ‘realistic’ color mix of two colors representing a real-world color mix, like the liquid fun mixing is doing. I need the ‘maximum’ mixed color of two colors, like the color which is the result when two different colored liquid particles have reached their maximum mix.

Any ideas? I’m stuck here :frowning:

Here is a useful link to show what kind of mixing I need: http://trycolors.com/ … something like this with two colors!

Argh… after hours of testing and retrying and searching for better solutions I realized I had a typo in my code and the sample code from above just works like planned :slight_smile:

Oh oh :wink:

Best,

Daniela

Hi Daniela,

When would you do this? During a particle collision? I ask because, if you have blue and red liquids mixing, obviously that mix consists of many different particles, each one leaning slightly more toward blue or red. So, I can’t think of any way to “average” out the mixed color across a wider area. However, if you want to get color values on collision, you should experiment with the event values like this one:

http://docs.coronalabs.com/api/event/particleCollision/r.html

Of course, there’s one for “g” and “b” and “a” (alpha) as well:

http://docs.coronalabs.com/api/event/particleCollision/index.html

Hope this helps,

Brent

Thx Brent… this helps a lot!

I was searching for something which can give me the maximum mix color of two colors. So normally it would be enough to take the values and do some math on it I guess. But I have no idea how two colors can be combined to the “mixed” color like this. So your collision info is something which will help me a lot to achieve what I’m trying to do here.

I still have some problems with it… I can’t figure out how to use the collision detection (like explained here…http://coronalabs.com/blog/2014/06/24/tutorial-particle-collisions-in-liquidfun/) for getting the color of mixed particles because with all the particle collision detection you have to use “fixtureContactListener” as the flag value and NOT the “colorMixing”, right?

Another problem is: It seems I have to much particles and using the FixtureContactListener is stopping the application with an error. Without the flag the performance is great btw.

So is there maybe an easy way to get the color value of one specific particle? Or is it possible to use a static physics body (another object) to get a collision detection with some particles to get the info from them?

Any ideas?

Thx!

Daniela

I think I figured it out. I still have to test it carefully, but if anybody is interested in doing some tests for himself, here is the code to mix two colors:

    local colorMix=function(c1\_R,c1\_G,c1\_B, c2\_R,c2\_G,c2\_B)             local \_r = math.min((c1\_R + c2\_R),255)-1         local \_g = math.min((c1\_G + c2\_G),255)-1         local \_b = math.min((c1\_B + c2\_B),255)-1                  print ("r= ", \_r)         print ("g= ", \_g)         print ("b= ", \_b)                  drawcircle=display.newCircle(0,0,100,100)         drawcircle.x=300         drawcircle.y=200         drawcircle:setFillColor(\_r,\_g,\_b)          end     colorMix (255,0,0,0,0,255)

Best,

Daniela

This is still not working :frowning:

How is the Color Mixing done between liquid fun particles when using the flag “colorMixing”? This is something which should be possible to implement with ‘normal’ code in Corona somehow, isn’t it? I just need the ‘realistic’ color mix of two colors representing a real-world color mix, like the liquid fun mixing is doing. I need the ‘maximum’ mixed color of two colors, like the color which is the result when two different colored liquid particles have reached their maximum mix.

Any ideas? I’m stuck here :frowning:

Here is a useful link to show what kind of mixing I need: http://trycolors.com/ … something like this with two colors!

Argh… after hours of testing and retrying and searching for better solutions I realized I had a typo in my code and the sample code from above just works like planned :slight_smile:

Oh oh :wink:

Best,

Daniela