I draw figures (von Koch snowflakes). I want to fill them with color. I don’t know how to do it. The level of knowledge of openframeworks is a bit more than nothing.
void koch(Turtle *turtle, double len, int depth) {
if (depth == 0) {
turtle->move(len);
} else {
koch(turtle, len / 3, depth - 1);
//Turn left 60 degrees.
turtle->turn(-60);
koch(turtle, len / 3, depth - 1);
//Turn right 120 degrees.
turtle->turn(120);
koch(turtle, len / 3, depth - 1);
//Turn left 60 degrees.
turtle->turn(-60);
koch(turtle, len / 3, depth - 1);
}
}
void loop() {
for(int i = 0; i < 12; i++) {
turtle[i].draw();
for (int j = 0; j < 3; j++) {
koch(&turtle[i], 300, 3);
turtle[i].turn(120);
}
}
}
Turtle::Turtle() {
lines = new ofPolyline();
x = 0.0;
y = 0.0;
dir = 0.0;
}
void Turtle::moveTo(int tx, int ty) {
lines->addVertex(tx,ty);