Hair like strokes

Hello, I have moving points on an Arabic letter outline (but you can try it using any letter from any font) , and basically I want to create hairlike strokes on the points, where they grow out (similar to sketches in the image), can anyone help me? I’m pretty new to programming too so excuse my code. Also I am using geomerative library.

Thank you!!!

24%20PM

import geomerative.*;

// Declare the objects we are going to use, so that they are accesible from setup() and from draw()
RFont f;
RShape grp;
RPoint[] points;

void setup(){
  // Initilaize the sketch
  size(600,600);
  frameRate(30);

  // Choice of colors
  background(255);
  fill(255,102,0);
  stroke(0);
  RG.init(this);
  
  //  Load the font file we want to use 
 grp = RG.getText("ج", "Mishafi.ttf", 672, CENTER);


  smooth();
}

void draw(){
    
  background(255);
  
  translate(width/2, height/2);
  
  // Draw the group of shapes
  noFill();
  stroke(0,0,200,150);
  RG.setPolygonizer(RG.ADAPTATIVE);
  //grp.draw();
  
  // Get the points on the curve's shape
  
  RG.setPolygonizer(RG.UNIFORMLENGTH);
  RG.setPolygonizerLength(map(frameCount, 0, height, 3, 200));
  points = grp.getPoints();

  // If there are any points
  if(points != null){
    noFill();
    stroke(0,200,0);
    beginShape();
    for(int i=0; i<points.length; i++){
      vertex(points[i].x, points[i].y);

    endShape();
  
    }
    fill(0);
    stroke(0);
    for(int i=0; i<points.length; i++){
      ellipse(points[i].x, points[i].y,1,1); 
    }
  }
  }
1 Like

when you are into oop / object oriented programming, make a class Hair and an ArrayList of that class

as start point pass the points of the letter

now each hair has its own vector to grow… so the vector is part of the class

examples for the growing itself:

https://www.processing.org/examples/brownian.html

https://www.processing.org/examples/movingoncurves.html

Chrisir

3 Likes

Hi @kaecodes,

Can’t look at your code at the moment but check the Particle class from this sketch made by Raven Kwok. That might help you figuring out how to create the motion (growth) of your “hair” object.

3 Likes

thank you, super helpful.