summaryrefslogtreecommitdiffstats
path: root/examples/painting/Drawing.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/painting/Drawing.qml')
-rw-r--r--examples/painting/Drawing.qml8
1 files changed, 1 insertions, 7 deletions
diff --git a/examples/painting/Drawing.qml b/examples/painting/Drawing.qml
index a19da45..f0f39a2 100644
--- a/examples/painting/Drawing.qml
+++ b/examples/painting/Drawing.qml
@@ -10,6 +10,7 @@ Canvas {
property int count: 0
property int lineWidth: 2
property variant drawColor: "black"
+ property variant ctx: getContext("2d");
MouseArea {
id:mousearea
@@ -25,8 +26,6 @@ Canvas {
}
function drawLineSegment() {
- var ctx = getContext();
- ctx.save();
ctx.beginPath();
ctx.strokeStyle = drawColor
ctx.lineWidth = lineWidth
@@ -34,20 +33,15 @@ Canvas {
ctx.lineTo(mousearea.mouseX, mousearea.mouseY);
ctx.stroke();
ctx.closePath();
- ctx.restore();
}
function drawPoint() {
- var ctx = getContext();
- ctx.save();
ctx.lineWidth = lineWidth
ctx.fillStyle = drawColor
ctx.fillRect(mousearea.mouseX, mousearea.mouseY, 2, 2);
- ctx.restore();
}
function clear() {
- var ctx = getContext();
ctx.clearRect(0, 0, width, height);
}
}