How do I get my colour mixing game to work

Get help using Construct 2

Post » Tue Dec 02, 2014 7:15 pm

Red and blue make magenta.
My problem is, when two cubes are put into the den, their tints are effectively added to the other cubes tint.
To make pink, one would have to subtract a value from the red block. Not add.

I know there are many combinations to Red/Green/Blue but, having not thought the game through enough, I realise it can't be written! If colours are only added, the values of each blocks tints do not go down.

A random element would have to be added, but that detracts from the original idea of using colour combinations to make others.

I want to that you for all your help, Xavier. It was your quick programming skills that have led me to the conclusion that I may well be barking up the wrong tree with this one.

Cheers.
B
7
Posts: 33
Reputation: 341

Post » Tue Dec 02, 2014 8:02 pm

You probably need to convert to LAB first, do the average, and then convert back.

Ref:
http://stackoverflow.com/questions/1481 ... javascript
http://www.easyrgb.com/?X=MATH
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Tue Dec 02, 2014 8:54 pm

Thanks for those links.
It seems I'd have to convert from RGB to XYZ to LAB, average, then convert back.

I wouldn't have a clue how to apply those formula though.

Thanks for the help though, it made for an interesting read.
B
7
Posts: 33
Reputation: 341

Post » Tue Dec 02, 2014 9:37 pm

You're welcome and you're right about RGB being an additive format for producing colors. For real life color mixing you'll need the Lab Colour Space format blackhornet mentioned. It doesn't sound like an easy task, at least for me, and it probably involves formulas or complicated expressions.

It could also be added as a plugin with Construct 2 SDK if someone wanted to do it.
B
74
S
28
G
17
Posts: 256
Reputation: 15,125

Post » Wed Dec 03, 2014 3:05 am

Here. I've bookmarked the key events that convert the first sprite, the seconds sprite, the Average calculation and the final Tint on the third sprite.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Wed Dec 03, 2014 7:27 pm

Wow, that's good.
I see I have much to learn about Construct as I couldn't even find a way to create the bookmarks that you have!

Brilliant stuff.
Thanks :-)
B
7
Posts: 33
Reputation: 341

Post » Sun Dec 07, 2014 8:09 pm

Sorry to bother you again....
BlackHornet: I've tried to integrate your rather excellent code into what I'd previously written.
I have done something wrong as my results aren't the same.
the calculations start off well, but something go amiss when the two different colours are combined.
Would you please have a look at the linky here:

https://www.dropbox.com/s/dyaf8ymhl3m5vow/WontWork.capx?dl=0

...and tell me where I've gone wrong?

Many thanks.
B
7
Posts: 33
Reputation: 341

Post » Mon Dec 08, 2014 3:16 am

You were storing the first and second tints in the same local variable. That can't work. I've adjusted it to repick the first one, to fill in the array. I fixed your button click also.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Mon Dec 08, 2014 4:46 pm

blackhornet: A million times thank you. That is wonderful. You're a star. :)
B
7
Posts: 33
Reputation: 341

Previous

Return to How do I....?

Who is online

Users browsing this forum: dop2000, uzumiapps, Yahoo [Bot] and 31 guests