Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
TheEndless
Channel Surfer

Re: Toggle Element Visibility with roImageCanvas

"skitdev" wrote:
I'm not sure why it was necessary, but it appears to be the culprit. I can set layers to invalid or use clearLayer to clear them away.

If you're displaying the canvas over video, then you need at least one layer that cuts a portal through the canvas, so the video can show through. Video does not reside on one of the layers, but behind the entire canvas.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
NewManLiving
Visitor

Re: Toggle Element Visibility with roImageCanvas

SetLayer(zOrder as Integer, contentMetaData as Object) as Void

zOrder is a z-order specifier with higher z-orders closer to the viewer. Negative z-orders are "behind the display" and are thus invisible


if(code = 6)'OK ' Code needs to be 6 for allowupdates to ever be false. So if code is not 6 then allowupdates false will never be called
canvas.allowUpdates(false)

canvas.allowUpdates(true)
canvas.show()



Now you may be testing this and therefore have your code set up that way, but allowupdates is set to false only when code = 6 and then turned right back on again at the bottom where there is no check on any code so if the user presses another key outside of the ones you check for then the bottom two lines will be called for every other button that is pressed as well

For example if you pressed 6 then allowupdates = false , but set right back to true at the bottom where it falls out of the if statement. Then if you press 3 allowupdates = false will never get called because you did not press 6, but it will always get set right back to true again at the bottom of the if statement
at the top allowupdates false will never be called if you press any other button but 6,
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
TheEndless
Channel Surfer

Re: Toggle Element Visibility with roImageCanvas

"NewManLiving" wrote:
zOrder is a z-order specifier with higher z-orders closer to the viewer. Negative z-orders are "behind the display" and are thus invisible

Fair enough, but it's very unlikely that applies to the video plane. If roVideoPlayer, which is on the video plane, is always behind the graphics plane (which makes sense), then no matter how negative you go with z-order, it'll always be in front of the video.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
NewManLiving
Visitor

Re: Toggle Element Visibility with roImageCanvas

Yes, you would think so, but apparently it is just a matter of clipping. While ClearLayer is the most efficient, you can put layers "behind" the so-called video plane
If you were to move the hello layer's x position back into the video x pos, it would display or clip accordingly as well ( I think ) 😄
Sub Main() 

hideL = -1 ' ? Behind the video plane
backL = 0
helloL = 1
videoL = 2 ' Transparent layer is 2
coverL = 3

playerRect = { x: 120, y: 250, w: 380, h:212 }
punchRect = playerRect
coverRect = { x: playerRect.x + 75, y: playerRect.y + 75 , w: playerRect.w - 150, h: playerRect.h - 150 }


back = { Color:"#FFFFFFFF", CompositionMode:"Source"}

hello ={
Text:"Press Ok To Toggle, Back To Exit"
TextAttrs:{Color:"#FFCCCCCC", Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:450,y:325,w:500,h:60}
}

video = {
Color: "#00000000"
TargetRect: punchRect
CompositionMode: "Source" }

cover = {
Color: "#FFFFFFFF"
TargetRect: coverRect
CompositionMode: "Source" }



content = {

Stream: {
url: "http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"

}

StreamFormat: "hls"
SwitchingStrategy: "full-adaptation"
}

canvas = CreateObject( "roImageCanvas" )
port = CreateObject( "roMessagePort" )
canvas.SetMessagePort(port)

VPlayer = CreateObject( "roVideoPlayer" )
VPlayer.SetMessagePort( port )
VPlayer.SetDestinationRect( playerRect )
VPlayer.AddContent( content )

canvas.SetLayer( backL , back )
canvas.SetLayer( videoL, video )
canvas.SetLayer( helloL, hello )
canvas.SetLayer( coverL, cover )

coverShowing = True
canvas.Show()

VPlayer.Play()

while(true)
msg = wait(0,port)
if type(msg) = "roImageCanvasEvent" then
if (msg.isRemoteKeyPressed()) then
i = msg.GetIndex()
print "Key Pressed - " ; msg.GetIndex()
if (i = 0) then
' Up - Close the screen.
VPlayer.Stop()
canvas.close()
else if i = 6

canvas.AllowUpdates( False )

if coverShowing
canvas.ClearLayer( coverL )
canvas.SetLayer( hideL, cover )
else
canvas.SetLayer( coverL, cover )
end if
coverShowing = not coverShowing
canvas.AllowUpdates( True )
canvas.Show()

end if
else if (msg.isScreenClosed()) then
print "Closed"
return
end if
else if type(msg) = "roVideoPlayerEvent" then
print msg.GetIndex(), msg.GetMessage()

end if
end while

My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
NewManLiving
Visitor

Re: Toggle Element Visibility with roImageCanvas

By the way, this also applies to sprite z orders in roScreen. Fankly, I don't think that negative sprites and layers are even drawn, what would be the point ? In the example would one use both clear and then set the cleared layer to a negative layer ? Of course not, but it demonstrates that you can have negative layers under the transparent video layer. However, you can also swap into a negative layer with the same results
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
TheEndless
Channel Surfer

Re: Toggle Element Visibility with roImageCanvas

"NewManLiving" wrote:
By the way, this also applies to sprite z orders in roScreen. Fankly, I don't think that negative sprites and layers are even drawn, what would be the point ? In the example would one use both clear and then set the cleared layer to a negative layer ? Of course not, but it demonstrates that you can have negative layers under the transparent video layer. However, you can also swap into a negative layer with the same results

Actually, that's a function of you having a fullscreen layer with a CompositionMode of "Source" on top of the negative layer, which will replace any pixels that are behind it. It is not putting the layers behind the video plane, but rather under that Source layer. You'll get the same results if you move all of your layers forward.. For example:
   hideL  =  9   ' ? Behind the Background Source plane
backL = 10
helloL = 11
videoL = 12 ' Transparent layer is 12
coverL = 13
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
NewManLiving
Visitor

Re: Toggle Element Visibility with roImageCanvas

I'm speaking in terms of the API
Had this same discussion with Mark previously
You can use the Api as stated and set layer
And set sprite as documented. What happens
Is a bunch of clipping. Nothing is ever put under
The video plane or any other plane
So your analysis is completely correct but you are
Looking at it from a different perspective
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
skitdev
Visitor

Re: Toggle Element Visibility with roImageCanvas

"NewManLiving" wrote:
SetLayer(zOrder as Integer, contentMetaData as Object) as Void

zOrder is a z-order specifier with higher z-orders closer to the viewer. Negative z-orders are "behind the display" and are thus invisible


if(code = 6)'OK ' Code needs to be 6 for allowupdates to ever be false. So if code is not 6 then allowupdates false will never be called
canvas.allowUpdates(false)

canvas.allowUpdates(true)
canvas.show()



Now you may be testing this and therefore have your code set up that way, but allowupdates is set to false only when code = 6 and then turned right back on again at the bottom where there is no check on any code so if the user presses another key outside of the ones you check for then the bottom two lines will be called for every other button that is pressed as well

For example if you pressed 6 then allowupdates = false , but set right back to true at the bottom where it falls out of the if statement. Then if you press 3 allowupdates = false will never get called because you did not press 6, but it will always get set right back to true again at the bottom of the if statement
at the top allowupdates false will never be called if you press any other button but 6,


As I said, it was a mistake. I didn't intend to have my code set up this way.
0 Kudos
skitdev
Visitor

Re: Toggle Element Visibility with roImageCanvas

"TheEndless" wrote:
"NewManLiving" wrote:
By the way, this also applies to sprite z orders in roScreen. Fankly, I don't think that negative sprites and layers are even drawn, what would be the point ? In the example would one use both clear and then set the cleared layer to a negative layer ? Of course not, but it demonstrates that you can have negative layers under the transparent video layer. However, you can also swap into a negative layer with the same results

Actually, that's a function of you having a fullscreen layer with a CompositionMode of "Source" on top of the negative layer, which will replace any pixels that are behind it. It is not putting the layers behind the video plane, but rather under that Source layer. You'll get the same results if you move all of your layers forward.. For example:
   hideL  =  9   ' ? Behind the Background Source plane
backL = 10
helloL = 11
videoL = 12 ' Transparent layer is 12
coverL = 13


This is the part that I think I'm having trouble understanding. When you specify a layer as "source" what is using as the source?
0 Kudos
TheEndless
Channel Surfer

Re: Toggle Element Visibility with roImageCanvas

"skitdev" wrote:
This is the part that I think I'm having trouble understanding. When you specify a layer as "source" what is using as the source?

Specifying a CompositionMode of "Source" means that that layer's pixels will replace any pixels behind it. When set to "Source-Over" the pixels will be alpha blended together. Using "Source" on a layer with transparent pixels (e.g., #00000000), those pixels will "punch" through any layers below it, all the way through to the video plane.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.