SVG
From SpinetiX Support Wiki
Contents
- 1 Introduction
- 2 SVG specification
- 3 Extensions of SVG elements
- 4 Additional SVG elements
- 5 Additional SVG attributes
- 5.1 allow
- 5.2 audio-pan
- 5.3 spx:accounting
- 5.4 spx:accounting-tag
- 5.5 spx:audio
- 5.6 spx:audioDelay
- 5.7 spx:audioPID
- 5.8 spx:buffering
- 5.9 spx:cacheMaxAge
- 5.10 spx:customHeaders
- 5.11 spx:mask-href
- 5.12 spx:maxDemuxingBufferSize
- 5.13 spx:multiScreenId
- 5.14 spx:overrideFPS
- 5.15 spx:packetization
- 5.16 spx:program
- 5.17 spx:rangeRequests
- 5.18 spx:recipes-href
- 5.19 spx:secureContext
- 5.20 spx:silent
- 5.21 spx:start-at-random-time
- 5.22 spx:subtitles
- 5.23 spx:subtitlesFormat
- 5.24 spx:subtitlesPID
- 5.25 spx:syncVar
- 5.26 spx:transport
- 5.27 spx:videoPID
- 6 Additions to SVG uDOM
- 7 Not supported
Introduction
Scalable Vector Graphics (SVG) is an open standard language created and developed by the World Wide Web Consortium to address the need for a versatile, scriptable and all-purpose vector format for the web and otherwise. It is an XML-based vector image format for two-dimensional graphics, with support for interactivity and animation.
SVG images and their behaviors are defined in XML text files; this means that they can be searched, indexed, scripted, and compressed. As XML files, SVG images can be created and edited with any text editor, but are more often created with drawing software, such as Inkscape, Adobe Illustrator, CorelDRAW etc.
SVG is a language for rich graphical content. SVG allows for three types of graphic objects: vector graphic shapes (e.g., paths consisting of straight lines and curves), multimedia (such as raster images, video, and audio), and text. Graphical objects can be grouped, styled, transformed and composited into previously rendered objects.
SVG specification
The baseline functionality of SVG Tiny 1.2 profile has been extended on SpinetiX platform to support features from SVG 2 and SVG 1.1 main profile, additional SVG elements, SVG attributes, and uDOM API functions.
Features from SVG 2
Here are the supported features from SVG 2:
- Support for the
<canvas>
element as defined into HTML5 / SVG 2 specification. Added in firmware 3.1.0.
Features from SVG 1.1
Here are the supported features from SVG 1.1 main profile:
- Support for the Opacity Attribute Module from the SVG Basic profile – the "opacity" attribute may be applied to any element, including a group (
<g>
). - Support for the Basic Clip Module from the SVG Basic profile – the
<clipPath>
element may only contain a single rect that defines the clipping path, with the additional restriction that only "userSpaceOnUse" coordinates are supported. - Support for elliptical arc path elements inside a path specifications (
<path>
element or animation path). - Support for the "style" attribute on any element, which may contain any of the supported SVG properties.
- Support for the "href" attribute on
<linearGradient>
and<radialGradient>
elements to reference the stop list of a previous element. - Limited support for SVG Filters (Added in firmware 3.1.0)
- Support for SVG
<filter>
element andfilter
property. - Support for the following filter primitives:
<feFlood>
,<feGaussianBlur>
,<feMerge>
and<feOffset>
. - Limited support for following filter primitives:
<feBlend>
(only normal mode),<feColorMatrix>
(the provided matrix does no transfer between alpha and color components),<feComposite>
(only over, in and out operators),<feImage>
(only with SVG fragment source).
- Support for SVG
Extensions of SVG elements
The following SVG elements have been extended to support more features:
-
<svg>
element supports the "dur" attribute to specify the time that should be retained as the "media duration" for this document. -
<video>
and<audio>
elements may specify live streaming sources. -
<animation>
element may reference SVG files, besides video and image files. -
<image>
element may reference an SVG file. If the file is animated it will be displayed at document time 0 or, if defined, at the snapshot time.
Additional SVG elements
auxCmd
The <auxCmd>
element is used to trigger the execution of a command towards a specified target, which is a device connected to the player's serial port. The specified command must be implemented into the serial port protocol file selected on the device.
The <auxCmd>
element uses the following attributes:
- target = ”target”
- Mandatory parameter representing the type of target to control. It must match the target of the protocol file.
- command = ”command”
- Mandatory parameter representing the name of the command to execute. It must match command attribute of one of the
<OnStart>
elements within the protocol file.
- Mandatory parameter representing the name of the command to execute. It must match command attribute of one of the
- param1 (to param9) = “parameters” (optional)
- Optional parameters passed with the command; each parameter could be a string, a number or a regular expression. The content of the parameter paramX is stored in
$PARAMX
(e.g.,$PARAM1, $PARAM2
etc.) when executing the protocol file.
- Optional parameters passed with the command; each parameter could be a string, a number or a regular expression. The content of the parameter paramX is stored in
- begin = "begin-value-list": (optional, =‟0‟ if not present)
- Optional parameter to control when the element should begin (i.e. become active). If not present, the default timing is '0'. See more information about the begin attribute.
For example, a PowerOn command can be triggered using:
<auxCmd command="PowerOn" target="monitor"/>
The actual PowerOn command could be implemented inside a protocol file like this:
<onStart command='PowerOn' goto='start'>
<write data='&#x8C;&#xFF00;&#xFF00;%c{2}%c{1}&#x8F;'/>
</onStart>
Other serial port commands can be implemented in the same manner; first in the protocol file and then called from an SVG document using the <auxCmd>
statement.
sendComPort()
function.iframe
The <iframe>
tag specifies an inline web page frame to embed a web document within the current SVG document.
It can take the following attributes:
-
src
(mandatory)- URI of the web page to be rendered.
-
sandbox
- A string containing zero or more of the following options:
- allow-top-navigation → user can change the top level page
- allow-scripts → JavaScript code can be executed in the web page
- allow-same-origin → allow local file to open remote URI and disable CORS.
- A string containing zero or more of the following options:
-
frameWidth
- Width used to render the iframe, may be different from the actual display width. If not set, the display width is used.
-
scrollX, scrollY
-
zoom- Zoom factor. This has been removed starting with release 4.5.0.
-
spx:customHeaders
- Specify additional custom headers to be used by the player when fetching a web page.
-
spx:scrollbar
- Select between "auto", "hidden" (scrollbar hidden, but scrolling with mouse wheel is possible), and "disabled" (no scrollbar and no scrolling).
-
spx:userAgent
- specify a custom user agent to be used by the player when fetching the web page.
frameWidth
or frameHeight
to force how the web page is rendered within that layer area. For instance, if you use frameWidth=1024
, the content is rendered as in a browser window at 1024 pixels, regardless of the layer size - if you increase the layer size, the zoom also increases. As a general rule, use only frameWidth
, as frameHeight
is automatically calculated to match the layer size.spx:multiScreen
The <spx:multiScreen>
element belongs to the SpinetiX namespace and is used for multiscreen content. It contains multiple <spx:screen>
elements specifying the position of each rectangular screen inside the design space.
The <spx:screen>
uses the following attributes:
- viewBox = "x y w h", where:
- x is the x-axis coordinate of the top-left point of this screen,
- y is the y-axis coordinate of the top-left point of this screen,
- w is the width of this screen,
- h is the height of this screen,
- xml:id is the screen identification name
<spx:multiScreen>
element and it must be under the top <svg>
element.Example:
<spx:multiScreen>
<spx:screen viewBox="0 0 1280 720" xml:id="top"/>
<spx:screen viewBox="0 720 1280 720" xml:id="bottom"/>
</spx:multiScreen>
Additional SVG attributes
allow
Added in release 4.7.0.
This attribute can be set to "spx-api
" in order to enable the Shared Variables JavaScript API and the JavaScript COM API in web page layers. These APIs are disabled by default.
audio-pan
The audio-pan
attribute takes a numerical value which specifies the spatial position of the media in degrees (-180 to 180) relative to the front. A value of 180 will for example reverse the left and right channels of a stereo source.
spx:accounting
The spx:accounting
attribute can take the value "open,close" to mark that a certain resource will be added to the accounting.log for accounting purposes.
spx:accounting="open,close"
spx:accounting-tag
This attribute refers to additional text that is put in the rightmost column in the accounting log for open or close entries referring to this media. It can be used to simplify the parsing of the accounting log by the user application.
spx:audio
Available from 4.0.1 release.
Additional attribute spx:audio
on video elements to select a particular audio track by providing the language code (e.g., "ENG", "FRA", "SPA", etc.), or "QAA" (original version), "QAD" (audio-description).
This attribute was initially added in 4.0.1 release to be used with MPEG-TS video streams and extended in 4.8.0 release to work with video files having multiple audio tracks within.
Starting with release 4.8.4, it is also possible to select the audio track by its number, using "#n" syntax.
spx:audioDelay
Additional attribute spx:audioDelay
on animation and video elements to adjust the audio/video delay. Positive values delay the audio, while negative values will advance it in regard to the video. Meaningful values are between -200ms and 500ms.
spx:audioPID
Available from 4.0.1 release.
Additional attribute spx:audioPID
on video streaming elements to select a particular audio track by its PID.
spx:buffering
The spx:buffering
attribute can be used on streaming media to increase or decrease the default stream buffering duration, which is chosen according to the source information (RTP or MPEG2 transport stream sources).
- It can be specified on animation, video and audio elements as a duration (in seconds, if the time unit is not specified).
- Starting with 4.0.2 release, negative values can also be used to reduce the streaming latency, but care should be taken to avoid buffer underflow when the latency is too low to handle network delay variations.
- This attribute has no effect on non-streaming sources, such as files.
spx:cacheMaxAge
The spx:cacheMaxAge
attribute can be used to overwrite the caching instructions returned by the server for a certain remote file. It can be added to image, video, audio, or animation elements and can take one of the following values:
-
0
(i.e. zero)- Instruct the player to not cache the media resource. This should be used with caution, since the file will be downloaded on every request.
-
spx:cacheMaxAge="0"
- a value grater than 0
- Instruct the player to revalidate the cache after the specified time(in seconds) by querying the server for updates; if the remote file has been updated on the server, the file will be downloaded.
-
spx:cacheMaxAge="3600s"
-
indefinite
- Instruct the player to use the time specified by the server as maximum cashing time.
-
spx:cacheMaxAge="indefinite"
-
disable
(added in 3.0.6)- Instruct the player to disable the cache usage for media resources requiring progressive download. Note that this should not be used for other media resources, as the player might freeze and reboot.
-
spx:cacheMaxAge="disable"
spx:customHeaders
The spx:customHeaders
attribute was initally added for the iframe
element in release 4.0.0. Starting with the release 4.3.0, it can be applied to all media elements; for instance, it can be used to display media from servers using HTTP headers based authentication.
spx:mask-href
Available from 4.1.0 release.
This attribute is used for displaying video with transparency – add it onto the video element to specify the mask video file, which must be a black and white video, where black means fully transparent, white means fully opaque, and shades of gray means partial transparency.
spx:maxDemuxingBufferSize
Additional attribute spx:maxDemuxingBufferSize
on animation, video and audio elements to control the maximum size (in bytes) of the audio/video demuxing buffer. The default is 3145728 for streaming sources and 1048576 for multimedia files. This should only be used when there are "Stream demuxing failed" errors within player.log.
spx:multiScreenId
Additional conditional attribute spx:multiScreenId
to switch on or off parts of the document based on the screen ID.
spx:overrideFPS
Available from 3.1 release.
Additional attribute to override the FPS value sent by a streaming source or read from a video file header in case the FPS is not correct. The attribute value is either an integer (e.g., "24") or a fraction in the form x/y
where both x and y are integers (e.g., "30000/1001").
spx:packetization
Available from 4.1.0 release.
The spx:packetization
attribute can be used on media elements to control the packet type for RTP/RTSP streaming. It can take one of the following values:
- "any"
- This is the default value, which is safer for most cases.
- "compliant"
- This means the RTP stream is strictly compliant with the relevant RFC for transport of MPEG2, MPEG4 or H.264 video over RTP and thus the player can skip some processing steps to find access units - this should enable a gain in latency of up to 1 frame for MPEG2 and MPEG4, and 2 frames for H.264, so typically 66ms at 30fps. When not in a low latency configuration or for other codecs, this parameter does not have any benefit and it is safer not to use it.
Note that this attribute has no effect if MPEG transport streams are used, even if it is over RTP.
spx:program
Available from 4.0.1 release.
Additional attribute spx:program
on video streaming elements to select a particular program by its PID.
spx:rangeRequests
Available from 4.8.4 release.
Additional attribute spx:rangeRequests="off"
on media layers for disabling the use of HTTP byte range requests for compatibility with servers that do not support it properly.
spx:recipes-href
Available from 4.5.0 release.
Additional attribute spx:recipes-href
on wep page layers to specify a recipe file for the Web Robot.
spx:secureContext
Available from 4.8.3 release.
Additional attribute spx:secureContext="on"
on web page layers to be rendered in secure context, as if they were loaded via HTTPS – it defaults to "off" for backwards compatibility.
spx:silent
Additional attribute spx:silent="true"
on video elements to suppress the rotating-dots animation while connecting to a streaming source.
spx:start-at-random-time
Additional attribute spx:start-at-random-time="on"
to be used for scheduled content in order to prevent executing scripts from the scheduled starting time of the document, which could trigger a player reboot (and eventually Safe mode).
Note that this attribute is added to the <svg>
element and requires the spx
namespace to be correctly specified.
<svg [...] xmlns:spx="http://www.spinetix.com/namespace/1.0/spx" spx:start-at-random-time="on">
spx:subtitles
Added in 4.8.0 release, the spx:subtitles
attribute can be used on video elements (files or streaming) to enable and select a particular subtitle track. It can be set to "ON" (select the first subtitle track), a language code (e.g., "ENG", "FRA", "SPA", etc.), "CC" (select closed captioning), "CC1", "CC2", "CC3", "CC4".
The supported subtitles formats are: EIA-708 (Line 21), Teletext, DVB, DVD, Blu-ray, SubRip (SRT), (Advanced) SubStation Alpha (ASS/SSA).
spx:subtitlesFormat
Added in 4.8.0 release, the spx:subtitlesFormat
attribute can be used on video elements (files and streaming) to customize how the subtitles text is displayed. This doesn’t apply to bitmap subtitles like DVB, hybrid like Teletext, nor does it override specific instructions if present in the subtitles source. Also beware of the risk of collision if increasing the font size on formats with explicit positioning of text like EIA-608.
The syntax is based on the Advanced SubStation Alpha (ASS) V4 style declarations, but provided as key-values pairs. The fields are as follows: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding.
For instance, to change the font family to Arial, increase the font size, and makes the text color blue, use this:
<video xlink:href="..." spx:subtitles="on" spx:subtitlesFormat="Fontname=Arial,Fontsize=18,PrimaryColour=&Hff0000&"/>
Note that the fields specifying a color must be spelled with "colour" (British format) and their values are expressed in hexadecimal BGR format as &HBBGGRR&
or &HAABBGGRR&
(with alpha channel). Transparency (alpha) can be expressed as &HAA&
, where "00" is opaque and "FF" is transparent. For boolean values, use "-1" for true and "0" for false.
spx:subtitlesPID
Added in 4.8.0 release, the spx:subtitlesPID
attribute can be used on video streaming elements to select a particular subtitle track by its PID.
spx:syncVar
Available from 4.1.0 release.
The spx:syncVar
attribute should be used on streaming elements (MPEG2-TS multicast over RTP or UDP only) to enable multiscreen synchronization of streaming video.
Its value should be a Shared Variable (e.g., sync@spx-hmp-001d50200015.local) located on one of the players composing the multiscreen.
spx:transport
Additional attribute spx:transport
on media elements to control what transport is used for RTP packets with RTSP streaming. It can take one of the following values:
- "tcp": request RTP streaming interleaved within the RTSP TCP connection
- this allows to do RTP / RTSP streaming over NAT routers and firewalls which do not have transparent RTP / RTSP support but has the disadvantages of TCP based streaming (i.e. head of line blocking and conflicting TCP rate control) causing uncontrolled delay under adverse network conditions.
- "unicast": request unicast RTP streaming over UDP.
- "multicast": request multicast RTP streaming (always UDP).
- no value: use the server's default, typically unicast or multicast RTP over UDP.
spx:videoPID
Available from 4.0.1 release.
Additional attribute spx:videoPID
on video streaming elements to select a particular video track by its PID.
Additions to SVG uDOM
Here are the additions to the SVG Micro DOM (uDOM):
- Global variables and objects for device identification:
MULTI_SCREEN_ID
,DEVICE_NAME
,SERIAL_NUMBER
, anddeviceInfo
. - Global methods:
createSharedVariable()
,fireSharedEvent()
,getElementsByTagName()
,getURL()
(extended),logAtLevel()
,propFindURL()
andsendComPort()
. - KeyboardEvent interface has been extended to include the key modifiers such as shift, alt, ctrl and meta.
- Parsing functions for the parsing of RSS, CSV and iCalendar files.
getElementsByTagName()
Added in 3.1.0 firmware release.
The getElementsByTagName()
function returns a collection of all descendant Elements with a given tag name.
Note: For tree traversal, you can also use the standard getElementById()
function or the ElementTraversal
interface attributes (firstElementChild
, lastElementChild
, previousElementSibling
and nextElementSibling
), and the localName
attribute of the Node interface to test if a certain node is the one you are looking for.
getURL()
The getURL method is not a new addition, but it was extended from the original definition (see SVGGlobal interface) to allow for an optional parameter called flags
:
const unsigned short GETURL_CACHE_CONTENT = 1;
const unsigned short GETURL_TRACK_CHANGES = 2;
const unsigned short GETURL_ALWAYS_CHECK = 4;
void getURL(in DOMString iri, in AsyncStatusCallback callback, in unsigned short flags);
- The
flags
parameter can take the following values:-
GETURL_CACHE_CONTENT
- saves the resource in the player cache.
-
GETURL_TRACK_CHANGES
- tracks / detects if the resource has been changed on the server and invokes the callback function when it has.
-
GETURL_ALWAYS_CHECK
- force the caching time to a very small value, regardless of the headers returned by the server. Using this flag will insure that content is check from the server for each request. This will increase the network bandwidth.
- This flag is available since 3.0.1
-
GETURL_CACHE_CONTENT|GETURL_TRACK_CHANGES
- does both actions from above. This is the recommended value.
-
- Calling the getURL method without the
flags
parameter (e.g.getURL( iri, callback );
) means no caching and no tracking.
-
getURL
supports the http(s) protocol for remote resources and the file protocol to get local stored resources.
logAtLevel()
This method can be used to change the global logging level dynamically from the JavaScript code.
void logAtLevel(in DOMString logLevel, in DOMString logText);
where logLevel
can take one of the following values: LOG_LEVEL_TRACE
, LOG_LEVEL_DEBUG
, LOG_LEVEL_INFO
, LOG_LEVEL_WARN
or LOG_LEVEL_ERROR
.
Example:
logAtLevel( LOG_LEVEL_ERROR, "Houston, we have a problem." );
propFindURL()
The propFindURL method performs a WebDAV PROPFIND request on the given URL, which is used to query information on remote resources and to list the content of directories on a web server, provided the WebDAV extension to HTTP is enabled on the server.
Listing of directories in local content (using a relative or absolute path as the URL) is supported as well, which can be used for instance to build "automatic" playlists.
void propFindURL( DOMString url, AsyncStatusCallback callback, optional unsigned short depth);
-
url
- target url for the WebDAV propFind request; -
callback
- callback function; -
depth
- 0 to get the WebDAV properties of the target resource, 1 to query for the target resource and its immediate children. The default value is 1.
As in getURL, the callback is called both on error or success and is passed a single AsyncURLStatus status
argument.
If status.success
is true, then status.contentType
is set to "application/json"
and status.content
will be an array of objects, whose properties are listed below:
-
filename
- resource name; -
href
- absolute path to resource for local resources or full URL for remote resources; -
creationdate
- value of the DAV:creationdate property represented as aDate
object, ornull
if no such property was returned by the server; -
getcontentlength
- value of the DAV:getcontentlength property ornull
if no such property was returned by the server; -
getetag
- value of the DAV:getetag property ornull
if no such property was returned by the server; -
getlastmodified
- value of the DAV:getlastmodified property represented as aDate
object, ornull
if no such property was returned by the server; -
resourcetype
- value of the DAV:resourcetype property, which is always"collection"
for directories andnull
otherwise.
sendComPort()
The sendComPort()
function triggers the execution of a command towards a specified target, which is a device connected to the serial port of the player. The specified command must be implemented into the serial port protocol file selected on the device. Optional arguments for the command can be provided; their interpretation is command dependent.
void sendComPort(in DOMString target, in DOMString command, [in DOMString arg1, in DOMString arg2, ...]);
For example, to send a "power on" command towards the monitor using a protocol file, use:
sendComPort( "monitor", "PowerOn" );
The actual PowerOn command could be implemented inside a protocol file like this:
<onStart command='PowerOn' goto='start'>
<write data='&#x8C;&#xFF00;&#xFF00;%c{2}%c{1}&#x8F;'/>
</onStart>
- For the SVG equivalent of this function, see
auxCmd
element. - This function is different from the
writeCOMPort()
function (defined by the JavaScript COM API), which is used to directly send characters on the serial port without going through a protocol file.
KeyboardEvent
The KeyboardEvent interface has been extended to include the key modifiers such as shift, alt, ctrl and meta:
interface KeyboardEvent : UIEvent
{
readonly attribute DOMString keyIdentifier;
readonly attribute boolean ctrlKey;
readonly attribute boolean shiftKey;
readonly attribute boolean altKey;
readonly attribute boolean metaKey;
};
- See DOM Level 3 Events for a description of the attributes and Key identifiers set for a description of the
keyIdentifier
.
Not supported
Event attributes
SVG Tiny 1.2 does not support the event attributes ('onload', 'onclick', 'onactivate', etc.), but uses XML Events instead, through the inclusion of the 'listener' and 'handler' elements to provide the ability to specify the event listener separately from the graphical content.
<tref>
<tref>
is not supported in SVG Tiny - to reference a block of text without duplicating the text content, you can either use:
- JavaScript code to set the text content to the contents of a
<tspan>
(this will keep text and formatting from the<tspan>
source) or - the <use> element, which can refer to
<textArea>
or<text>
nodes.
Example:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" dur="indefinite" height="100%" viewBox="0 0 1280
720" viewport-fill="black" width="100%" id="svg">
<title id="title">Use of textArea sample</title>
<defs>
<text id='text' font-size='48' font-family='Comic Sans MS'>Sample Text</text>
<textArea id='textArea' font-size='48' font-family='Comic Sans MS' text-align='center' display-align='center' width='600'
height='100'>Sample Text Area</textArea>
</defs>
<use x='100' y='100' fill='#FFFFFF' xlink:href='#text' />
<use x='100' y='200' fill='#FFFFC0' xlink:href='#text' />
<use x='640' y='100' fill='#FFFFFF' xlink:href='#textArea' />
<use x='640' y='200' fill='#C0FFFF' xlink:href='#textArea' />
</svg>