mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-26 01:34:40 +00:00
ref #97 Added method draw square.
This commit is contained in:
parent
525222e4a0
commit
74bb6f30f8
@ -59,8 +59,13 @@ void ControlPos::updatePosition() {
|
||||
|
||||
void ControlPos::drawCircle() {
|
||||
|
||||
if (objects().size() == 0) {
|
||||
QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."));
|
||||
return;
|
||||
}
|
||||
|
||||
float step = 360 / objects().size();
|
||||
int temp = 1;
|
||||
int temp = 0;
|
||||
|
||||
for (ClasterItem* object: objects()) {
|
||||
|
||||
@ -75,16 +80,28 @@ void ControlPos::drawCircle() {
|
||||
|
||||
void ControlPos::drawSquare() {
|
||||
|
||||
float step = 360 / objects().size();
|
||||
int temp = 1;
|
||||
if (objects().size() == 0) {
|
||||
QuasarAppUtils::Params::log(QString("The number of objects is zero. Add object."));
|
||||
return;
|
||||
}
|
||||
|
||||
for (ClasterItem* object: objects()) {
|
||||
int height = qFloor(qSqrt(objects().size()));
|
||||
int width = qCeil(qSqrt(objects().size()));
|
||||
|
||||
float x = _distance * qCos(step*temp);
|
||||
float y = _distance * qSin(step*temp);
|
||||
GroupObject::updatePosition(object->guiId(), {x, y, 0});
|
||||
int coutObj = 0;
|
||||
for (int y = 0; y < height; y++) {
|
||||
|
||||
temp++;
|
||||
coutObj = coutObj+y;
|
||||
for (int x = 0; x < width; x++) {
|
||||
|
||||
if (coutObj == objects().size()) {
|
||||
return;
|
||||
}
|
||||
GroupObject::updatePosition(objects()[coutObj]->guiId(), {float(x + _distance),
|
||||
float(y + _distance),
|
||||
0});
|
||||
coutObj++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user