Using rects as masks.
in
Programming Questions
•
8 months ago
Hello i've been trying to get my 2 rect to act as masks for 3 underlying images.
At first i've tried to fill them with the image but I dont want any scaling so I was thinking masks might be better.
I hope someone can help me!
At first i've tried to fill them with the image but I dont want any scaling so I was thinking masks might be better.
I hope someone can help me!
Here's my code so far. Thanks!
PFont z;
final static byte numVars = 4;
final static float[] vars = new float[numVars];
final static byte marginX = 25, marginY = 50;
final static color bg = 120;
PImage img;
void setup() {
size(600, 400);
frameRate(10);
z = loadFont( "Andalus-48.vlw" );
stroke(-1);
String[] data = loadStrings("data.txt");
for ( int i=0; i!=numVars; vars[i] = float(data[i++]) );
}
void draw() {
textFont(z,16);
fill(0);
img = loadImage("Civil_Ensign_of_Luxembourg.bmp");
float e, f, g, h, i, j;
e = vars[0] + vars[1];
f = vars[0]/e * (width-marginY);
g = vars[1]/e * (width-marginY);
h = vars[2] + vars[3];
i = vars[2]/h * (height-marginY);
j = vars[3]/h * (height-marginY);
String[] data = loadStrings("data.txt");
for ( int k=0; k!=numVars; vars[k] = float(data[k++]) );
background(bg);
fill(80,255,80);
rect(marginX, marginX, f, height-marginY);
fill(255,80,80);
rect(f+marginX, marginX, g, i);
fill(255,110,110);
rect(f+marginX, i+marginX, g, j);
fill (0);
text ( ""+vars[0]+"" ,marginX+10,marginY+10);
text ( ""+vars[1]+"" ,f+40,marginY+10);
text ( ""+vars[2]+"" ,f+60,i+10);
text ( ""+vars[3]+"" ,f+60,i+50);
}
1