Initial Commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Transparency.
|
||||
*
|
||||
* Move the pointer left and right across the image to change
|
||||
* its position. This program overlays one image over another
|
||||
* by modifying the alpha value of the image with the tint() function.
|
||||
*/
|
||||
|
||||
PImage img;
|
||||
float offset = 0;
|
||||
float easing = 0.05;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
img = loadImage("moonwalk.jpg"); // Load an image into the program
|
||||
}
|
||||
|
||||
void draw() {
|
||||
image(img, 0, 0); // Display at full opacity
|
||||
float dx = (mouseX-img.width/2) - offset;
|
||||
offset += dx * easing;
|
||||
tint(255, 127); // Display at half opacity
|
||||
image(img, offset, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 117 KiB |
Reference in New Issue
Block a user