Add path drawing to the API

This commit is contained in:
GriffinR
2022-10-11 10:34:09 -04:00
committed by Marcus Huderle
parent 2fa2fc52e8
commit 385c17fd23
4 changed files with 52 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ public:
Q_INVOKABLE void addTileImage(int x, int y, int tileId, bool xflip, bool yflip, int paletteId, bool setTransparency = false, int layer = 0);
Q_INVOKABLE void addTileImage(int x, int y, QJSValue tileObj, bool setTransparency = false, int layer = 0);
Q_INVOKABLE void addMetatileImage(int x, int y, int metatileId, bool setTransparency = false, int layer = 0);
Q_INVOKABLE void addPath(QList<int> x, QList<int> y, QString color = "#000000", int layer = 0);
private:
QMap<int, Overlay*> overlayMap;

View File

@@ -70,6 +70,23 @@ private:
QImage image;
};
class OverlayPath : public OverlayItem {
public:
OverlayPath(QPainterPath path, QString color) {
this->prevX = 0;
this->prevY = 0;
this->path = path;
this->color = color;
}
~OverlayPath() {}
virtual void render(QPainter *painter, int x, int y);
private:
int prevX;
int prevY;
QPainterPath path;
QString color;
};
class Overlay
{
public:
@@ -102,6 +119,7 @@ public:
void addRect(int x, int y, int width, int height, QString color = "#000000", bool filled = false);
bool addImage(int x, int y, QString filepath, bool useCache = true, int width = -1, int height = -1, int xOffset = 0, int yOffset = 0, qreal hScale = 1, qreal vScale = 1, QList<QRgb> palette = QList<QRgb>(), bool setTransparency = false);
bool addImage(int x, int y, QImage image);
bool addPath(QList<int> x, QList<int> y, QString color);
private:
QList<OverlayItem*> items;
int x;