Hi All,
I am trying to make custom UI by using roImageCanvas. but I am not able to understand the exact behaviour of layers.
What is the exact meaning of clear() interface in roImageCanvas?
for better understanding of my problem I am giving my sample code below.
function main()
mainCanvas = createObject("roImageCanvas")
mainCanvas.setlayer(0, {color:"#FF0000"})
mainCanvas.show()
canvas = createObject("roImageCanvas")
port = createObject("romessagePort")
canvas.setMessagePort(port)
canvas.show()
yPosition = 0
showDataOnCanvas(yPosition, canvas)
while true
msg = wait(0, port)
if(type(msg) = "roImageCanvasEvent")
if(msg.IsRemoteKeyPressed())
index = msg.GetIndex()
if(index = 0)
mainCanvas.close()
canvas.close()
else if(index = 2)
yPosition = yPosition - 100
showDataOnCanvas(yPosition, canvas)
else if(index = 3)
yPosition = yPosition + 100
showDataOnCanvas(yPosition, canvas)
end if
else if(msg.isScreenClosed())
print "comes into screen closed"
exit while
end if
end if
end while
end function
function showDataOnCanvas(yPos, canvas)
list = []
canvas.AllowUpdates(false)
canvas.ClearLayer(0)
list.push({
color:"#33FFFFFF",
compossionMode:"Source_Over"
TargetRect:{x:0, y:0, w:1280, h:720}
})
list.push({
color: "#FF0000",
TargetRect: {x:100, y:yPos, w:300,h:100}
})
list.push({
text: yPos.toStr(),
textattrs: {color:"#000000"},
TargetRect: {x:100, y:yPos, w:300,h:100}
})
canvas.setlayer(0, list)
canvas.AllowUpdates(true)
end function
In this code I am create a red canvas first.
On above of this screen I made an another canvas with low opacity. On that canvas I am trying to make a box of red color and updating that canvas on click on up and down keys.
I am not able to understand the working of clear() interface.
As you can see In showDataOnCanvas(yPos, canvas) method, I am clearing the layer and drawing new data on that but its showing me the previous data also.
Can anyone explain? why is this behaving like that? Or I am missing something?
Thanks in advance.