Dynamic Color Changing (Mixing Liquid Simulation)

Get help using Construct 2

Post » Tue Nov 06, 2012 3:49 am

Hello all! I have run smack into a roadblock trying to create my first Construct2 project and I was hoping someone out there could guide me to a solution.


My Goal:
I am trying to create a basic simulation where you have a cup with a liquid of a known color (Color A) and you are pouring a second liquid of a different known color (Color B) into the cup. What I hope to achieve here is turning the liquid in the cup into a new color (Color C) which would be the interpolated mid-point of Color A and Color B.

My Problem:
The full scale of my project will include dozens of different liquids and you could combine any number of them into the cup in a given round so creating sprite animations of the color shift for every combination of liquids is far from ideal if not all together impossible.



I understand that a sprite object doesn't exactly have a color of its own and therefore I can't just set read and set the RGB/HSL values of a sprite object the way I'd like. Can anyone suggest a good way to approach this?

Thanks in advance,

-Mike
B
6
S
2
G
3
Posts: 5
Reputation: 2,502

Post » Tue Nov 06, 2012 10:07 am

Create a white sprite and use the tint effect. Store the RGB values in variables and use them to read/write the colours.
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Tue Nov 06, 2012 11:35 am

What @thehen said is applicable, if you want computer-color blending.

HOWEVER.

I suppose you want to blend liquids as liquids should blend - i.e. as we all learned in 3rd grade art class (yellow and cyan = green, white + color = lighter color).

I was actually researching this a few weeks ago. It turns out that as far as I can see, nobody has even discovered a reasonable algorithm to accomplish this. It goes into the terrible realm of color spaces.

Let me know if you get it to work!
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Nov 06, 2012 12:16 pm

There was this iOS game that did this perfectly...can't...remember...name...
B
39
S
12
G
8
Posts: 580
Reputation: 7,108

Post » Tue Nov 06, 2012 5:55 pm

@Crudemik, that's good! I googled the problem and found nothing, but if one game has done it, that's a start. I wonder if they'd be willing to share their algorithm...
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Nov 06, 2012 7:52 pm

I was actually hoping to add something like this in my game, and was using this thread at stackoverflow as a base. Might point you in the right direction.

If you get to it before I do (lots of stuff to do before then) let us know!
B
51
S
13
G
8
Posts: 194
Reputation: 7,311

Post » Tue Nov 06, 2012 7:55 pm

@mulkaccino, that's all well and good for additive color mixing. Real-life liquids and paints use subtractive color mixing, which is a different beast altogether.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Nov 06, 2012 8:31 pm

Ahh, missed that entirely.
B
51
S
13
G
8
Posts: 194
Reputation: 7,311

Post » Wed Nov 07, 2012 5:02 am

[QUOTE=thehen] Create a white sprite and use the tint effect. Store the RGB values in variables and use them to read/write the colours.[/QUOTE]

This was much easier than trying to use the AdjustHSL effect and seems to be giving me the control over the colors that I was looking for. Thanks!
B
6
S
2
G
3
Posts: 5
Reputation: 2,502

Post » Wed Nov 07, 2012 5:05 am

Thanks for all the replies!

I'm putting the Tint effect to work for me now and I've started working on the problem of gradually changing the color of my liquid object as new colors are added but, alas, it got late and I had a long day at work so my head is getting kinda fuzzy. I'll be back tomorrow night with a status update and if all goes well a sample of my progress.
B
6
S
2
G
3
Posts: 5
Reputation: 2,502

Next

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 18 guests