Add static Metatile::coordFromPixmapCoord()

This commit is contained in:
BigBahss 2020-09-27 12:17:12 -04:00
parent 9565b677d2
commit 84f920bb03
2 changed files with 8 additions and 0 deletions

View file

@ -3,6 +3,7 @@
#include "tile.h"
#include <QImage>
#include <QPoint>
#include <QString>
class Metatile
@ -20,6 +21,7 @@ public:
Metatile *copy();
void copyInPlace(Metatile*);
static int getBlockIndex(int);
static QPoint coordFromPixmapCoord(const QPointF &pixelCoord);
};
#endif // METATILE_H

View file

@ -39,3 +39,9 @@ int Metatile::getBlockIndex(int index) {
return index - Project::getNumMetatilesPrimary();
}
}
QPoint Metatile::coordFromPixmapCoord(const QPointF &pixelCoord) {
int x = static_cast<int>(pixelCoord.x()) / 16;
int y = static_cast<int>(pixelCoord.y()) / 16;
return QPoint(x, y);
}