My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
jssvg  
jssvg module
doc
Updated May 31, 2009 by sou...@gmail.com

If something seems wrong or incomplete, please enter a comment at the bottom of this page.



- source - main - QA -

jssvg module


class jssvg::SVG

- top - revision -

constructor

constructor()
Constructs a new SVG object.

Methods

Write

this Write( xmlString )
Adds XML data to the current SVG context.
note:
calls to callback function 'onImage' may occur during this call.
example:
  svg.Write(<svg><circle cx="50" cy="50" r="25" fill="red"/></svg>);
  // or
  svg.Write('<svg><circle cx="50" cy="50" r="25" fill="red"/></svg>');

RenderImage

ImageObject RenderImage( [ imageWidth , imageHeight ] [ , channels ] [ , fit ] [ , elementId ] )
Draws the SVG to an image object.
arguments:
  1. integer imageWidth: override default SVG's width.
  2. integer imageHeight: override default SVG's width.
  3. integer channels: 1 (Alpha only), 3 (RGB) or 4 (RGBA).
  4. boolean fit: fit the SVG dimensions to [imageWidth, imageHeight].
  5. string elementId: draws a subset of a SVG starting from an element's id. For example, if you have a layer called "layer1" that you wish to render, pass "#layer1" as the id.
example:
  var svg = new SVG();
  svg.Write(<svg><circle cx="50" cy="50" r="25" fill="red"/></svg>);
  svg.Rotate(Math.PI/4); // +45 deg
  svgimage = svg.RenderImage(100, 100, true);
  new File('test.png').content = EncodePngImage( svgimage )

SetVisible

boolean SetVisible( elementId, polarity )
arguments:
  1. string elementId: the id of the element with '#' prefix (eg. '#circle1').
  2. boolean polarity: false to hide, true to show.
return value:
true if the element visibility has been set, otherwise false.

Scale

this Scale( sx, sy )
Applies scaling by sx, sy to the current transformation. The effect of the new transformation is to first scale the coordinates by sx and sy, then apply the original transformation to the coordinates.

Rotate

this Rotate( radians )
Applies rotation by radians to the current transformation. The effect of the new transformation is to first rotate the coordinates by radians, then apply the original transformation to the coordinates.

Translate

this Translate( tx, ty )
Applies a translation by tx, ty to the current transformation. The effect of the new transformation is to first translate the coordinates by tx and ty, then apply the original transformation to the coordinates.

Properties

dpi

integer | Array dpi write-only
Sets the dpi of the resulting image. If the argument is an Array (like dpiX, dpiY ) X and Y dpi can be set aside.

width

width
Is the default width of the SVG.

height

height
Is the default height of the SVG.

title

title
Is the title of the SVG.

metadata

metadata
Is the metadata string of the SVG.

description

description
Is the description string of the SVG.

images

images

callback functions

  • ImageObject onImage( uri )
  • Called when the SVG renderer need to draw an image element. uri is the name of the requested image. The function must return an image Object.
    example:
      var svg = new SVG();
      svg.Write(<svg><image x="0" y="0" path="img.png"/></svg>);
      svg.onImage = function(href) {
       return DecodePngImage( new File('myImage.png').Open('r') );
      }

- top - main -


Sign in to add a comment
Powered by Google Project Hosting