Chapter 15, Images …a few points
Getting Started PImage is a class for loading and displaying an image. 4 steps to draw an image to the screen. Add file to data folder Create the PImage variable Load the image into the variable with loadImage() Draw the image image() function
Activity Practice Example 15-1. Use image of your own. To get the image: Drag file into Processing window, or Click SKETCH>Add file, or Create the data folder and add file manually. Practice Example 15-1. Use image of your own. Next, control the height & width with the mouse. Other considerations The files accepted are GIF, JPG, PNG & TGA Spaces are OK, but the file name is case sensitive.
Animate Use translate, increment, and rotate to animate an image. Remember that rotate is measured in radians. Also, change mode to rectMode(CENTER).
Another Practice Exercise Open your Example 15-2 and let’s examine code. Use your own picture from www.pngimg.com or ww.freepngimg.com For a remix, add JPG picture as background() Use a for() loop to repeat a PNG picture across width of the screen.
All About Tinting Tint is essentially equivalent to fill(), setting the color and alpha transparency. Functions are tint() and noTint() Example: tint(0, 255, 0, 127) will give green tint with 50% opacity You can also use hexadecimal colors, e.g. tint(#FF0000, 50) will be a red tint, with near complete transparency.
Syntax of Tint and Alpha Alpha is from 0-255, where: 0 is completely transparent 255 is completely opaque Alpha tint(r, g, b) tint(r, g, b, alpha) tint(gray) tint(gray, alpha) Tint
First Example Original tint(255, 100); That is… Shows rainbow row behind waterfront pineapple. That is… white for NO color change, and 100 for partial transparency
Another Example: tint(255, 0, 0); Or tint(#FF0000); Shows a red tint with no transparency
Another Example: background(0); tint(0,200,255 ); background(0); …blue/green with no transparency background(0); tint(0,200,255,50); …blue/green with high transparency against black background.