Player APIs (BrightScript & Ja...
...
Object Reference
Presentation and Widget Object...
roCanvasWidget
15min
this object composites background color, text, and images into a single rectangle, allowing you to layer images on a z axis object creation like other widgets, rocanvaswidget is created with an rorectangle to set its size and position on the screen createobject ("rocanvaswidget", r as rorectangle) as object ifcanvaswidget hide() as boolean hides the widget show() as boolean shows the widget raise() as void sends the widget to the top of the z order on the graphics plane (i e in front of all other surfaces that implement the ifwidget interface) by default, new widgets are placed at the top of the graphics z order some surfaces are always drawn at the top of the graphics z order, including the mouse cursor, closed captions, and rotextwidget docid\ gqenktmmfazejdlzhttiz tip you can use the pausegraphics() / resumegraphics() methods on the rovideomode docid\ qq734nqz0hcwni0unsdmp object to ensure multiple changes to the graphics z order occur simultaneously lower() as void sends the widget to the bottom of the z order on the graphics plane (i e behind all other surfaces that implement the ifwidget interface) by default, new widgets are placed at the top of the graphics z order setrectangle(r as rorectangle) as boolean changes the size and positioning of the widget rectangle using the passed rorectangle object setlayer(content as object, z level as integer) as boolean sets the contents of a layer within the widget the lowest z level is drawn first, and the highest z level is drawn last the object content is described below clearlayer(z level as integer) as boolean clears the specified layer clear() as boolean clears all of the layers enableautoredraw(enable as boolean) as boolean enables or disables the automatic redrawing of the widget when this function is enabled, each call to setlayer, clearlayer, or clear results in a redraw if you need to change multiple layers, then you should disable auto redraw while calling the setlayer function setlayer enables or disables redrawing of the widget when layer content is changed when auto redraw is enabled, each call to setlayer, clearlayer, or clear results in a redraw to batch multiple updates together, you should first suspend drawing using enableautoredraw(false), then make the changes to the content, and finally re enable drawing using enableautoredraw(true) the redraw happens in a separate thread, so enableautoredraw returns almost immediately object content the content specified in each layer can consist of one or more objects each object is defined by an roassociativearray if there is more than one object, then each is placed into an roarray prior to passing to the setlayer() method currently, there are four object types background color color the #\[aa]rrggbb hex value of the background color targetrect a target rectangle, which is another roassociativearray consisting of x, y, w, and h values these values are relative to the top left corner of the widget text text a string of text to display targetrect the rectangle in which the text is displayed textattrs an roassociativearray containing attributes to be applied to the text the attributes can be any of the following font a string indicating whether the text should be displayed as "small"/"medium"/"large"/"huge" fontsize a point size that is used directly when creating the font if the value is set to 0, then the font automatically resizes to fit the targetrect fontfile the filename for a non system font to use halign a string indicating the "left"/"center"/"right" alignment of the text on a line valign a string indicating the "top"/"center"/"bottom" alignment of the text perpendicular to the line rotation a string indicating the "0"/'90"/"180"/"270" degree rotation of the text color the #\[aa]rrggbb hex value of the text image filename the filename of the image encryptionalgorithm the file encryption algorithm currently the options are "aesctr" and "aesctrhmac" encryptionkey the key to decrypt the image file this is a byte array consisting of 128 bits of key, followed by 128 bits of iv see roimageplayer docid 0umxqyvruy7drnluuzafp for details on displaying encrypted images targetrect the rectangle in which the image is displayed the image will be automatically resized to fit into the target area sourcerect the source rectangle to clip from a source image compositionmode enter either source or source over the latter alpha blends with underlying objects the former replaces the underlying values completely imgattrs an roassociativearray containing attributes to be applied to the image rotation a string indicating the "0"/'90"/"180"/"270" degree rotation of the image qr codes qr (quick response) codes appear as squares of black dots on a white background they are used to encode urls, email addresses, etc, and they can be scanned using readily available software for smart phones although the codes usually appear as black on white, you can, in theory, use any two contrasting colors targetrect the rectangle in which the qr code is displayed regardless of the aspect ratio of this rectangle, the qr code itself will always be squared with the background color that fills the gaps qrcode (simple form) contains the string to encode into the qr code qrcode (complex form) contains an array of parameters for the qr code the parameters can be any of the following color the foreground color in the qr code (the default is black) backgroundcolor the background color in the qr code (the default is white) rotation a string indicating the "0"/'90"/"180"/"270" degree rotation of the code the code will scan regardless of rotation qrtext contains the text to encode into the qr code example this code contains most of the rocanvaswidget features outlined above rect=createobject("rorectangle", 0, 0, 1920, 1080) cw=createobject("rocanvaswidget", rect) aa=createobject("roassociativearray") aa\["text"] = "primal scream" aa\["targetrect"] = { x 280, y 180, w 500, h 30 } aa\["textattrs"] = { color "#aaaaaa", font "medium", halign "left", valign "top"} aa1=createobject("roassociativearray") aa1\["text"] = "movin' on up, followed by something else, followed by something else, followed by something else, followed by something else" aa1\["targetrect"] = { x 282, y 215, w 80, h 500 } aa1\["textattrs"] = { color "#ffffff", font "large", fontfile "usb1 /giddyupstd otf", halign "left", valign "top", rotation "90"} array=createobject("roarray", 10, false) array push({ color "5c5d5f" }) array push({ filename "transparent balls png" }) array push(aa) aa2=createobject("roassociativearray") aa2\["filename"] = "transparent balls png" aa2\["compositionmode"] = "source over" aa2\["targetrect"] = { x 400, y 200, w 200, h 200 } aa3=createobject("roassociativearray") aa3\["qrcode"] = "www brightsign biz" aa3\["targetrect"] = { x 100, y 100, w 400, h 400 } aa4=createobject("roassociativearray") aa4\["qrcode"] = { qrtext "www brightsign biz", rotation "90" } aa4\["targetrect"] = { x 1200, y 100, w 400, h 600 } aa5=createobject("roassociativearray") aa5\["qrcode"] = { color "#964969", backgroundcolor "#ffff77", qrtext "www brightsign biz", rotation "180" } aa5\["targetrect"] = { x 100, y 600, w 400, h 400 } cw\ show() cw\ enableautoredraw(0) cw\ setlayer(array, 0) cw\ setlayer(aa1, 1) cw\ setlayer(aa1, 2) cw\ setlayer(aa3, 3) cw\ setlayer(aa4, 4) cw\ setlayer(aa5, 5) cw\ enableautoredraw(1) cw\ clearlayer(0)