UNPKG

p5.js-svg

Version:

The main goal of p5.SVG is to provide a SVG runtime for p5.js, so that we can draw using p5's powerful API in \<svg\>, save things to svg file and manipulating existing SVG file without rasterization.

35 lines (28 loc) 806 B
import { P5SVG, P5, P5Global, SVGElement, SVG, p5SVG } from './types' import RendererSVG from './p5.RendererSVG' import SVGFiters from './p5.SVGFilters' import Rendering from './rendering' import IO from './io' import Image from './image' import Element from './element' import Filters from './filters' import constants from './constants' function init(p5: P5) { const p5svg = p5 as unknown as P5SVG RendererSVG(p5svg) SVGFiters(p5svg) Rendering(p5svg) IO(p5svg) Image(p5svg) Filters(p5svg) Element(p5svg) // attach constants to p5 instance p5svg.prototype['SVG'] = constants.SVG return p5svg } const global = window as unknown as P5Global if (typeof global.p5 !== 'undefined') { init(global.p5) } export default init export { SVGElement, SVG, p5SVG }