drawing reworked into c++ plugin, moved input handler to Interactions.qml as a PointHandler
This commit is contained in:
+4
-31
@@ -1,36 +1,9 @@
|
||||
import QtQuick
|
||||
import ZShell.Internal
|
||||
|
||||
Canvas {
|
||||
StrokeCanvas {
|
||||
id: root
|
||||
|
||||
property color penColor: "white"
|
||||
property real penWidth: 4
|
||||
property var points: []
|
||||
|
||||
function clear(): void {
|
||||
var ctx = getContext('2d');
|
||||
root.points = [];
|
||||
ctx.reset();
|
||||
root.requestPaint();
|
||||
}
|
||||
|
||||
renderStrategy: Canvas.Cooperative
|
||||
|
||||
onPaint: {
|
||||
if (points.length < 2)
|
||||
return;
|
||||
var ctx = root.getContext('2d');
|
||||
ctx.save();
|
||||
ctx.lineWidth = root.penWidth;
|
||||
ctx.strokeStyle = root.penColor;
|
||||
ctx.lineJoin = "round";
|
||||
ctx.lineCap = "round";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(points[0].x, points[0].y);
|
||||
for (var i = 1; i < points.length; i++)
|
||||
ctx.lineTo(points[i].x, points[i].y);
|
||||
ctx.stroke();
|
||||
points = points.slice(points.length - 2);
|
||||
ctx.restore();
|
||||
}
|
||||
penColor: "white"
|
||||
penWidth: 4
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user