diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-01-24 18:27:27 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-01-27 09:12:28 +0000 |
commit | a48244d5aa1d14c286b7cd39afebcfff9c9dcb60 (patch) | |
tree | 7acd17b061bf6f5afccc4f737e11704ebf035acd /src/quick/items/qquickpathitemgenericrenderer_p.h | |
parent | 00d3f3e9da071efce92d320884b331ea559fb292 (diff) |
JS API for defining static paths and draw params
In order to avoid the over head of one QObject for each VisualPath, Path
and PathXxxx element, provide an optional JavaScript API.
PathItem {
VisualPath { strokeWidth: 4; fillColor: "blue";
dashPattern: [ 1, 2, 3, 4]; capStyle: RoundCap
path: Path { PathMove { x: 100; y: 200 }
PathLine { x: 300; y: 300 } }
}
can now also be written as, at least when the path and the stroke/fill params
are static and do not need changing/animating later on:
PathItem {
Component.onCompleted: {
var path = newPath();
var sfp = newStrokeFillParams();
path.moveTo(100, 200);
path.lineTo(300, 300);
sfp.strokeWidth = 4;
sfp.fillColor = "blue";
sfp.dashPattern = [ 1, 2, 3, 4 ];
sfp.capStyle = VisualPath.RoundCap;
appendVisualPath(path, sfp);
commitVisualPaths();
}
}
In order to emphasize the difference from an imperative API (like
context2d), keep the path and the path stroke/fill parameters separate.
To preserve our sanity, extras like gradients are not mapped to JavaScript,
instead, one still references an QML-defined object from properties like
fillGradient.
The objects from newPath() and newStrokeFillParams() are reusable by calling
clear(). This avoids the need for multiple temp objects when there are
multiple paths.
Add a simple test and a hidden stress test with the tiger to the manual
test.
Change-Id: I3b1e275bacf8c8fc52f585fbed5d6f9354d5ae8e
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/items/qquickpathitemgenericrenderer_p.h')
-rw-r--r-- | src/quick/items/qquickpathitemgenericrenderer_p.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/quick/items/qquickpathitemgenericrenderer_p.h b/src/quick/items/qquickpathitemgenericrenderer_p.h index 045c52d610..70a9e88d2f 100644 --- a/src/quick/items/qquickpathitemgenericrenderer_p.h +++ b/src/quick/items/qquickpathitemgenericrenderer_p.h @@ -87,6 +87,7 @@ public: void beginSync(int totalCount) override; void setPath(int index, const QQuickPath *path) override; + void setJSPath(int index, const QQuickPathItemPath &path) override; void setStrokeColor(int index, const QColor &color) override; void setStrokeWidth(int index, qreal w) override; void setFillColor(int index, const QColor &color) override; |