How do I get the stroke color?
For fill color it’s just;
local fc = object.fill
How do I get the stroke color?
For fill color it’s just;
local fc = object.fill
You can’t get previously set colors.
Also the technique you show won’t always work for fills.
If you need that info, you need to store it aside when you set it.
There are many ways to do this. If you need it a lot, the easiest way is to override the core display object builder functions to provide the feature.
Ping back if you want to know how to do that. Hint, see SSK 2 display object extensions as a starting point.
https://raw.githubusercontent.com/roaminggamer/SSK2/master/ssk2/core/extensions/display.lua
SSK 2 extends display.newContainer() and display.newGroup() A similar thing can be done for display.newRect() etc…
Again, if you get stuck, post back.
Hi thanks.
I overrided the newLine to add a function as below.
Interestingly I couldn’t override setStrokeColor function itself - I did try - but it just wouldn’t set it, so I made version 2.
seems to work
local \_newLine = display.newLine display.newLine = function( ... ) local object = \_newLine( unpack(arg) ) object.setStrokeColor2 = function ( ... ) object.strokeColor = { arg[2], arg[3], arg[4], arg[5] or 1 } object.setStrokeColor( unpack(arg) ) end return object end
You can’t get previously set colors.
Also the technique you show won’t always work for fills.
If you need that info, you need to store it aside when you set it.
There are many ways to do this. If you need it a lot, the easiest way is to override the core display object builder functions to provide the feature.
Ping back if you want to know how to do that. Hint, see SSK 2 display object extensions as a starting point.
https://raw.githubusercontent.com/roaminggamer/SSK2/master/ssk2/core/extensions/display.lua
SSK 2 extends display.newContainer() and display.newGroup() A similar thing can be done for display.newRect() etc…
Again, if you get stuck, post back.
Hi thanks.
I overrided the newLine to add a function as below.
Interestingly I couldn’t override setStrokeColor function itself - I did try - but it just wouldn’t set it, so I made version 2.
seems to work
local \_newLine = display.newLine display.newLine = function( ... ) local object = \_newLine( unpack(arg) ) object.setStrokeColor2 = function ( ... ) object.strokeColor = { arg[2], arg[3], arg[4], arg[5] or 1 } object.setStrokeColor( unpack(arg) ) end return object end