We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › geomerative: update text
Page Index Toggle Pages: 1
geomerative: update text? (Read 451 times)
geomerative: update text?
Mar 3rd, 2009, 10:43pm
 
Hi everybody,
I try to write a program which seperates a text in asceders and descenders to manipulate their y position by user interaction.
Therefore I use the geomerative library to get an array of points which are seperated by threshold, in a for-loop.

Now there is one big problem:
I don`t figured out how to update the text.
Within the for-loop the array of points is redefined and in the example they are drawn as blue and red ellipses(with correct mouse interaction), but I don`t know how to rebuild the text with these modified points.

If I change the polygonizer mode to adaptative, the original text is modified, but in a very uncontrolled way (or a way I don`t understand).

Now the question is, how to build the text with these points? or what other parameters accessible through the geomerative library I could use to update the original text?

I haven`t found any solution and I don`t even know what to search for, so I would be very grateful if somebody could give me a hint.



here is the example code:

import geomerative.*;

RFont f;
RShape grp;
RPoint[] points;

void setup() {
 size(800,600);
 frameRate(25);
 smooth();
 RG.init(this);
 grp = RG.getText("lakögfaty", "MYRIADPS.TTF", 70, CENTER);
}

void draw() {
 translate(width/2,height/2);

 noStroke();
 fill(0);
 background(255);
 grp.draw();

 RG.setPolygonizer(RG.UNIFORMLENGTH);
 points = grp.getPoints();

 for (int i = 0; i < points.length; i++){
   int move = mouseY;

   if (points[i].y < -50){
     fill(0,0,255);
     points[i].y = points[i].y + move-height/2;

   }
   else if (points[i].y > 5){
     fill(255,0,0);
     points[i].y = points[i].y + move;
   }

   ellipseMode(CENTER);
   ellipse(points[i].x,points[i].y,2,2);

 }
}
Re: geomerative: update text?
Reply #1 - Mar 4th, 2009, 12:27am
 
Yep, I'll have to work a bit on the doc and the implementation of the getPoints etc. methods to make them behave equally.

The points these methods return are (or at least should be) always new points and not the actual points of the shape.
The solution to your problem is to create a new shape using those modified points.
So I have added a method to the lib to make this easy: RG.createShape(RPoint[][] points)

NOTE:  You will need revision 24 of geomerative at http://www.ricardmarxer.com/geomerative

Furthermore since you want to maintain the hierarchy of the shapes (the holes) you will need to use getPointsInPaths() instead of getPoints()

Here is the corrected sketch:
Code:

import geomerative.*;

RFont f;
RShape grp;
RPoint[][] pathPoints;

void setup() {
size(800,600);
frameRate(25);
smooth();
RG.init(this);
grp = RG.getText("lakögfaty", "MYRAIDPS.TTF", 70, CENTER);
}

void draw() {
translate(width/2,height/2);

noStroke();
fill(0);
background(255);
//grp.draw();

RG.setPolygonizer(RG.UNIFORMLENGTH);
pathPoints = grp.getPointsInPaths();

for (int j = 0; j < pathPoints.length; j++){
RPoint[] points = pathPoints[j];

for (int i = 0; i < points.length; i++){
int move = mouseY-height/2;

if (points[i].y < -50){
fill(0,0,255);
points[i].y = points[i].y + move;

}
else if (points[i].y > 5){
fill(255,0,0);
points[i].y = points[i].y - move;
}

ellipseMode(CENTER);
ellipse(points[i].x,points[i].y,2,2);

}
}

stroke(0);

RShape newshp = RG.createShape( pathPoints );
RG.shape( newshp );
}


I have modified a bit the sketch to make it work in a way I understand it better.  By the way I like the idea a lot!!
Re: geomerative: update text?
Reply #2 - Mar 4th, 2009, 1:05am
 
Thank you very much, Ricard.
That was a great help!

If I can handle it, this sketch should become a kind of equalizer for typography.
With this equalizer, the user should be able to play with typefaces and
maybe create their own.
Page Index Toggle Pages: 1