playMaker

Author Topic: Compare colours  (Read 789 times)

moondust.games

  • Playmaker Newbie
  • *
  • Posts: 44
    • View Profile
Compare colours
« on: December 22, 2017, 08: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, 08:22:56 AM by moondust.io »

moondust.games

  • Playmaker Newbie
  • *
  • Posts: 44
    • View Profile
Re: Compare colours
« Reply #1 on: December 22, 2017, 09: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.

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 988
    • View Profile
    • Fat Pug Studio
Re: Compare colours
« Reply #2 on: December 22, 2017, 11:16:26 AM »
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.

Deek

  • Full Member
  • ***
  • Posts: 126
    • View Profile
Re: Compare colours
« Reply #3 on: December 22, 2017, 04: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, 06:46:39 AM by Deek »