Skip to content

Latest commit

 

History

History
107 lines (74 loc) · 6.63 KB

README.md

File metadata and controls

107 lines (74 loc) · 6.63 KB

Generating SVG Files

Introduction

SVG ("Scalable Vector Graphic") files are text files that contain descriptions of geometry. Paths in SVG files are defined as sequences of points (though elliptical arcs and Bezier curves are also possible), which makes them very suitable for controlling pen plotters. Here is an SVG file, and its code:

<svg version="1.1"
	width="400" height="400"
	xmlns="http://www.w3.org/2000/svg">

	<rect width="100%" height="100%" fill="lightgray" />

	<circle cx="100" cy="100" r="80" fill="white" />

	<path fill="none" stroke="black" stroke-width="1.0px" d="
		M100 100 
		L300 100 
		L250 300 
		Z" />
</svg>

Toolchains

You could write code to directly generate SVG text files, but if you wish to preview your work, you would likely use a creative-coding toolkit. Here are some links and example projects for various toolkits for computationally generating SVG files.

Java

JavaScript

Python

C++


Other SVG Tools

  • Huge list of SVG tools at Drawingbots.net
  • vpype, which can
    • layout vector files with precise control of position & scale
    • optimize existing SVG files for faster and cleaner plots;
    • create HPGL output for vintage plotters;
    • create generative artwork from scratch;
    • create, modify and process multi-layer vector files for multi-colour plots; etc.
  • Occult, vpype plug-in to remove lines occulted by polygons from SVG files.
  • Deduplicate, vpype plug-in to remove overlapping lines in SVG files.
  • Shapely, a Python package for manipulation and analysis of planar geometric objects.

SVG Readymades

We will generally not be using others' "readymade" SVG generators, but it's good to be aware of the kinds of free tools that people make.

  • SVG Crowbar, a Chrome-specific bookmarklet that extracts SVG nodes and accompanying styles from an HTML document and downloads them as an SVG file.
  • Potrace, a NodeJS-compatible JavaScript tool for tracing bitmaps.
  • Flowchart.fun, a tool that generates SVGs of flowcharts from structured text
  • City Map Generator, a readymade tool by @probabletrain for creating procedural city maps in the browser
  • flow-lines by @msurguy, a readymade tool for generating SVGs of flow fields
  • rad-lines by @msurguy, a readymade tool for generating SVGs of rotating patterns
  • Great96, a tool for generating Islamic tiling geometric patterns
  • AudioPlotter, a tool for generating SVGs of audio waveforms from sound files
  • DrawingBotV3 a tool to create stylised line drawings from images

Other Programming Toolkits

These are mostly obsolete or experimental.

  • cozyvec by @brubsby is "a tiny terminal program for creating plotter art" with JavaScript.
  • D3.js, "A JavaScript library for manipulating documents based on data", widely used in data visualization. Can export SVG as described here.
  • three.js with its SVGRenderer
  • SnapSVG by Adobe Systems. "A JavaScript SVG library for the modern web", possibly no longer maintained.
  • svgwrite by @mozman is "a Python library to create SVG drawings." Currently in maintenance mode.
  • drawSvg, a Python 3 library for programmatically generating SVG images (vector drawings) and rendering them or displaying them in a Jupyter notebook.
  • NodeBox, by Frederik De Bleser, is "an interactive Python environment where you can create two-dimensional graphics", and a fork of Drawbot. Possibly no longer maintained.