We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, i was editing some geomerative's codes but i'm not able to line-break this. Could you help me with this example? i would like to write a sentence in the canvas and distorce it with mouse over. Thank you for your help
import processing.pdf.*;
import geomerative.*;
PGraphics pg;
RFont myFont;
RGroup myGroup;
RPoint[] myPoints;
String myText = "hello \n hello";
FontAgent[] myAgents;
int step = 0;
int dim;
boolean stopAnime = false;
void setup() {
size(1050, 1050);
background(255);
smooth();
ellipseMode(RADIUS);
RG.init(this);
myFont = new RFont("relative.ttf",100,RFont.CENTER);
RCommand.setSegmentLength(2);
RCommand.setSegmentator(RCommand.UNIFORMLENGTH);
myGroup = myFont.toGroup(myText);
myPoints = myGroup.getPoints();
myAgents = new FontAgent[myPoints.length];
for (int i=0; i<myPoints.length; i++) {
myAgents[i] = new FontAgent(new PVector(myPoints[i].x, myPoints[i].y));
}
}
void draw() {
translate(width/2, height/2);
background(0);
fill(0);
for (int i = 0; i < myPoints.length; i++) {
myAgents[i].display();
myAgents[i].motion();
}
//saveFrame("line-######.png");
}
void keyPressed() {
if (key == 'f' || key == 'F')
stopAnime = !stopAnime;
if (stopAnime == true)
noLoop();
else loop();
if (key == '+')
step++;
println(step);
if (key == '-')
step--;
}
class FontAgent {
PVector loc;
float motion;
FontAgent(PVector l) {
loc = l.get();
}
void motion() {
float noiseScale = map(mouseX, mouseY, width, 0.001, 0.01);
motion = noise(loc.x * noiseScale, loc.y * noiseScale ) * 25;
}
//-7 -16
void display() {
noStroke();
fill(255);
//noFill();
// stroke(1);
rect(loc.x, loc.y, motion+step, motion+step);
}
}
Answers
i can't figure out how to have both "hell " and "o " lines
When you format your code, make sure there is an empty line above and below your code block. You can edit your posts by clicking on the gear icon on the top right corner of each post.
Kf
ah sorry, i now fixed that
any help please??
A 2D array might work. You may want to look into the idea.