Loading

Ptint


processing
Since v1.0.0
Available on all platforms
See also

Sets the fill value for displaying images. Images can be tinted to specified colors or made transparent by including an alpha value.

To apply transparency to an image without affecting its color, use white as the tint color and specify an alpha value. For instance, tint(255, 128) will make an image 50pc transparent (assuming the default alpha range of 0-255, which can be changed with PcolorMode).

The value for the gray parameter must be less than or equal to the current maximum value as specified by PcolorMode. The default maximum value is 255.

Link to original Processing doc

Signature

Examples

// @preview image 200 100 '2D' PGraphics DUP 'Pg' STORE //new 200x100 image 0xff000000 Pbackground //black background 'CORNER' PimageMode //set Pimage mode to centered //load a white klingon salute png "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAABggAAAYIBFx04PQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANuSURBVFiFrZdLiJZlFMd/xxnFS9RMYzcHkyLELijdkMpRol3SpiAFEzGhVi5m0aZNhETELIKoRbUoiIosFzFEdKVRioKCQRgVb5jQTIxaMxqaTs6vxft89Pj2znzvNzNn83znObf/d57zPOe8MA2pa9SH1UUVskfVIXVc3a0unc5XS6S2qR/6H42q92byleoF9Sv1BfW02q/2qNvUW2YL4MkU+OmUhUH1x0zeq/7dyIy60yvporppNgB2qSMZvy05Xpb4PvVkJt+R5M+qXeqelJV5zWJNpXACuEG9LvEDaV2f1g5gLNPvAC4Bb0fEGeB9oAu4sWUA6hqgDQigByAiTgAnmwAYi4jJxC9J64XaANQF6qfAIPBm2l6f6Q5kfGcVgBI/CZytDQB4CngM2ALcDQwBGzL5XuCOdCzlgFWAzkXE5VYA3Akcj4gPImIQeANYrXZkABrHUnkEJUB/NgteBnAG6FbbEr8vydcBRMRhYJjiGDqBP0oBy3zLAA4BC4GbEz8EjHJlHeyjOJZrgPFsvyojLQM4mNbbASJC4Hv+XweNW1IOWAY0DqAuUz9Tz6uH1MenAnAUmABWZXsDwD3qVRkf6XezWzCW6uc7YDWwCzgGfJQ/6+2NHxExoR4rAdibdB4EvgQOAKeBpY2A6gJg8RQZeY/iMVobEQfVdoo6egL4pZwBKOogB7A/Od6QQJr+EcDvWbByRjqBTcBGYHtENI53MUWdnaeK1JfV0dJev/pFxq9QN2f8fPVddXni29TLqTe8UvL1ampi1d0yazpd2d4qtafSoNrH1cnH19mVbswWE+qL0xmvTcYP1Q04hZ/t6rUZP0/9QT2qLqyDfsdsAFT4fSb53VhHeVjtm8PgXeopdXddg2/U/jkE8I56Vu2ua/B6eg/mIniPOqn2tmK0NR+/ZhG83WKW3K/Ob8WwW/1H3TlLAM+l9+CBmRjvUY9b8T1Q036F+pf61kzsUe9KL9ZrM7BdpP6s/pa/BTMB0Ztq4fkWbJak7F1S1804eObwpQTi42ZFqd6nHrD4Yqr9URLNFNKVvBW4CHwCfE7RNc8Byym65xagUWyPRMS3cwngCPATcBjYCtxWUpmkGNVGgM3A9RFxqi6A9uYqANxEMZz0Ad3ASoq+PgL8SjH/3V83aEtkMc/VpeFpu10F/QvGQ+9Q7nwO8wAAAABJRU5ErkJggg==" Pdecode 'salute' STORE //decode it, store it $salute 0 20 Pimage //paste 255 0 0 Ptint //red $salute 32 20 Pimage //paste 200 Ptint //light gray $salute 64 20 Pimage //paste 255 127 Ptint //white (no color change), with 50pc transparency $salute 96 20 Pimage //paste 0 255 255 255 Ptint //cyan 100pc opaque $salute 128 20 Pimage //paste 0x7f00ffff Ptint //cyan 50pc opaque $salute 160 20 Pimage //paste Pencode //render