tiny-svg 1.0.1

Tiny SVG library for drawing and quick experiments


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

<img src="imgs/icon-tsvg.png" width="95" height="52" align="left"></img>

Tiny SVG

A tiny SVG library for drawing and quick experiments. No dependencies.

Library

Add library to your project using DUB:

dub add tiny-svg

Or copy the following to your DUB configuration file:

// dub.json
"tiny-svg": "~>1.0.0"

// dub.sdl
dependency "tiny-svg" version="~>1.0.0"

Example

import rk.tsvg.canvas;

SVGCanvas canvas = SVGCanvas(240, 240);

// create a radial gradient
new RadialGradient("rg0", Colors.gold, Colors.orange)
    .setOpacityA(0.4)
    .setOpacityB(0.9)
    .addToCanvas(canvas);

// draw
new Rectangle(0, 0, canvas.width, canvas.height)
    .setStrokeColor(Colors.blue)
    .setStrokeWidth(0)
    .setRadius(24)
    .setGradient("rg0")
    .addToCanvas(canvas);

new Circle(canvas.width / 3, canvas.height / 3, 24)
    .setFillColor(Colors.white)
    .addToCanvas(canvas);

new Circle(canvas.width * 2 / 3, canvas.height / 3, 24)
    .setFillColor(Colors.white)
    .addToCanvas(canvas);

new Curve(canvas.width / 3, canvas.height * 2 / 3, canvas.width * 2 / 3, canvas.height * 2 / 3)
    .setFillColor(Colors.white)
    .addToCanvas(canvas);

// save
canvas.save("examples/example.svg");

Output:

<img src="examples/example.svg" width="240">

Examples

Origami bird

<img src="examples/origami_bird.svg" width="720">

Albatros

<img src="examples/albatros.svg" width="720">

Code can be found here.

LICENSE

All code is licensed under the BSL license.

Authors:
  • rillki
Dependencies:
none
Versions:
1.0.1 2023-Aug-09
1.0.0 2023-Aug-03
~main 2023-Dec-06
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 18 downloads total

Score:
0.3
Short URL:
tiny-svg.dub.pm