Doodle SVG

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

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.

Examples

The source for these examples is in the repository.

Concentric Circles

Text Positioning

Pulsing Circle

Parametric Spiral

Doodle Canvas→