Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 1.4 KB

File metadata and controls

34 lines (27 loc) · 1.4 KB

plotSvg_hello_static Example

The plotSvg_hello_static example shows the simplest possible use of the p5.plotSvg library. The program runs in the p5.js "static mode", and the SVG is exported at the conclusion of setup(). There is no interactivity or animation.

plotSvg_hello_static.png

Code:

// plotSvg_hello_static Example
// Extremely simple demo of using p5.plotSvg to export SVG files.
// Requires https://cdn.jsdelivr.net/npm/p5.plotsvg@latest/lib/p5.plotSvg.js
// 
// Note 1: This sketch will export an SVG at the very moment when you run it. 
// Note 2: This sketch issues many warnings; the following line quiets them:
p5.disableFriendlyErrors = true;

function setup() {
  createCanvas(576, 384); // Postcard size: 6"x4" at 96 dpi
  background(245); 
  noFill();

  beginRecordSvg(this, "plotSvg_hello_static.svg");
  circle(width/2, height/2, 300); 
  ellipse(width/2-60, height/2-40, 30, 50);
  ellipse(width/2+60, height/2-40, 30, 50);
  arc(width/2, height/2+30, 150, 100, 0, PI);
  endRecordSvg();
}