How to get the rect's color

Hi, all,

I have a question about the rect, I can use setFillColor to set a rect’s color.

But after I set the color, how can I get the color I set?

Thank you guys.

Can’t till gpx2.0 is released
But there are ways around it. If you know the values you can store them in a variable and read them back or I built a function that let’s you read the color values. I’ll post the code later when I get home

Thank you jstrahan.

Appreciate your help.

:slight_smile:

One more question.

How can I get the rect’s width, height, top, and left?

Thank you.

Object.width
Object.height
Object.x
Object.y

X,y depends on reference point so if it’s not set to top left you’ll need to do some math

say you create a rect called block

then create this new function for block

  function block:fillColor( ... )     self:setFillColor(arg[1] or 255, arg[2] or 255, arg[3] or 255, arg[4] or 255)     self.r, self.g, self.b, self.a = arg[1], arg[2], arg[3], arg[4] end

then when you want to color the block use

block:fillColor( r, g, b, a )

this will color the block then to get the current color of the block use

red = block.r

green = block.g

blue = block.b

alfa = block.a

Can’t till gpx2.0 is released
But there are ways around it. If you know the values you can store them in a variable and read them back or I built a function that let’s you read the color values. I’ll post the code later when I get home

Thank you jstrahan.

Appreciate your help.

:slight_smile:

One more question.

How can I get the rect’s width, height, top, and left?

Thank you.

Object.width
Object.height
Object.x
Object.y

X,y depends on reference point so if it’s not set to top left you’ll need to do some math

say you create a rect called block

then create this new function for block

  function block:fillColor( ... )     self:setFillColor(arg[1] or 255, arg[2] or 255, arg[3] or 255, arg[4] or 255)     self.r, self.g, self.b, self.a = arg[1], arg[2], arg[3], arg[4] end

then when you want to color the block use

block:fillColor( r, g, b, a )

this will color the block then to get the current color of the block use

red = block.r

green = block.g

blue = block.b

alfa = block.a