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: 
renojim
Community Streaming Expert

Re: first attempt at imagecanvas - not working...

"jbrave" wrote:
Rotation is completely inaccurate, but could be used creatively.

I don't know what you mean by this. Look at the screensaver in Video Poker. It uses TargetTranslation and TargetRotate for the effect you see.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
jbrave
Channel Surfer

Re: first attempt at imagecanvas - not working...

"TheEndless" wrote:
Calling SetLayer on any layer should replace all of the content on that layer, even 0. What you may be seeing is left over from the screen behind your ImageCanvas not redrawing.

#ff00F00C0 (where C0 is the transparancy)

Actually ff is the transparency in that string (though technically not transparent at FF). Either the trailing 0 or the leading f is likely being ignored, since there are only 4 bytes to a color string, and yours seems to have 4 and a half..


typo, but isn't the last byte reading left to right on the end in the 4 bytes the transparancy? If it is the first byte, that might explain some of the mixed results...

"renojim" wrote:
jbrave wrote:Rotation is completely inaccurate, but could be used creatively.
I don't know what you mean by this. It uses TargetTranslation and TargetRotate for the effect you see.
-JT


When rotating a 10x10 square it becomes distorted in an asymmetrical way instead of a symmetrical distortion as one would expect from rotating a low resolution object...

Anyone have any comments on my other questions about why writing to layer 0 results in a trail of dots that stay on the screen and writing to other layers seems to replace the last write? Is that also a timing related effect?

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
TheEndless
Channel Surfer

Re: first attempt at imagecanvas - not working...

"jbrave" wrote:
typo, but isn't the last byte reading left to right on the end in the 4 bytes the transparancy? If it is the first byte, that might explain some of the mixed results...

First byte on the Roku.

"jbrave" wrote:
Anyone have any comments on my other questions about why writing to layer 0 results in a trail of dots that stay on the screen and writing to other layers seems to replace the last write? Is that also a timing related effect?

I commented on that above. It's most likely a result of you not redrawing the screen behind your image 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
jbrave
Channel Surfer

Re: first attempt at imagecanvas - not working...

I commented on that above. It's most likely a result of you not redrawing the screen behind your image canvas.


Ok... the thing is I *want* whatever I draw to be persistant, so it is a good thing, but I also want to be able to do that for each layer I write to.

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
TheEndless
Channel Surfer

Re: first attempt at imagecanvas - not working...

If you want a layer to be persistent, why not just draw on a new layer? If you don't do that, then you'll need to keep track of everything you've drawn on a layer and be sure to add it back when you draw the new stuff on that layer. You can do that by passing an array of objects to the SetLayer(), instead of just a single object.
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
jbrave
Channel Surfer

Re: first attempt at imagecanvas - not working...

Ok, maybe I'm missing something here:

1. I draw a black background on layer by using a screensize rect with color black

backgroundHD = {
Color: "#000000",
TargetRect: { x: 0, y: 0, w: 1280, h: 720 }
}


canvas.SetLayer( 0, backgroundHD)

2. anything I draw on layer 0 after that is persistant



gpix={color:"#00FF0040"
CompositionMode:"Source_Over"
TargetRect:{x:gx,y:gy,w:50,h:50}}

bpix={color:"#0000FF40"
CompositionMode:"Source_Over"
TargetRect:{x:bx,y:by,w:50,h:50}}

rpix={color:"#FF000040"
CompositionMode:"Source_Over"
TargetRect:{x:rx,y:ry,w:50,h:50}}

... 'calculations to move the squares around the screen

rpix.TargetRect.x = rx
rpix.TargetRect.y = ry
rpix.CompositionMode="Source_Over"

gpix.TargetRect.x = gx
gpix.TargetRect.y = gy
gpix.CompositionMode="Source_Over"

bpix.TargetRect.x = bx
bpix.TargetRect.y = by
bpix.CompositionMode="Source_Over"

canvas.SetLayer(0,rpix)
canvas.SetLayer(0,gpix)
canvas.SetLayer(0,bpix)


3. but if I set each color square to its own layer:


canvas.SetLayer(1,rpix)
canvas.SetLayer(2,gpix)
canvas.SetLayer(3,bpix)


every draw replaces the previous draw.

So, I guess my question is, how do I keep persistant drawing on multiple layers, or does it only work on layer 0? Sticking a background on a layer other than 0 first doesn't seem to have an effect.
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
TheEndless
Channel Surfer

Re: first attempt at imagecanvas - not working...

It's not really persistent on layer 0. It appears persistent, because there's no data to replace it with, unless you redraw the screen underneath. As a test, let the screensaver kick in between one of your draws to layer 0, and you'll see what I mean.

If you want consistent,reliable persistence on any layer, you'll need to redraw everything on that layer that needs to be persisted. Unless you want to keep track of that, it will be easier to just draw a new layer, and not replace the existing layer.
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
kbenson
Visitor

Re: first attempt at imagecanvas - not working...

"renojim" wrote:
"jbrave" wrote:
Rotation is completely inaccurate, but could be used creatively.

I don't know what you mean by this. Look at the screensaver in Video Poker. It uses TargetTranslation and TargetRotate for the effect you see.


I'm fairly certain he's referring to using background colors and TargetRect to draw "quads" onthe image canvas. it works well and is fast, as long as you don't rotate. You get some interesting effects.

jbrave, you could always use the rdPNG function from librokudev to arbitrarily color a single pixel PNG and then scale it to the dimensions you want. Rotation works perfectly then. That's the method we used in KidPaint after examining all the other options. The correctly color indexed PNG pixel image is included in the library.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
renojim
Community Streaming Expert

Re: first attempt at imagecanvas - not working...

Interesting. I'll have to try that. I've always used small GIFs.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
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.