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
It’s OK to copy/paste from website. Then let’s revise…
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); //starts with no transparency.
image(img, 100, 80);
if ((transparency < 0) || (transparency >255) ){
speed = speed * -1;
}
println(transparency);
}
Install Video Library
Click to sign up for �Show & Tell
Use the textbook or online tutorials to learn more about rotation. With your teammate, create a more embellished version of this vector scene. In addition to the aesthetics, the important programming functions are: translate, rotate, pop, and push. Specifically, you will:
(Try to animate the blades and sun rays when the program runs.)
Click to sign up for �Show & Tell
Slideshow/Gallery
Using either Example 15-3 or 15-4 as a model, create a slideshow. Here are some specifics:
Submit by zipping it up and uploading to a folder called �“Headroll Classwork”
An example is shown below.
Task: Program a sketch where your head rotates across the canvas and keeps looping around as in Example 15-2.