To get around this I made this utility mask.lua
[lua]
local M = {}
local GENERIC_MASK_FILE = “images/generic_mask.png”
local GENERIC_MASK_WIDTH = 400
local GENERIC_MASK_HEIGHT = 400
M.applyMask = function(params)
if params.object == nil then
return
end
if params.width == nil then
params.width = params.object.width
end
if params.height == nil then
params.height = params.object.height
end
local myMask = graphics.newMask(GENERIC_MASK_FILE)
params.object:setMask(myMask)
params.object.maskScaleX = params.width/GENERIC_MASK_WIDTH
params.object.maskScaleY = params.height/GENERIC_MASK_HEIGHT
--there may be a need in the future add logic to the positioning for different reference points
params.object.maskX = params.width/2
params.object.maskY = params.height/2
end
return M
[/lua]
In my case I used an image that was 408 x 408 pixels image, a 400 x 400 white square with a 4 pixel wide black border. having a large image and scaling down works better than a small image scaling up (since when scaling up a grey area is created and thus not a crisp mask)
An example of usage:
[lua]
local Mask = require(“mask”)
…
local OPTIONS_LIST_HEIGHT = 300
local OPTIONS_LIST_HEIGHT = 200
…
local tableView = Widget.newTableView{
width = OPTIONS_LIST_WIDTH,
height = OPTIONS_LIST_HEIGHT,
…
}
Mask.applyMask({
object = tableView,
width = OPTIONS_LIST_WIDTH,
height = OPTIONS_LIST_HEIGHT
})
[/lua]
When applying to a table view passing in explicit sizes seems to works better since getting the size from the table view object isn’t always exactly what you set it to be.