SvgPicture

smile.pictures.SvgPicture
See theSvgPicture companion class
object SvgPicture

Parses and loads SVG pictures, each centered at the origin.

Attributes

Companion
class
Source
Element.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
SvgPicture.type

Members list

Value members

Concrete methods

def apply(path: String): SvgPicture

A picture of the SVG document at the resource path path, which may also be a file path or a URL. It is looked up as Bitmap(path) is and parsed as by smile.pictures.SvgPicture.fromString. In a browser, the document must have been loaded with smile.pictures.SvgPicture.load first, and every picture of a path then shares its document, so they are equal. On the JVM each call reads the document anew, as Bitmap(path) does, so two pictures of a path are not equal.

A picture of the SVG document at the resource path path, which may also be a file path or a URL. It is looked up as Bitmap(path) is and parsed as by smile.pictures.SvgPicture.fromString. In a browser, the document must have been loaded with smile.pictures.SvgPicture.load first, and every picture of a path then shares its document, so they are equal. On the JVM each call reads the document anew, as Bitmap(path) does, so two pictures of a path are not equal.

The JVM reads a file in the encoding its XML declaration names, and a browser reads it as UTF-8 whatever the declaration says, so a file that is to be the same picture on both is saved as UTF-8 or ASCII.

Attributes

Throws
UnsupportedOperationException

in a browser, if path has not been loaded

java.io.IOException

naming path, on the JVM, if nothing is there or it cannot be read as an SVG document

Source
Element.scala

Exports

Defined exports

Exported from SvgPictures

Parses svg, an SVG document, into a picture centered at the origin, the same picture on every platform. Only the static picture in the document is kept. Scripts, event attributes, animation elements, metadata, elements and attributes of other namespaces, and references outside the document are removed, and a switch draws its first child. CSS animations stay, drawn as at their start in a browser and ignored on the JVM. Nothing outside the document is loaded. PNG, JPEG and GIF rasters embedded in it as data: URLs are drawn. The size comes from the root's width, height and viewBox, at 96 pixels per inch, and is 300 by 150 pixels when they give none.

Parses svg, an SVG document, into a picture centered at the origin, the same picture on every platform. Only the static picture in the document is kept. Scripts, event attributes, animation elements, metadata, elements and attributes of other namespaces, and references outside the document are removed, and a switch draws its first child. CSS animations stay, drawn as at their start in a browser and ignored on the JVM. Nothing outside the document is loaded. PNG, JPEG and GIF rasters embedded in it as data: URLs are drawn. The size comes from the root's width, height and viewBox, at 96 pixels per inch, and is 300 by 150 pixels when they give none.

Attributes

Throws
java.io.IOException

if the text is not well-formed XML with an SVG root, its elements nest more than 30 deep, or its size is invalid or over 16384 pixels a side

Source
SvgPicture.scala
def load(path: String): Future[SvgPicture]
Exported from SvgPictures

Loads the document at path asynchronously using the rules of smile.pictures.SvgPicture.apply. In a browser the first load must be asynchronous and includes decoding for canvas output. Later calls to apply can load the same path synchronously. A missing, unreadable or undecodable document fails the future with an IOException.

Loads the document at path asynchronously using the rules of smile.pictures.SvgPicture.apply. In a browser the first load must be asynchronous and includes decoding for canvas output. Later calls to apply can load the same path synchronously. A missing, unreadable or undecodable document fails the future with an IOException.

Attributes

Source
SvgPicture.scala