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: 
greubel
Visitor

roImageCanvas and alpha channel

How does this work ?

I was trying to do a fade to black by incrementing the alpha bits from 00 to FF but the transparency bounces all over the place.

clr = "#"+Hex(a)+Hex(b)+"000000"
ic.SetLayer(0, {Color:clr, CompositionMode:"Source_Over"})
0 Kudos
3 REPLIES 3
TheEndless
Channel Surfer

Re: roImageCanvas and alpha channel

What are your a and b values? I would think you should only have one Hex() call going from 0 to 255. Also, is Hex a valid BrightScript function, or did you write your own? I don't see it in the documentation.
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
greubel
Visitor

Re: roImageCanvas and alpha channel

a and b is the first and second digit of the x00 to xFF and Hex is my function that returns a string.
I displayed the resultant string and it was what is expected.
0 Kudos
TheEndless
Channel Surfer

Re: roImageCanvas and alpha channel

This works for me... Feel free to steal it. 😉

Function FadeToBlack( fadeStep = 1 As Integer ) As Object
canvas = CreateObject( "roImageCanvas" )
fade = {
Color: "#00000000",
TargetRect: { x: 0, y: 0, w: 1280, h: 720 }
}
canvas.SetLayer( 0, fade )
canvas.Show()
Sleep( 25 )
For value = 0 To 255 Step fadeStep
fade.Color = "#" + ByteToHex( value ) + "000000"
canvas.SetLayer( 0, fade )
Sleep( 25 )
Next
Return canvas
End Function

Function ByteToHex( byte As Integer ) As String
If byte > 255 Then
byte = 255
End If
hexValues = "0123456789ABCDEF"
hex = hexValues.Mid( Int( byte / 16 ), 1 ) + hexValues.Mid( Mod( byte, 16 ), 1 )
Return hex
End Function

' This function is not at all efficient, but the Roku's
' division is very sketchy at higher numbers
Function Mod( a as Integer, b as Integer ) as Integer
If a = 0 Or b = 0 Or a = b Then
Return 0
ElseIf a < b Then
Return a
Else
x = a - b
While x >= b
x = x - b
End While
Return x
End If
End Function
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