Array Index Out Of Bounds
in
Programming Questions
•
2 years ago
Hi,
I'm new in Processing and i got a problem i can't find the answer :
ArrayIndexOutOfBundsException : 0
The idea of my project is to randomly display points of construction of a font each time you click, anyway i'll put you an image of what i'd like in result and my code :
As i said i'm really new so maybe there is error of construction, please tell me !
THANKS !
import geomerative.*;
cercle [] touslescercle;
RFont font;
String textTyped = "TEST";
boolean doSave = false;
float a;
float b;
void setup() {
size(1324,350);
frame.setResizable(true);
smooth();
RG.init(this);
font = new RFont("FreeSans.ttf", 200, RFont.LEFT);
RCommand.setSegmentLength (11);
RCommand.setSegmentator(RCommand.UNIFORMLENGTH);
touslescercle = new cercle [0];
}
void draw() {
background(255);
translate(20,220);
if (textTyped.length() > 0) {
RGroup grp;
grp = font.toGroup(textTyped);
grp = grp.toPolygonGroup();
RPoint[] pnts = grp.getPoints();
// dots
fill(0);
noStroke();
for (int i = 0; i < pnts.length; i++ ) {
touslescercle[i].dessine();
float a = random(pnts[i].x);
float b = random(pnts[i].y);
}
}
}
class cercle {
float diametre,x,y;
cercle() {
x = a;
y = b;
diametre = 7;
touslescercle = (cercle[]) append
(touslescercle, this);
}
void dessine(){
ellipse(x, y, diametre, diametre);
}
}
void mouseReleased(){
new cercle();
}
1