Geomerative Type
in
Contributed Library Questions
•
1 year ago
Hi guys, I'm trying to make a program that displays one letter at a time depending what key you press on the keyboard and for each letter I have different parameters so when a key is pressed whatever letter is on the screen has to be replaced with the next one. However, I'm still new to processing and can't make it work. Below is the code I have so far. I have a string at the beginning of the sketch with a value "A", because if i leave it blank the program gives me error. So if I run the program and press a key, it puts the character next to the "A" and doesn't replace it. Any ideas of what I'm doing wrong??? Thank you in advance.
V.
import geomerative.*;
RFont font;
RPoint[] myPoints;
String myText="A";
RGroup myGroup;
int i;
void setup() {
size(800, 800, P3D);
background(255);
smooth();
RG.init(this);
font = new RFont("FreeSans.ttf", 500, CENTER);
frameRate(50);
}
void draw() {
noFill();
stroke(0,9);
strokeWeight(0.6);
translate(width/2, height/1.2);
RCommand.setSegmentLength(10);
RCommand.setSegmentator(RCommand.UNIFORMLENGTH);
RGroup myGroup = font.toGroup(myText);
myGroup = myGroup.toPolygonGroup();
RPoint[] myPoints = myGroup.getPoints();
for (int i=0; i<myPoints.length; i++) {
if ((keyPressed == true) && (key =='A' || key=='a')){
beginShape();
vertex(myPoints[i].x,myPoints[i].y);
bezierVertex(90,4,myPoints[i].x*4.75,6,0,myPoints[i].y*(1.3));
bezierVertex(20,-1,myPoints[i].x*2.5,2,10, random(0,40));
endShape();
}
if ((keyPressed == true) && (key =='B' || key=='b')){
beginShape();
vertex(myPoints[i].x,myPoints[i].y*1.2);
bezierVertex(90,-500,myPoints[i].x*(3),6,-90,myPoints[i].y*(1.193));
bezierVertex(20,-20,myPoints[i].x*(2.5),2,10, random(-60,10));
endShape();
}
}
}
void keyPressed() {
if(key !=CODED) {
switch(key) {
case DELETE:
case BACKSPACE:
myText = myText.substring(0,max(0,myText.length()-1));
break;
case ENTER:
break;
default:
myText +=key;
}
}
}
1