I thought the explained way would help me, but i was wrong.
I won't get along without posting the code.
So I wrote a function which writes text in randomly altering fonts, but the function shall run at start once.
Then the textfont shall only change if i am in the textfield.
/////////////////////////////////////////////////////////////////////////////////////////////////
- PImage grad;
//Counter
int zahl;
int richtung;
//trig
int angle = 50;
float transX;
float transY;
float wGrad;
float hGrad;
color c1 = color(255, 0, 0);
color c2 = color(0, 255, 0 );
PFont[] fontList = new PFont[2];
float linelength;
float abstand;
float fontPosX = 0;
int fontPosY = -250;
int fontSize = 50;
float linienAbstand;
float xPos;
float corrY = 2;
void setup() {
size(800, 600);
smooth();
background(255);
fontPosX = fontSize*.86;
linienAbstand = fontSize* .5;
xPos = width/2;
fontList[0] = loadFont("AntiqueOlive-Roman-70.vlw");
fontList[1] = loadFont("Imago-Book-70.vlw");
//TRIG For the Gradient
transX = (sin(radians(90-angle)))*(sin(radians(angle))*height);
transY = (cos(radians(90-angle)))*(sin(radians(angle))*height);
hGrad = (sin(radians(angle)) * width)+(cos(radians(angle))*height);
wGrad = (cos(radians(angle)) * width)+(sin(radians(angle))*height);
////// INIT COUNTER //////
richtung = -1;
zahl = 500;
}
void draw() {
rectMode(CORNER);
translate(-transX, transY);
rotate(radians(-angle));
//////////////////
grad = generateGradient(c1, c2, (int) wGrad, (int) hGrad);
///////////
image(grad, 0, 0);
fill(255, 200);
noStroke();
rect(0, 0, width*2, height*2);
rotate(radians(angle));
////// POSITION where the Randomness begins /////
if((mouseX <= 481) && (mouseX >= 134)) {
if((mouseY >= 80) && (mouseY<= 134)) {
runBaby();
}
}
}
void runBaby() {
//////COUNTER///////////
if (richtung == -1){
zahl=zahl-10;
if (zahl == 0){
richtung = 1;
}
}
if (richtung == 1){
zahl=zahl+10;
if (zahl == 500){
richtung = -1;
}
}
////////
rectMode(CENTER);
fill(0);
///////////// LETTERS
int x = (int)random(0, 2);
// println(x);
textFont(fontList[x], fontSize);
// textFont(fontList[zeitSchleife], fontSize);
textAlign(CENTER, CENTER);
text("F", xPos + fontPosX, fontPosY);
x = (int)random(0, 2);
// println(x);
textFont(fontList[x], fontSize);
// textFont(fontList[zeitSchleife], fontSize);
text("R", xPos + 2*fontPosX, fontPosY);
x = (int)random(0, 2);
// println(x);
textFont(fontList[x], fontSize);
// textFont(fontList[zeitSchleife], fontSize);
text("O", xPos + 3*fontPosX, fontPosY);
x = (int)random(0, 2);
// println(x);
textFont(fontList[x], fontSize);
// textFont(fontList[zeitSchleife], fontSize);
text("U", xPos + 4*fontPosX, fontPosY);
x = (int)random(0, 2);
// println(x);
textFont(fontList[x], fontSize);
// textFont(fontList[zeitSchleife], fontSize);
text("T", xPos + 5*fontPosX, fontPosY);
x = (int)random(0, 2);
// println(x);
textFont(fontList[x], fontSize);
// textFont(fontList[zeitSchleife], fontSize);
text("E", xPos + 6*fontPosX, fontPosY);
x = (int)random(0, 2);
textFont(fontList[x], fontSize);
text("6", xPos + 7*fontPosX+15, fontPosY-corrY);
x = (int)random(0, 2);
textFont(fontList[x], fontSize);
text("6", xPos + 8*fontPosX+15, fontPosY-corrY);
}
// Generate a vertical gradient image
PImage generateGradient(color top, color bottom, int w, int h) {
int tR = (top >> 16) & 0xFF;
int tG = (top >> 8) & 0xFF;
int tB = top & 0xFF;
int bR = (bottom >> 16) & 0xFF;
int bG = (bottom >> 8) & 0xFF;
int bB = bottom & 0xFF;
PImage bg = createImage(w, h, RGB);
bg.loadPixels();
for (int i=0; i < bg.pixels.length; i++) {
int y = i/bg.width;
//float n = y/(float)bg.height;
// for a horizontal gradient:
float n = y/(float)bg.width;
bg.pixels[i] = color(
lerp(tR, bR+zahl, n),
lerp(tG, bG+zahl, n),
lerp(tB, bB, n),
255);
}
bg.updatePixels();
return bg;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
Is there a way to do it by code?
loop - noLopp doesnt make sense for me.
PS: To run the sketch you should create 2 fonts ("XXXXX.vlw") and insert them instead of mine in the fontList Array, afterwards move the mouse in the in the textfield. near the upper left corner.
AND PLEEEEASE HELP ME.