Objects affecting other objects transparency

i’d start with looking up masks. here is an example of something you can do with it

GIF

PImage img;
PGraphics mask;
PVector pos;
PVector vel;

void setup() {
  size(512, 256);
  surface.setSize(512, 256);
  img = loadImage("flowers.png");
  mask = createGraphics(512, 256);  
  pos = new PVector();
  vel = new PVector(random(2), random(2));
}
 
 void draw() {
  background(255);
  pos.add(vel);
  if(pos.x < 0 | pos.x > width)
    vel.x = -vel.x;
  if(pos.y < 0 | pos.y > height)
    vel.y = -vel.y;
   
  mask.beginDraw();
  mask.clear();
  mask.textSize(128);
  mask.text("yoyo", pos.x, pos.y);
  mask.endDraw();
  
  img.mask(mask);
  
  image(img, 0, 0);
 }
2 Likes