Doodle SVG

A Doodle backend for SVG.

This project draws Doodle pictures to SVG, both in the browser using Scala JS and to files on the JVM.

Getting Started

Add the following dependency to your build.sbt:

libraryDependencies += "org.creativescala" %%% "doodle-svg" %% 0.11.2

Usage

Firstly, bring everything into scope

import doodle.svg._

Now what you can do depends on whether you are running in the browser or on the JVM.

Running in the Browser

In the browser you can draw a picture to SVG. To do this, construct a Frame with the id of the DOM element where you'd like the picture drawn.

For example, if you have the following element in your HTML

<div id="svg-root"></div>

then you can create a Frame referring to it with

val frame = Frame("svg-root")

Now suppose you have a picture called thePicture. You can draw it using the frame you just created like so

thePicture.drawWithFrame(frame)

The rendered SVG will appear where the element is positioned on your web page.

Running on the JVM

On the JVM you can't draw SVG to the screen. Use the java2d backend for that instead. However you can write SVG output in the usual way.