Diffused Limited Aggregatin / Plant Multiple Seeds in Type Outline ?
in
Contributed Library Questions
•
2 months ago
Hi everybody !
so working on this got me to realize a lot of generative type is not open source right now... i would like to create a type face using the DLA sketch from FORM + CODE
http://formandcode.com/code-examples/simulate-dla
having the DLA seed out of the outline of the type's shapes.
using geomerative, i got to this point:
but i still can't converts those points to seeds for the diffusion to start from ....
i want it to look like this Photoshop mockup i made
my code is looking like:
______________________________
and the particle class tab is:
___________________
Anything would help ! thanks so so much !
Youmna
so working on this got me to realize a lot of generative type is not open source right now... i would like to create a type face using the DLA sketch from FORM + CODE
http://formandcode.com/code-examples/simulate-dla
having the DLA seed out of the outline of the type's shapes.
using geomerative, i got to this point:
but i still can't converts those points to seeds for the diffusion to start from ....
i want it to look like this Photoshop mockup i made
my code is looking like:
- //speed varies when particleCount augments
- int particleCount = 300000;
- Particle[] particles = new Particle[particleCount];
- boolean[] field;
- import geomerative.*;
- RFont font;
- String myText = "Points on Outline";
- //----------------SETUP---------------------------------
- void setup() {
- size(1024, 700, P2D);
- background(102);
- smooth();
- RG.init(this);
- font = new RFont("FreeSans.ttf", 100, CENTER);
- fill(255, 0, 0);
- noStroke();
- translate(width/2, height/2);
- // create an array that stores the position of our particles
- field = new boolean[width * height];
- //CONFIGURE SEGMENT LENGTH AND MODE
- //SETS THE SEGMENT LENGTH BETWEEN TWO POINTS ON A SHAPE/FONT OUTLINE
- RCommand.setSegmentLength(10);//ASSIGN A VALUE OF 10, SO EVERY 10 PIXELS
- RCommand.setSegmentator(RCommand.UNIFORMLENGTH);
- //RCommand.setSegmentator(RCommand.CUBICBEZIERTO);
- //RCommand.setSegmentator(RCommand.ADAPTATIVE);
- //GROUP TOGETHER MY FONT & TEXT.
- RGroup myGroup = font.toGroup(myText);
- myGroup = myGroup.toPolygonGroup();
- //ACCESS POINTS ON MY FONT/SHAPE OUTLINE
- RPoint[] myPoints = myGroup.getPoints();
- //DRAW ELLIPSES AT EACH OF THESE POINTS
- for (int i=0; i<myPoints.length; i++) {
- ellipse(myPoints[i].x, myPoints[i].y, 5, 5);
- }
- // add seed in the center
- int fcenterX = width / 3 ;
- int fcenterY = height / 3;
- field[fcenterX + fcenterY * width] = true;
- // make particles
- for(int i=0; i<particleCount; i++) {
- particles[i] = new Particle();
- }
- }
- void draw() {
- loadPixels();
- for(int i=0; i<particleCount; i++) {
- particles[i].update();
- if (particles[i].stuck) {
- pixels[particles[i].y * width + particles[i].x] = color(150,255,0);
- }
- }
- updatePixels();
- }
______________________________
and the particle class tab is:
- // ---------------
- // Particle.pde
- // ---------------
- class Particle
- {
- int x, y;
- boolean stuck = false;
- Particle() {
- reset();
- }
- void reset() {
- // keep choosing random spots until an empty one is found
- do {
- x = floor(random(width));
- y = floor(random(height));
- } while (field[y * width + x]);
- }
- void update() {
- // move around
- if (!stuck) {
- x += round(random(-1, 1));
- y += round(random(-1, 1));
- if (x < 0 || y < 0 || x >= width || y >= height) {
- reset();
- return;
- }
- // test if something is next to us
- if (!alone()) {
- stuck = true;
- field[y * width + x] = true;
- }
- }
- }
- // returns true if no neighboring pixels
- boolean alone() {
- int cx = x;
- int cy = y;
- // get positions
- int lx = cx-1;
- int rx = cx+1;
- int ty = cy-1;
- int by = cy+1;
- if (cx <= 0 || cx >= width ||
- lx <= 0 || lx >= width ||
- rx <= 0 || rx >= width ||
- cy <= 0 || cy >= height ||
- ty <= 0 || ty >= height ||
- by <= 0 || by >= height) return true;
- // pre multiply the ys
- cy *= width;
- by *= width;
- ty *= width;
- // N, W, E, S
- if (field[cx + ty] ||
- field[lx + cy] ||
- field[rx + cy] ||
- field[cx + by]) return false;
- // NW, NE, SW, SE
- if (field[lx + ty] ||
- field[lx + by] ||
- field[rx + ty] ||
- field[rx + by]) return false;
- return true;
- }
- }
___________________
Anything would help ! thanks so so much !
Youmna
1