Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
boolean SetRectangle(in unisgned long x, //
	in unsigned long y, //
	in unsigned long w, //
	in unsigned long h);
/*
Modifies the position (x,y) and size (w,h) of the ticker widget. Changing the size of the widget 
will reset the ticker animation. As long as the size of the widget remains unchanged, modifying 
the position will not interrupt the ticker animation.
*/
 
int AddString(in DOMString str); 
/*
Adds a string to the queue. This method returns a string_id integer that can be used to identify 
which string was removed when the ontickerstringremoved event is generated; a zero return indicates 
that the method failed to add the string. Adding too many strings without popping them from the 
stack will cause AddString() to return False (the exact number depends on the font size for each 
string). The maximum recommended number of stored strings is 64.
*/
int AddSurface(in ImageData image);
/*
Adds a bitmap image to the list of strings to display. The image must be of type ImageData. This 
method returns a string_id integer that can be used to identify which surface is removed when the 
ontickerstringremoved event is generated. See the code at the bottom of this page for an example of
using a canvas/image with this method.
*/
boolean PopStrings(in unsigned long count);
boolean SetAutoPop(in boolean);
/*
If this method is set to True, strings are automatically removed (popped from the stack) once they 
have scrolled off screen.
*/
boolean SetForegroundColor(in unsigned long argb);
boolean SetForegroundColor(in unsigned long a, 
	in unsigned long r,
	in unsigned long g,
	in unsigned long b);

boolean SetBackgroundColor(in unsigned long argb);
boolean SetBackgroundColor(in unsigned long a,
	in unsigned long r,
	in unsigned long g,
	in unsigned long b);

boolean SetSeparatorString(in DOMString str);
boolean SetSeparatorCircle();
boolean SetSeparatorDiamond();
boolean SetSeparatorSquare();

unsigned long SetPixelsPerSecond(in unsigned long pps);

boolean SetFont(in DOMString font); 
/*
Specifies a font for the BSTicker (as well as the roTextWidget BrightScript object). This method accepts a
list of font-family names (similar to the CSS <font-family> property). The string can also have a "font-face:"
prefix to indicate that this is a font description (e.g. "font-face:DejaVu Serif,Serif Italic Bold"). Fonts 
must be added to the HTML widget using the roHtmlWidget.AddFont() method before they can be used in a BSTicker 
instance.
*/
boolean SetMultiscreen(in unsigned long offset, 
in unsigned long size,
in DOMString ip_address,
in unsigned long port);

void Shutdown()

...

Code Block
languagejs
linenumberstrue
var bsTicker = new BSTicker(10, 110, 600, 30);
 
function addText1()
{
    console.log('############ addText1');
    bsTicker.AddString("addText1");
}
function addText2()
{
    console.log('############ addText2');
    bsTicker.AddString("addText2");
}
function addText3()
{
    console.log('############ addText3');
    bsTicker.AddString("addText3");
}

function setBackground1()
{
    console.log('############ setBackground1');
    bsTicker.SetBackgroundColor(0xFF0000);
}
function setBackground2()
{
    console.log('############ setBackground2');
    bsTicker.SetBackgroundColor(0x00FF00);
}

function setForeground1()
{
    console.log('############ setBackground1');
    bsTicker.SetForegroundColor(0x007700);
}
function setForeground2()
{
    console.log('############ setBackground2');
    bsTicker.SetForegroundColor(0x000077);
}

function setSeparatorString()
{
    console.log('############ setSeparatorString');
    bsTicker.SetSeparatorString(" ### ");
}
function setSeparatorCircle()
{
    console.log('############ setSeparatorCircle');
    bsTicker.SetSeparatorCircle();
}
function setSeparatorDiamond()
{
    console.log('############ setSeparatorDiamond');
    bsTicker.SetSeparatorDiamond();
}
function setSeparatorSquare()
{
    console.log('############ setSeparatorSquare');
    bsTicker.SetSeparatorSquare();
}

function setTickerSpeed()
{
    console.log('############ setTickerSpeed');
    var speed = bsTicker.SetPixelsPerSecond(180);
    console.log('############ SetPixelsPerSecond(180), Resulting speed: ' + speed);
}

 

The following examples allow for adding a canvas or image to the ticker with the AddSurface() method:

Code Block
languagejs
linenumberstrue
//Loading a canvas
var ctx = canvas.getContext("2d");
var img = ctx.getImageData(0, 0, ctx.canvas.width, ctx.canvas.height);

ticker.AddSurface(img); 

//Loading an image

var imageObj = new Image();
imageObj.onload = function() {
	canvas.width = this.width;
	canvas.height = this.height;

	var ctx = canvas.getContext("2d");
	ctx.drawImage(this, 0, 0); // Use getImage Data as above
 };
 imageObj.src = "filename.jpg";