Loading

PtextWidth

processing

Calculates and returns the width of any character or text string.

Link to original Processing doc

PtextWidth is available since version 1.0.0.

See also

Signatures

Examples

// @preview image 200 200 '2D' PGraphics 255 Pbackground 0xff0000ff Pstroke //blue 0xffff0000 Pfill //red //will draw a box around the text with a 3px margin 'Warp 10' 'mytext' STORE 30 'fontsize' STORE 'CENTER' 'CENTER' PtextAlign 'CENTER' PrectMode $fontsize PtextSize PtextDescent 'a' STORE $mytext 100 100 $a - Ptext $mytext PtextWidth 'w' STORE PnoFill 100 100 $w 6 + $fontsize 6 + Prect Pencode