CHAPTER 15: IMAGES
SECTIONS 1, 2, 3
GETTING STARTED
4 steps to draw an image to the screen.
PImage is a class for loading and displaying an image.
PRACTICE ACTIVITY
To get the image:
Other considerations
RESIZING AN IMAGE
ANIMATE - This is what we’ll do in Example 15-2
ANOTHER PRACTICE EXERCISE
SYNTAX OF TINT AND ALPHA
1 argument: tint(brightness)
2 arguments: tint(brightness, alpha)
3 arguments: tint(r, g, b)
4 arguments: tint(r, g, b, alpha)
Alpha is from 0-255, where:
0 is completely transparent
255 is completely opaque
About Alpha
Tint
First Example
Original
tint(255, 100);
Shows rainbow row behind waterfront pineapple.
Brightness and alpha
Another Example:
tint(255, 0, 0);
Or
tint(#FF0000);
Shows a red tint with no transparency
Another Example:
background(0);
tint(0,200,255 );
…blue/green with no transparency
background(0);
tint(0,200,255,50);
…blue/green with high transparency against black background.
INTERESTING COMPARISON TO “THE BOUNCING BALL”
//see page 86. Reverse polarity
PImage img;
float transparency = 255;
float speed = 1;
void setup() {
size(400, 400);
img = loadImage("flower_red.png");
}
void draw() {
background(0);
transparency = transparency - speed;
tint(255, transparency);
image(img, 100, 80);
if ((transparency < 0) || (transparency >255) ){
speed = speed * -1;
}
println(transparency);
}
Install Video Library