playMaker

Author Topic: Compare colours  (Read 1842 times)

moondust.games

  • Playmaker Newbie
  • *
  • Posts: 46
Compare colours
« on: December 22, 2017, 10:15:36 AM »
Hi Jean (or anyone) - is it possible to get a simple action made? I can't find one already on the ecosystem.

I just need to compare color1 to color2 with true or false result for if they are identical rbga values or not. color1/2 are either local or global color variables.

Thanks in advance for anyone that can help me out :)

edit : I've thought of a work-around and that's to break both colours down to RGBA floats and then compare those - which means comparing up to 4 floats each time to see if they're the same. Not too bad but if there's a simpler approach to compare colour to colour it would be great.
« Last Edit: December 22, 2017, 10:22:56 AM by moondust.io »

moondust.games

  • Playmaker Newbie
  • *
  • Posts: 46
Re: Compare colours
« Reply #1 on: December 22, 2017, 11:03:11 AM »
In case anyone was going to try and make this please don't worry now....not just for me anyway :)

I've worked out that with my 6 random colours I only need to compare the R(ed) component to the existing colour to see if there's a match since R differs in each case so I've got a very simple FSM to do that now.

I'm sure a "compare color" would be useful in other situations.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Compare colours
« Reply #2 on: December 22, 2017, 01:16:26 PM »
I don't think there's a simpler approach, you can just make a simpler action yourself, that will have the code for comparing float, while UI will show only colors you compare.
Available for Playmaker work

Deek

  • Full Member
  • ***
  • Posts: 133
Re: Compare colours
« Reply #3 on: December 22, 2017, 06:46:13 PM »
Because I thought this would be a good idea for an action, I made one that is comprehensive enough so that you can specify how many colors should be compared to one another and what parts (r, g, b, a, or any combination between them).
With it you can send single events on matching occurrences or save as a bool, if at least one color matched the specified part of the main color.

Even though you already created a small fsm that handles your requirements, you might still want to use my action to cut down the logic into one action.
I'll probably put it onto the ecosystem soon enough, but for now you can find it in the attachments to this post.
« Last Edit: December 23, 2017, 08:46:39 AM by Deek »