| Reference | Downloads | Github

How to get the color of a polygon

I am trying to compare a color to the current color of a polygon to see if they match in an if-statement. However, even if the colors are rigged so that they match, the if-statement always returns a false statement.


#this successfully sets the polygon color to blue (I have visual confirmation)

polygon1.color = ‘blue’

#but this comparison always returns false

if (polygon1.color == ‘blue’)

is there a way to make this work? Or a different method besides .color? I have looked at the documentation but I could not find anything.

I hope someone can help.


I suspect this is because "blue" is essentially shorthand for (-1, -1, 1) (i.e. no red, no green, full blue), so polygon1.color == (-1, -1, 1) should work :slight_smile:

Hi There,

This post might also be useful because we test equality of colors (in python and JS)