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

2D API Help and Drawing Text

screen_width = 1100
screen_height = 650

guide_height = 400
guide_width = 1000

cell_height = 50
cell_width = 200
cell_width_margin = 2
cell_height_margin = 2


epg_start_x = 200
epg_start_y = 200

epg_rows = 5
number_programs = 4
current_row = 1


screen = CreateObject("roScreen")


port = CreateObject("roMessagePort")
codes = bslUniversalControlEventCodes()

screen.SetMessagePort(port)
screen.SetAlphaEnable(true)
'screen.Clear(&h0000FFFF)

cell_bm = CreateObject("roBitmap", "pkg:/images/cell.png")
cell_bm.SetAlphaEnable(true)

start_x = epg_start_x
start_y = epg_start_y


fontRegistry = CreateObject("roFontRegistry")
font = fontRegistry.GetDefaultFont()

for i=0 to epg_rows step 1

for j=0 to number_programs step 1
'screen.DrawRect(start_x, start_y, cell_width, cell_height, yellow)
render_text(screen, font, "test episode", start_x, start_y)
screen.DrawObject(start_x, start_y, cell_bm)
start_x = start_x + cell_width + cell_width_margin


end for

start_y = start_y + cell_height + cell_height_margin
start_x = epg_start_x


end for

screen.Finish()


I am trying to generate an EPG grid with cells that contain text. The example above generates the epg grid but the text is underneath the green cell. How can I make the text appear over the drawn object? How could I remove the grid cells for an update to an EPG program data? On a related note, how could I clip the text to appear within the confines of the cell? I don't see anything native for the draw text to enable the use of ellipsis (...). Would this need to be written as extended functionality of the drawText. I've read the 2D API but would love to see some more examples using it.

Thanks for any insight or help.
0 Kudos
1 REPLY 1
RokuMarkn
Visitor

Re: 2D API Help and Drawing Text

To make text appear on top of an object, draw the object first and then draw the text.
Generally an app using roScreen will redraw the entire screen on a update.
This post describes how to truncate text to a desired width.

--Mark
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.