Pencode


processing
Since v1.0.0
Available on all platforms
See also

Pencode function takes a processing graphic object on the top of the stack, render it to a png file, encode it in base64, prefix the result with the standard png header "data:image/png;base64,".

The resulting string is ready to use in an html document.

Signature

Examples

//simple example // @preview image 200 150 '2D' PGraphics //new image instance, 200x150 pixels 0xffffff6c Pbackground //yellow background 3 PstrokeWeight //stroke width 3pixels 0xff0000ff Pstroke //blue stroke (ARGB color) 0x7fff0000 Pfill //semi transparent red fill 10 30 100 50 Prect //draw a rectangle, left corner 10 30, size 100 50 20 PtextSize //set text size to 20pt 0xffff0000 Pfill //red fill "Hello" 10 100 Ptext //text, bottom left at 10 100. Pencode //render the image in a base64 format on the stack