We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I asked a very close question brillantly answered by @jeremydouglas few time ago, now I'd like to have a different duration for each text. In the sketch below the changePhraseTimer() works, but not the changePhraseTimerN(), we don't see the last text and it doesn't loop properly. Could someone help me with this issue please ?! Thanks a lot in advance. L
import generativedesign.*;
import geomerative.*;
// List of a list of points. 1rst the numbre of phrases: 4, the 2nd indicate the number of points
RPoint[][] myPoints = new RPoint[5][0];
RFont font;
PFont f;
Attractor attractor;
String [][] phraseSets = new String [4][0];
String [] FR1 = {
"On me dit de te haïr et je m'y efforce",
"Je t'imagine cruel, violent, implacable",
"Mais à te voir je n'ai bientôt plus de force",
"Et de te blesser je suis bien incapable",
};
String [] FR2 = {
"Tous mes camarades combattent avec rage",
"Et pleurent la nuit au souvenir des supplices",
"Infligés à leurs frères qui sont du même âge",
"Et rêvent comme eux de toucher une peau lisse"
};
String [] FR3 =
{"Et de pouvoir enfin caresser des obus",
"Autres que ceux produits par le pouvoir obtus",
"Je rêve de quitter ces boyaux infernaux"
};
String [] FR4 = {
"De laisser ces furieux des deux bords du Rhin",
"Et de pouvoir embrasser ta chute de rein",
"Et porter notre amour sur les fonts baptismaux"
};
//TEXT
final color textColor = color(245);
int fontSize;
// TIME
int startTime;
int initTime;
int lineSpacing;
int index;
int state;
float duration;
int dur1;
//----------------SETUP---------------------------------------------------------------------------------------
void setup() {
size(1920, 1080, JAVA2D);
//add phrases to list
phraseSets[0]=FR1;
phraseSets[1]=FR2;
phraseSets[2]=FR3;
phraseSets[3]=FR4;
smooth();
RG.init(this);
font = new RFont("FreeSans.ttf", 86, CENTER);
stroke(textColor);
strokeWeight(0.05);
//INIT
drawPhrases(phraseSets[0]);
// TIME
startTime=millis();
initTime=millis();
index=0;
lineSpacing =150;
}
//----------------DRAW----------------------------------------------------------------------------------
void draw() {
background(255);
state =0;
// TEXTS
// draw on the center of the screen
translate(width/2, height/2);
// draw phrases vertically centered by moving the top up by half the line spaces
translate(0, -1.0*lineSpacing*(phraseSets[index].length-1)/2.0);
// loop through lines
for (int i=0; i< myPoints.length; i++) {
// draw a line
for (int j=0; j< myPoints[i].length-1; j++) {
pushMatrix();
translate(myPoints[i][j].x, myPoints[i][j].y);
noFill();
stroke(0, 200);
strokeWeight(0.25);
float angle = TWO_PI*10;
rotate(j/angle);
bezier(-2*(noise(10)), 10, 25*(noise(10)), -5, 2*noise(5), -15, 10, -3);
//bezier(-10*(noise(20))+mouseX/15, 30+mouseY/10, -10*(noise(10))+mouseX/15, 20+mouseY/15, -20*noise(20)+mouseX/15, -20+mouseY/5, 10+mouseX/15, -10+mouseY/15);
popMatrix();
}
// move to the next line
translate(0, lineSpacing);
}
//check Timer and redraw phrases if time has passed
changePhraseTimerN();
//changePhraseTimer(duration*4, phraseSets);
}
//----------------INITIALIZE----------------------------------------------------------------------------------------------------------------------------------------
void drawPhrases(String [] phrases) {
myPoints = new RPoint[phrases.length][0];
for (int j=0; j<phrases.length; j++) {
RGroup myGroup = font.toGroup(phrases[j]);
myGroup = myGroup.toPolygonGroup();
myPoints[j] = myGroup.getPoints();
}
}
//----------------TIMER----------------------------------------------------------------------------------------------------------------------------------------
/*void changePhraseTimer( float duration, String [][] phraseSets) {
duration = sounds[0].length()-150;
if (millis()-startTime > duration*4) {
index =(index+1) % phraseSets.length;
//drawPhrases(phraseSets[index]);
//startTime = millis();
}
}*/
void changePhraseTimerN() {
dur1=11500;
if (millis()-startTime > dur1+1400) {
index =(index+1) % phraseSets[1].length;
drawPhrases(phraseSets[index]);
startTime= millis();
} else if (millis()-startTime > dur1-800) {
index =(index+1) % phraseSets[2].length;
drawPhrases(phraseSets[index]);
startTime= millis();
} else if (millis()-startTime > dur1+1000) {
index =(index+1) % phraseSets[3].length;
drawPhrases(phraseSets[index]);
startTime= millis();
} else if (millis()-startTime > dur1*2-8000) {
drawPhrases(phraseSets[0]);
startTime= millis();
}
}
//----------------TEXT ATTRACTOR INIT----------------------------------------------------------------------------------------------------------------------------------------
void initAttractor(int i) {
if (i>=4 && i<8) {
i-=4;
} else if (i>=8 && i<11) {
i-=8;
} else if (i>=11 && i<14) {
i-=11;
} else if (i>14) {
i=0;
}
float x = 0;
float y =-50;
// println(i);
attractor = new Attractor(x, y, myPoints[i]);
}
class Attractor {
float force_radious = 100;
float maxForce = 15;
RPoint position;
RPoint[] points;
Attractor(float x, float y, RPoint[] p) {
points = p;
position = new RPoint(x, y);
}
void attract() {
for (int i =0; i < points.length; i++) {
float d= points[i].dist(position);
// println ("d : "+d);
if (d < force_radious) {
RPoint desired = new RPoint(points[i]);
//points[i]= new RPoint(points[i]);
//println( "avant x : "+ points[i].x +" y: "+points[i].y);
desired.sub(position);
desired.normalize();
desired.scale(map(d, 0, force_radious, maxForce, 0));
points[i].add(desired);
//println( "après x : "+ points[i].x +" y: "+points[i].y);
}
}
}
void display () {
stroke(0);
strokeWeight(2);
// ellipse (position.x, position.y-750, 30, 30);
}
void moveTo(float x, float y){
position.x=x;
position.y=y;
}
}
Answers
There is a new forum
Why not ask there?
Thank you chrisir, yes good idea, how can I access to the new forum please?! Except if you have a bit of time to help me now ;)) !!
https://discourse.processing.org/
Dear Chrisir, my browser doesn't allow me to go on the new forum... It's so frustrating! Days I don't find a solution to my stupid error!! :((
I think there is also an app for the new forum
What if you kill these lines
startTime= millis();
in
changePhraseTimerN()
Thanks Chrisir for your answer, I finally manage to find a way to make a timer that allows me to switch from a stanza to the next according to different time variables. But it's just a part of a larger sketch where I deform the text with an attractor. The attractor works but the text goes back to ist original form immediately... Don't know why. I can send you the code if you want...?!
Dear Chrisir, I've switched to the new forum an asked my question there... https://discourse.processing.org/t/how-to-deform-a-text-generated-with-thegeomerative-library/1147 I hope someone will be able to help me. Thanks a lot for your help, as usual ;)) best, L
You are welcome!
;-)
Still no solution unfortunately !... :-O
Sorry I missed the ping -- @jeremydouglass - not @jeremydouglas. Glad the past thread on timed text was helpful. Will follow up on the new forum soon.
Oups sorry, my mistake! Thanks to reply.Yes the past thread on timed text was very helpful, but since I've changed my mind ...! See you on the new forum and thank you for your help ;))
Continue discussion here: https://discourse.processing.org/t/how-to-deform-a-text-generated-with-thegeomerative-library/1147
Kf
yep I am there, I've posted a simple version of the sketch...Thanks!