A Doodle backend for SVG. This is Doodle SVG 0.15.0, and is built against Doodle 0.18.0
This project draws Doodle pictures to SVG, both in the browser using Scala JS and to files on the JVM.
Add the following dependency to your
libraryDependencies += "org.creativescala" %%% "doodle-svg" % "0.15.0"
See the ScalaDoc index for API documentation.
Firstly, bring everything into scope
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
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
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.
The source for these examples is in the repository.