Question

I would like to generate random/noise points along each character of a multiple line text. I've tried this with the Geomerative library, but unfortunately it does not support multi line. Any other solution?

Was it helpful?

Solution

You could find a library to get the path points of the text or if simply adding points, you could get a 2D snapshot(either using get() or PGraphics) of the text and fill in pixels. Here's a minimal example.

PImage snapshot;
int randomSize = 3;
void setup(){
  //render some text
  background(255);
  fill(0);
  textSize(40);
  text("Hello",0,50);
  //grab a snapshot
  snapshot = get();
}
void draw(){
  int rx = (int)random(snapshot.width);//pick a random pixel location
  int ry = (int)random(snapshot.height);//you can pick only the areas that have text or the whole image bot a bit of hit&miss randomness
  //check if it's the same colour as the text, if so, pick a random neighbour and also paint it black
  if(snapshot.get(rx,ry) == color(0)) snapshot.set(rx+((int)random(randomSize,-randomSize)),ry+((int)random(randomSize,-randomSize)),0);
  image(snapshot,0,0);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top