@raphael_tillman
In p5.js, you can use the saveCanvas()
function to save the canvas (which includes the image) to a specific directory on your computer. Here's an example of how you can save an image to a specific directory:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
function setup() { createCanvas(400, 400); background(220); } function draw() { // Draw something on the canvas ellipse(200, 200, 100, 100); // Save the canvas to a specific directory saveCanvas("myImage", "png", true, saveCallback, "myImageOutputDirectory"); } function saveCallback() { console.log("Image saved successfully."); } |
In the example above, the saveCanvas()
function is used to save the canvas as an image in PNG format to the directory named "myImageOutputDirectory". The saveCallback
function is optional and will be called after the image is saved. You can replace "myImageOutputDirectory" with the path of the directory where you want to save the image.