i try with subtracting
- a (white) text ( with transparent background )
from
- a image as transparent
on pixel level
with a dynamic background show can see what part is transparent
String mytext = "Hallo World";
PGraphics my_tt; //my_trans_text;
PImage my_btt;
int bw=180, bh=40;
int ck = 0;
void make_my_tt() { // only text
my_tt = createGraphics(bw, bh);
my_tt.beginDraw();
my_tt.fill(255, 255, 255); // in white
my_tt.textSize(30);
my_tt.text(mytext, 7, 30);
my_tt.endDraw();
}
void make_my_btt() {
my_btt = createImage(bw, bh, ARGB);
for (int y = 0; y < my_btt.height; y++) {
for (int x = 0; x < my_btt.width; x++) {
color ctt = my_tt.get(x, y);
if ( red(ctt) >= 255 ) my_btt.set(x, y, color(0, 0, 0, 0) ); // and set pixel transparent
else my_btt.set(x, y, color(0, 0, 255, 255) ); // set background
}
}
}
void draw_background_show() {
fill(0, 200, 0);
stroke(200,0,0); // noStroke();
circle(width/2, height/2, ck);
ck++;
if ( ck > width ) ck = 0;
}
void setup() {
size(200, 200);
make_my_tt();
make_my_btt();
}
void draw () {
background(200, 200, 0);
draw_background_show();
image(my_tt, 10, 10);
image(my_btt, 10, 110);
}
there might be much smarter ways, but this should do for a first test.
other test combine with mirror: