mask.width or obj.maskWidth

Would be great if you could expose the width and height of the loaded mask image, so we could access the mask’s source images dimensions.

The reason is that I need to move and scale the mask relative to the object it is masking. Without the width/height I can’t set the ratios properly to do the calculations needed.

[code]

local containerW = 200
local containerH = 400

local group = display.newGroup()

local bkgd = display.newRect( 0, 0, containerW, containerH )

local image = display.newImage(“something.jpg”)

local mask = graphics.newMask( imgMask )

– Would like to set the scaling dynamically based on the container dimensions:
local maskW = mask.width
local maskH = mask.height
local myMaskScaleX = containerW/maskW
local myMaskScaleY = containerH/maskH

group:insert(bkgd)
group:insert(image)
group:setMask(mask)

– Would automatically scale the mask to match the container dimensions:

group.maskScaleX = myMaskScaleX
group.maskScaleX = myMaskScaleY

– OR perhaps to keep the existing mask property conventions:

local maskW = group.maskWidth
local maskH = group.maskHeight
local myMaskScaleX = containerW/maskW
local myMaskScaleY = containerH/maskH

group.maskScaleX = myMaskScaleX
group.maskScaleY = myMaskScaleY

[/code] [import]uid: 616 topic_id: 19252 reply_id: 319252[/import]

+1 [import]uid: 110373 topic_id: 19252 reply_id: 81430[/import]

+1

+1

+1

when I try to find out the width and the height I would do it like that:

local MIMG = display.newImage(MFile, system.TemporaryDirectory ) print( MIMG.width ) display.remove(MIMG); MIMG = nil local viewMask = graphics.newMask( MFile, system.TemporaryDirectory )

even though I delete the image before adding the mask it throws the following error:

The file (mask-320x458.png) has already been loaded as an image display object, so it cannot be used as a mask.

Very frustrating…

I just found this library and ported it to Corona:

http://luaforge.net/projects/imagesize/

a piece of cake… it works like a charm.

wanted to upload it but don’t manage it right now on github…

+1

when I try to find out the width and the height I would do it like that:

local MIMG = display.newImage(MFile, system.TemporaryDirectory ) print( MIMG.width ) display.remove(MIMG); MIMG = nil local viewMask = graphics.newMask( MFile, system.TemporaryDirectory )

even though I delete the image before adding the mask it throws the following error:

The file (mask-320x458.png) has already been loaded as an image display object, so it cannot be used as a mask.

Very frustrating…

I just found this library and ported it to Corona:

http://luaforge.net/projects/imagesize/

a piece of cake… it works like a charm.

wanted to upload it but don’t manage it right now on github…