Skip to content

Instantly share code, notes, and snippets.

@nataliefreed
Created February 9, 2019 15:44
Show Gist options
  • Save nataliefreed/363effc3da3f646a8e77d266cd9617be to your computer and use it in GitHub Desktop.
Save nataliefreed/363effc3da3f646a8e77d266cd9617be to your computer and use it in GitHub Desktop.
//This example saves out two images of a star,
//a PNG (bitmap/raster) and a SVG (vector)
//SVG export: http://processing.org/reference/libraries/svg/
import processing.svg.*;
size(300, 300);
//begin creating the SVG
beginRecord(SVG, "vector.svg");
strokeWeight(6); //wider line
noFill(); //no fill color
//connect-the-dots star
beginShape();
vertex(90, 230);
vertex(251,112);
vertex(51, 112);
vertex(213, 229);
vertex(151, 39);
vertex(90, 230);
endShape(CLOSE);
//record and save the bitmap image
saveFrame("bitmap.png");
//record and save the SVG
//note: depends on corresponding beginRecord!
endRecord();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment