A static SVG document, kept as vectors and drawn under an affine at the output's own density.
Its local frame is the document's own, from the origin to its width and height, and its bounds are that box under its affine, whatever the document paints inside it. Its anchor starts in the middle of the document.
Moves, scalings, turns and flips keep it a vector picture, since each only changes its affine. Only what needs its pixels turns it into pixels, such as toBitmap, which renders it at the settings' scale. The document is opaque to recoloring. Its paints are not rewritten, so a smile.pictures.Recolor whose function changes a color the document shows gives a bitmap of the recolored pixels alone.
SVG pictures are equal when they have the same document, the same affine and the same anchor, so two pictures parsed from the same text separately are not equal.
In the browser, a document is decoded after it is parsed. The browser starts when the picture is made, and until it is done, canvas output draws nothing in the picture's place, and no rendering that left it out is kept. So a bitmap of a picture that holds it, made with Bitmap.of(picture), is transparent there and rendered again at every read and draw until then, and shows the picture afterwards. Pixels taken at once keep what they showed. Those are the pixels of toBitmap, which renders when it is called, and of a color operation such as transformARGB. Await the picture's ready first, or load it with smile.pictures.SvgPicture.load, which gives a picture that is ready. SVG output needs no decoding.
smile.pictures.SvgPicture$ parses and loads them.
Attributes
- Companion
- object
- Source
- Element.scala
- Graph
-
- Supertypes
Members list
Grouped members
scaling
This element scaled by horizontal along the world's x axis and vertical along its y axis, around pivot. A negative factor also mirrors it on that axis, and a zero factor gives the empty picture.
This element scaled by horizontal along the world's x axis and vertical along its y axis, around pivot. A negative factor also mirrors it on that axis, and a zero factor gives the empty picture.
Attributes
- Throws
-
IllegalArgumentException
if a factor or a coordinate of
pivotis not finite, or the scaled element would be too large for its transform to hold in aDouble - Inherited from:
- Element
- Source
- Element.scala
This element scaled by factor around pivot. A negative factor also mirrors it, and a zero factor gives the empty picture.
This element scaled by factor around pivot. A negative factor also mirrors it, and a zero factor gives the empty picture.
Attributes
- Throws
-
IllegalArgumentException
if the factor or a coordinate of
pivotis not finite, or the scaled element would be too large for its transform to hold in aDouble - Inherited from:
- Element
- Source
- Element.scala
This element scaled by horizontal along the world's x axis and vertical along its y axis, around its anchor. A negative factor also mirrors it on that axis, and a zero factor gives the empty picture.
This element scaled by horizontal along the world's x axis and vertical along its y axis, around its anchor. A negative factor also mirrors it on that axis, and a zero factor gives the empty picture.
import smile.colors.PresetColor.*
import smile.modeling.*
val coin = Circle(Pos.Origin, 30, fillWith(Gold), lineWith(Black, 4, round = true))
val stretched = coin.scaleBy(2, 0.5)

Attributes
- Throws
-
IllegalArgumentException
if a factor is not finite
- Inherited from:
- Element
- Source
- Element.scala
This element scaled by factor around its anchor. A negative factor also mirrors it, and a zero factor gives the empty picture.
This element scaled by factor around its anchor. A negative factor also mirrors it, and a zero factor gives the empty picture.
Attributes
- Throws
-
IllegalArgumentException
if the factor is not finite
- Inherited from:
- Element
- Source
- Element.scala
This element scaled around its anchor along the world axes so that its bounds are width wide and height high, outlines included, since they scale with the shape.
This element scaled around its anchor along the world axes so that its bounds are width wide and height high, outlines included, since they scale with the shape.
A negative target flips the element on that axis first. A zero target gives the empty picture. An axis on which the element has no extent, such as the width of an empty text, is left as it is.
Scaling along the world axes scales the bounds by exactly the same factors, so one step is enough, up to the rounding of the factors and of the arithmetic that places the bounds. That rounding has an absolute floor of about 2^-19 pixel, since the anchor and every move lie on the grid of 2^-20 pixel, so a target smaller than that is not met to its own precision.
Attributes
- Throws
-
IllegalArgumentException
if a target is not finite, or the target is so much larger than the current extent that the factor between them, or the scaled transform, overflows a
Double - Inherited from:
- Element
- Source
- Element.scala
turning
This element mirrored both ways through its anchor, which is a half turn around it.
This element mirrored both ways through its anchor, which is a half turn around it.
Attributes
- Inherited from:
- Element
- Source
- Element.scala
This element mirrored left to right across the vertical line through its anchor.
This element mirrored left to right across the vertical line through its anchor.
Attributes
- Inherited from:
- Element
- Source
- Element.scala
This element mirrored top to bottom across the horizontal line through its anchor.
This element mirrored top to bottom across the horizontal line through its anchor.
Attributes
- Inherited from:
- Element
- Source
- Element.scala
This element turned by degrees around pivot, counterclockwise on screen for a positive angle. Right angles are exact.
This element turned by degrees around pivot, counterclockwise on screen for a positive angle. Right angles are exact.
import smile.colors.PresetColor.*
import smile.modeling.*
val hand = Rectangle(60, 8, fillWith(Navy), None)
val fan = Picture((0 to 150 by 30).map(angle => hand.rotateAround(angle, Pos(-30, 0)))*)

Attributes
- Throws
-
IllegalArgumentException
if the angle or a coordinate of
pivotis not finite - Inherited from:
- Element
- Source
- Element.scala
This element turned by degrees around its anchor, counterclockwise on screen for a positive angle. Right angles are exact.
This element turned by degrees around its anchor, counterclockwise on screen for a positive angle. Right angles are exact.
Attributes
- Throws
-
IllegalArgumentException
if the angle is not finite
- Inherited from:
- Element
- Source
- Element.scala
measuring
The point this element is placed, turned and scaled by.
The point this element is placed, turned and scaled by.
Attributes
- Inherited from:
- Element
- Source
- Element.scala
The tight box around what this element draws, outlines included, or None when it draws nothing and takes no room.
The tight box around what this element draws, outlines included, or None when it draws nothing and takes no room.
Attributes
- Inherited from:
- Element
- Source
- Element.scala
The height of smile.pictures.Element.bounds in pixels, or 0 when there are none.
The height of smile.pictures.Element.bounds in pixels, or 0 when there are none.
Attributes
- Inherited from:
- Element
- Source
- Element.scala
The width of smile.pictures.Element.bounds in pixels, or 0 when there are none.
The width of smile.pictures.Element.bounds in pixels, or 0 when there are none.
Attributes
- Inherited from:
- Element
- Source
- Element.scala
moving
This element moved by dx to the right and dy down.
This element moved by dx to the right and dy down.
Attributes
- Throws
-
IllegalArgumentException
if an offset is not finite
- Inherited from:
- Element
- Source
- Element.scala
This element moved so that its anchor is at p.
This element moved so that its anchor is at p.
Attributes
- Throws
-
IllegalArgumentException
if a coordinate of
pis not finite - Inherited from:
- Element
- Source
- Element.scala
This element with its anchor at p, drawn exactly as before. The anchor goes to the nearest multiple of 2^-20 pixel, where every translation lies, so that quarter turns around it stay exact. Every transform puts the anchor back on that grid, which moves it by at most half a step.
This element with its anchor at p, drawn exactly as before. The anchor goes to the nearest multiple of 2^-20 pixel, where every translation lies, so that quarter turns around it stay exact. Every transform puts the anchor back on that grid, which moves it by at most half a step.
Attributes
- Throws
-
IllegalArgumentException
if a coordinate of
pis not finite - Inherited from:
- Element
- Source
- Element.scala
Type members
Types
The type of element that a transform that keeps an element whole returns.
The type of element that a transform that keeps an element whole returns.
Attributes
- Source
- Element.scala
Value members
Concrete methods
Compares the receiver object (this) with the argument object (that) for equivalence.
Compares the receiver object (this) with the argument object (that) for equivalence.
Any implementation of this method should be an equivalence relation:
- It is reflexive: for any instance
xof typeAny,x.equals(x)should returntrue. - It is symmetric: for any instances
xandyof typeAny,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any instances
x,y, andzof typeAnyifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue.
If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).
Value parameters
- that
-
the object to compare against this object for equality.
Attributes
- Returns
-
trueif the receiver object is equivalent to the argument;falseotherwise. - Definition Classes
-
Object -> Any
- Source
- Element.scala
This picture, once its document is decoded for canvas drawing, which starts when the document is parsed. Canvas output draws nothing in its place before that, so await this before reading its pixels. Scala.js only. Every picture of the same document shares the decoding, and SVG output needs none. It fails with an IOException if the browser cannot decode the document.
This picture, once its document is decoded for canvas drawing, which starts when the document is parsed. Canvas output draws nothing in its place before that, so await this before reading its pixels. Scala.js only. Every picture of the same document shares the decoding, and SVG output needs none. It fails with an IOException if the browser cannot decode the document.
Attributes
- Source
- SvgPictureJS.scala
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
Attributes
- Returns
-
a string representation of the object.
- Definition Classes
-
Any
- Source
- Element.scala
Concrete fields
Calculates a hash code value for the object.
Calculates a hash code value for the object.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.
Attributes
- Returns
-
the hash code value for this object.
- Source
- Element.scala
