Class SvgWriter

java.lang.Object
com.codename1.art.SvgWriter

public final class SvgWriter extends Object

Writes an ArtDocument as SVG.

Shapes, paths, groups, gradients, image paints, clips, masks, text and blend modes are written as SVG. Effects with an SVG filter equivalent (blurs, shadows, color matrices and SVG filter graphs) become filters. A node whose effects SVG cannot express (a bevel, a curves adjustment) and every adjustment layer is written as the image it renders to, so the output looks the same in any SVG viewer.

  • Constructor Details

    • SvgWriter

      public SvgWriter()
  • Method Details

    • setRasterScale

      public SvgWriter setRasterScale(double scale)

      Sets the resolution, in pixels per unit, of nodes written as images.

      Parameters
      • scale: pixels per document unit
    • write

      public static void write(ArtDocument doc, OutputStream out) throws IOException

      Writes a document.

      Parameters
      • doc: the document
      • out: receives UTF-8 SVG; not closed
      Throws:
      IOException
    • toSvg

      public String toSvg(ArtDocument doc)

      The SVG text of a document.

      Parameters
      • doc: the document
    • pathData

      public static String pathData(GeneralPath p)

      Path data for a path.

      Parameters
      • p: the path