With the random function, I have created a simple algorithm to generate a different font type every time I run the program but the font flickers from one font type to the other when I run the program because draw () keeps calling back the random function.
class WordCollage extends InteractiveBoxes {
PFont font1, font2, font3, fontR;
String word1;
// constructor of the Picture Gallery class
WordCollage (int boxPosX, int boxPosY, int boxPosW, int boxPosH) {
super (boxPosX, boxPosY, boxPosW, boxPosH);
font1 = loadFont("VinerHandITC-48.vlw");
font2 = loadFont("SegoeScript-Bold-48.vlw");
font3 = loadFont("BradleyHandITC-48.vlw");
word1=(textbox.getWord());
} // end of the constructor
void display () {
float rF =random(1, 3);
int randomFont=int(rF);
switch(randomFont) {
case 1:
fontR=font1;
break;
case 2:
fontR=font2;
break;
case 3:
fontR=font3;
break;
}
fill(0);
textFont(fontR, 48); // Set the font type and size at
text (word1, 700, 200);
}
}
class WordCollage extends InteractiveBoxes {
PFont font1, font2, font3, fontR;
String word1;
// constructor of the Picture Gallery class
WordCollage (int boxPosX, int boxPosY, int boxPosW, int boxPosH) {
super (boxPosX, boxPosY, boxPosW, boxPosH);
font1 = loadFont("VinerHandITC-48.vlw");
font2 = loadFont("SegoeScript-Bold-48.vlw");
font3 = loadFont("BradleyHandITC-48.vlw");
word1=(textbox.getWord());
} // end of the constructor
void display () {
float rF =random(1, 3);
int randomFont=int(rF);
switch(randomFont) {
case 1:
fontR=font1;
break;
case 2:
fontR=font2;
break;
case 3:
fontR=font3;
break;
}
fill(0);
textFont(fontR, 48); // Set the font type and size at
text (word1, 700, 200);
}
}
1