drawText method
void
drawText()
Implementation
void drawText() {
drawIn(0, textCenter[0][0], textCenter[0][1]);
for (var i = 1; i < textlist.length; i++) {
double w = textlist[i].width;
double h = textlist[i].height;
int attempts = 0;
bool isadded = false;
while (!isadded) {
int getX = Random().nextInt(mapX.toInt() - w.toInt());
int direction = Random().nextInt(2);
if (direction == 0) {
for (int y = textCenter[i][1].toInt(); y > 0; y--) {
if (checkMap(getX.toDouble(), y.toDouble(), w, h)) {
drawIn(i, getX.toDouble(), y.toDouble());
isadded = true;
break;
}
}
if (!isadded) {
for (int y = textCenter[i][1].toInt(); y < mapY; y++) {
if (checkMap(getX.toDouble(), y.toDouble(), w, h)) {
drawIn(i, getX.toDouble(), y.toDouble());
isadded = true;
break;
}
}
}
} else if (direction == 1) {
for (int y = textCenter[i][1].toInt(); y < mapY; y++) {
if (checkMap(getX.toDouble(), y.toDouble(), w, h)) {
drawIn(i, getX.toDouble(), y.toDouble());
isadded = true;
break;
}
}
if (!isadded) {
for (int y = textCenter[i][1].toInt(); y > 0; y--) {
if (checkMap(getX.toDouble(), y.toDouble(), w, h)) {
drawIn(i, getX.toDouble(), y.toDouble());
isadded = true;
break;
}
}
}
}
attempts += 1;
if (attempts > attempt) {
isadded = true;
}
}
}
}