I have a problem with understanding who to optimize my code.
Main idea of program of creating a words with dots.
ArrayList<PVector> edgeVertices = new ArrayList<PVector>();
ArrayList<PVector> Adding = new ArrayList<PVector>();
char[] word = new char[5];
PFont font;
PShape shape;
PVector max;
String fontPath;
char c;
int border = 0;
int distance = 10;
int adding_length =1;
void setup() {
size(900, 300);
background(51);
fontPath = "arial.ttf"; // Path to font file "AvenirNextLTPro-Demi.otf" Comfortaa-Light.ttf
word[0] = 't';
word[1] = 'r';
word[2] = 'a';
word[3] = 'i';
word[4] = 'n';
for (int i = 0; i < word.length; i++) {
c = word[i];
font = createFont(fontPath, 166, true);
shape = font.getShape(c);
for (int j = 0; j < shape.getVertexCount(); j++) {
edgeVertices.add(shape.getVertex(j));
}
max = new PVector(edgeVertices.get(0).x, edgeVertices.get(0).y + 165);
stroke(255);
strokeWeight(8);
for (int j = 0; j < edgeVertices.size(); j++) {
for (int k = 0; k < edgeVertices.size(); k++) {
float di = edgeVertices.get(j).y - edgeVertices.get(k).y;
if (di < 0) di*=-1;
if (edgeVertices.get(j).x == edgeVertices.get(k).x && di > distance) {
Adding.add(new PVector (edgeVertices.get(j).x, (edgeVertices.get(j).y < edgeVertices.get(k).y?edgeVertices.get(j).y:edgeVertices.get(k).y) + di/2));
++adding_length;
}
}
}
for (int k = 0;k < Adding.size()-1; k++) {
edgeVertices.add(Adding.get(k));
}
for (PVector v : edgeVertices) {
point(v.x + 25 + border, v.y + 165 );
if (max.x < v.x) {
max.x = v.x;
}
}
border += max.x + 20;
for (int k = shape.getVertexCount()-1; k > 0; k--) {
edgeVertices.remove(shape.getVertex(k));
}
Adding = new ArrayList<PVector>();
}
}
void draw() {
}