const paper = require("paper");
const { createCanvas } = require("canvas");
// Create a canvas and set the size
const canvas = createCanvas(800, 600);
// Set the canvas to be the active layer
paper.setup(canvas);
// Create a circle shape
const circle = new paper.Path.Circle({
center: [400, 300],
radius: 50,
fillColor: "red",
});
// Create a square shape
const square = new paper.Path.Rectangle({
point: [300, 200],
size: [100, 100],
fillColor: "blue",
});
// export img
const fs = require("fs");
const out = fs.createWriteStream(__dirname + "/test.png");
const stream = canvas.createPNGStream();
stream.pipe(out);
out.on("finish", () => console.log("The PNG file was created."));