Is there a getFillColor

I have a newRect that I use obj:setFillColor but I want to check its fill color at a later date is there a method such as getFillColor. I say like as that doesn’t seem to work.

Thanks in advance

J [import]uid: 103970 topic_id: 29342 reply_id: 329342[/import]

Found this:

http://stackoverflow.com/questions/11239054/how-to-get-colour-of-rect-on-touch-in-corona-sdk [import]uid: 103970 topic_id: 29342 reply_id: 117922[/import]

On reflection this doesn’t quite do it for me. Any other ideas? [import]uid: 103970 topic_id: 29342 reply_id: 117930[/import]

I would just track it in a variable. You could even add it onto the object in question.

For example:

[code]
test = display.newRect(0,0,200,200)
test.myfill = {}

function SetMyfill(ob,c1,c2,c3,a1)
{
ob:setFillColor(c1,c2,c3,a1)
ob.myfill[1] = c1
ob.myfill[2] = c2
ob.myfill[3] = c3
ob.myfill[4] = a1
}

SetMyfill(test,200,100,5,255)

print (test.myfill[1]) – prints 200
print (test.myfill[2]) – prints 100
print (test.myfill[3]) – prints 5
print (test.myfill[4]) – prints 255

[/code] [import]uid: 56820 topic_id: 29342 reply_id: 117934[/import]

@anderoth - great answer, this is a great way of handling this for now.

@J - we know this is a requested feature, hopefully something we will see in the not too distant future.

Peach :slight_smile: [import]uid: 52491 topic_id: 29342 reply_id: 118042[/import]

Thanks for your feedback @Peach and @anderoth

I keep getting

attempt to call method ‘setFillColor’ (a nil value)

I’m storing my rects in a table and recalling the ones touched. Everything is returned correctly like the x, y values for example and I can retrieve the fillcolor as described but can’t apply as the object isn’t recognised as a rect.

Any ideas. This has me puzzled

J [import]uid: 103970 topic_id: 29342 reply_id: 118388[/import]

Thanks for your feedback @Peach and @anderoth

I keep getting

attempt to call method ‘setFillColor’ (a nil value)

I’m storing my rects in a table and recalling the ones touched. Everything is returned correctly like the x, y values for example and I can retrieve the fillcolor as described but can’t apply as the object isn’t recognised as a rect.

Any ideas. This has me puzzled

J [import]uid: 103970 topic_id: 29342 reply_id: 118389[/import]

Since you are setting the color manually set the .name or .myName to be “red”, “yellow”, “blue”, “green” etc. And then you know what color it is from the name of that object, in case you aren’t using name and myName. So for example you are creating a rectangle named “block”

block:setFillColor(255,0,0)  
block.name = "red"  
block.myName = "red"  

either of the two work, then you can use name or myName to see the exact color anytime [import]uid: 77199 topic_id: 29342 reply_id: 118426[/import]

Thank you @hatethinkingofgames but my issue isn’t retrieving the colour from the object but more retrieving the appropriate rect from a table and resetting the colour

When retrieving it from table the object is not recognised as a rect. Any idea why? [import]uid: 103970 topic_id: 29342 reply_id: 118429[/import]