Loading

Pbackground

processing

The Pbackground function sets the color used for the background of the processing graphics object.

An image object can also be used as the background for a sketch, although the image's width and height must match that of the processing object. Images used with Pbackground will ignore the current Ptint setting.

The most efficient is to use the raw ARGB format: 0x102030FF means Red 32, Green 48, Blue 255 with alpha=16/255. Alpha 0xFF means fully opaque. When using v1, v2, v3, gray, alpha, Pbackground calls internally Pcolor.

Link to original Processing doc

Pbackground is available since version 1.0.0.

See also

Signatures

Examples

//load a klingon salute png (32x32px) // @preview image "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAABggAAAYIBFx04PQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAMkSURBVFiFrddNqFVVFAfwn/oSv0jtKZqPkiZiHyRpIWka2ixpUpBBhZhgg2jwBk0cFCES4SCIHFQDBbWocBDiwFLoKUWDBBE0sYwSeoZlPTV86ktvg7UPd3veve/ec+/7w2GfdfZee/3PXmuvtTdjYwnWYGqDvqdxEpfwOea0mKsSJuFT1NJzAcuy/kUYxtd4C39hP1ZhA+7rlsDzyfArYhWO4/usvx/X1Ffm9YxsDdexvhsCW3E+kzekiRckeTvOZf2bUv+r6MU+sSoTWxlqNuBXzMPcJA+kdnVqZ2EoGz8LN/AxLmJvIjK/EwJLRAxMED4tCJ1rQWAIt5I8PbXDVQhMxpfC3x+mb6uz/oFMnt2EQC7fwuUqBF7CM3gRj4gt9mTWfwQPCLeUDTYidAU3qxB4EL/gE7EKO/BwmqwgULilmQtyQv+0Ml4mcBF9wv9wNPU/keQzGBRumI2/SwbLcmUCpzEF9yb5pEhAeRwcFW6ZKTJggUYrUpnAj6m9P7U1fGt0HBS7pGywTKiQF+AAroqffLYZgZ8xgsXZtwEsxYxMnpDeW+2CodR+I2JpK87iM1la78mURtKAnMCRNGYFvsIpkeHmZAYnY1oDApewWySj5WKFe0QcPYdj5RUgligncCJNXLihlv4I/siMMXoXrMc6bFR37zQRZ1c1wTsi8HLsx8FMXogXMvkO7MI9SZ4k9n8N75bmek8UsabVsig6vdm3xeopuR3cmeY4pL6lieAdwdtjKS9PyisrGGyEjbgrkyfiOxHoU8ZSLNhv6pJAGZvTvOvaGTwo6v14oRd/imNbWzgsAm+8sFNUxb52FT4Q+WA8sEqU5f4qSi+7/fjVKXpEVT0htmrb6MN/4qDZDd4Q+eDxTpT3ibNBo/tAO1iIf/FRh/oeEhnr/Q50p+IH/O72XFAZ/SIWtlTQmS5W74b6QaYrbEskvtA6KB8V1XJYl5eSMs4mEtewRxxal4nr2VN4TaTZ4la0djyNw0/J8JvpvVZ6booSXdwl5zacpQl6Wg8Bd4vDyXaxTReJonIev4nz32NVDFfBAaP/utkzqEW1K+N/QkDNWuXUcakAAAAASUVORK5CYII=" Pdecode DUP 'Pimg' STORE //decode it 32 32 '2D' PGraphics //new 32x32 Pgraphic //100 100 '2D' PGraphics //will fail. background must be the same size $Pimg Pbackground //set the background image Pencode //render
// @preview image 100 50 '2D' PGraphics //new Pgraphic 127 Pbackground //gray background, no transparency Pencode //render 100 50 '2D' PGraphics //new Pgraphic 255 10 Pbackground //white , alpha 3.9pc ( = 80pc transparent) Pencode //render 100 50 '2D' PGraphics //new Pgraphic 255 127 Pbackground //white , alpha 50pc ( = 80pc transparent) Pencode //render 100 50 '2D' PGraphics //new Pgraphic 255 255 Pbackground //white , alpha 100pc ( = no transparency) Pencode //render 100 50 '2D' PGraphics //new Pgraphic 0xff00ff00 Pbackground //green , alpha 100pc ( no transparency ) Pencode //render