mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Alpha Mask.
|
||||
*
|
||||
* Loads a "mask" for an image to specify the transparency
|
||||
* in different parts of the image. The two images are blended
|
||||
* together using the mask() method of PImage.
|
||||
*/
|
||||
|
||||
PImage img;
|
||||
PImage maskImg;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
img = loadImage("test.jpg");
|
||||
maskImg = loadImage("mask.jpg");
|
||||
img.mask(maskImg);
|
||||
imageMode(CENTER);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(map(mouseX+mouseY, 0, width+height, 0, 255));
|
||||
image(img, width/2, height/2);
|
||||
image(img, mouseX, mouseY);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Alphamask extends PApplet {
|
||||
|
||||
/**
|
||||
* Alpha Mask.
|
||||
*
|
||||
* Loads a "mask" for an image to specify the transparency
|
||||
* in different parts of the image. The two images are blended
|
||||
* together using the mask() method of PImage.
|
||||
*/
|
||||
|
||||
PImage img;
|
||||
PImage maskImg;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200,200);
|
||||
img = loadImage("test.jpg");
|
||||
maskImg = loadImage("mask.jpg");
|
||||
img.mask(maskImg);
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background((mouseX+mouseY)/1.5f);
|
||||
image(img, 50, 50);
|
||||
image(img, mouseX-50, mouseY-50);
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Alphamask" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Alpha Mask.
|
||||
*
|
||||
* Loads a "mask" for an image to specify the transparency
|
||||
* in different parts of the image. The two images are blended
|
||||
* together using the mask() method of PImage.
|
||||
*/
|
||||
|
||||
PImage img;
|
||||
PImage maskImg;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200,200);
|
||||
img = loadImage("test.jpg");
|
||||
maskImg = loadImage("mask.jpg");
|
||||
img.mask(maskImg);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background((mouseX+mouseY)/1.5);
|
||||
image(img, 50, 50);
|
||||
image(img, mouseX-50, mouseY-50);
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Reference in New Issue
Block a user