Moving particles following text contour
in
Contributed Library Questions
•
1 month ago
Hello guys,
I'm using the useful Geomerative library for text manipulation, and I'm trying to make particles follow the text contour. I tried thinking about taking each one and move towards the previous one, but I'm not getting to the right code.
This is the effect I'm trying to achive.
- import processing.opengl.*;
- import geomerative.*;
- Particle p;
- ArrayList particles;
- RFont font;
- RShape s;
- void setup() {
- size(600, 400, OPENGL);
- smooth();
- particles = new ArrayList();
- RG.init(this);
- RCommand.setSegmentLength(10);
- font = new RFont("FreeSans.ttf", 200, RFont.CENTER);
- RGroup maGroupe = font.toGroup("GEO");
- RPoint[] points = maGroupe.getPoints();
- int xoff = width/2;
- int yoff = 2*height/3;
- for (int i=0;i<points.length;i++) {
- particles.add(new Particle(xoff + points[i].x, yoff + points[i].y, 3));
- }
- }
- void draw() {
- background(0);
- noStroke();
- fill(255, 50);
- for (int i=0;i<particles.size();i++) {
- Particle p = (Particle) particles.get(i);
- p.draw();
- if (i > 0) {
- p.goTo( (Particle) particles.get(i-1) );
- }
- }
- }
- class Particle {
- PVector position;
- //POSITION
- float x;
- float y;
- //DIAMETER
- float d;
- Particle(float x_, float y_, float d_) {
- x = x_;
- y = y_;
- position = new PVector (x, y);
- this.d = d_;
- }
- float getPosX(){
- return position.x;
- }
- float getPosY(){
- return position.y;
- }
- void draw(){
- ellipse(x,y,d,d);
- }
- void goTo(Particle p) { //possible method?
- x = lerp(x, p.getPosX(), 0.4);
- y = lerp(y, p.getPosY(), 0.4);
- }
- }
1