Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create transparent canvas

I am developing a paint brush application in javascript using processing.js It is using a canvas object. I want to keep an image at the background of the canvas. Draw something in the foreground. And while saving i need to get only foreground data.

For that we need to make canvas object transparent so that background image is visible.

I don't see any option to make the canvas transparent. How do I do that?

like image 749
Soft Avatar asked Feb 13 '10 01:02

Soft


People also ask

Can a canvas be transparent?

Canvases are transparent by default. Try setting a page background image, and then put a canvas over it. If nothing is drawn on the canvas, you can fully see the page background. Think of a canvas as like painting on a glass plate.

Can I make a Canva with transparent background?

Download designs with transparent backgroundsWith Canva Pro, simply choose PNG, then click the box with the transparent background option. Now you're ready to place your design anywhere –over other images, as branding on all your social posts, or even on a mug.


1 Answers

Even better, at the top of your pjs just put:

/* @pjs transparent=true; */

... and then in your draw loop:

background(0, 0, 0, 0);

voila!

like image 138
Jared Avatar answered Oct 05 '22 13:10

Jared