Skip to content

Commit

Permalink
Use only standard API in examples.
Browse files Browse the repository at this point in the history
Change-Id: I62a864de35c5b595ffda4397edb16342f54a86ce
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
  • Loading branch information
Justin McPherson authored and Qt by Nokia committed Feb 10, 2012
1 parent 66f740c commit dcd47af
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 16 deletions.
5 changes: 3 additions & 2 deletions examples/declarative/canvas/bezierCurve/bezierCurve.qml
Expand Up @@ -82,7 +82,7 @@ Item {

onPaint: {
var ctx = canvas.getContext('2d');
ctx.reset();
ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.globalAlpha = canvas.alpha;
ctx.strokeStyle = canvas.strokeStyle;
Expand All @@ -103,6 +103,7 @@ Item {
ctx.fill();
if (canvas.stroke)
ctx.stroke();
ctx.restore();
}
}

Expand All @@ -120,4 +121,4 @@ Item {
}
}
}
}
}
3 changes: 2 additions & 1 deletion examples/declarative/canvas/clip/clip.qml
Expand Up @@ -92,7 +92,7 @@ Item {
if (N>100) M=100;
if (N<0.00000000001) M=0.00000000001;

ctx.reset();
ctx.save();
ctx.globalAlpha =canvas.alpha;
ctx.fillStyle = "gray";
ctx.fillRect(0, 0, canvas.width, canvas.height);
Expand Down Expand Up @@ -129,6 +129,7 @@ Item {
ctx.clip();

ctx.drawImage(canvas.imagefile, 0, 0);
ctx.restore();
}
}

Expand Down
Expand Up @@ -80,7 +80,7 @@ Item {

onPaint: {
var ctx = canvas.getContext('2d');
ctx.reset();
ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.globalAlpha = canvas.alpha;
ctx.strokeStyle = canvas.strokeStyle;
Expand All @@ -107,6 +107,7 @@ Item {
ctx.font = "Bold 15px";

ctx.fillText("QML酷毙了", 30, 60);
ctx.restore();
}
}

Expand All @@ -124,4 +125,4 @@ Item {
}
}
}
}
}
5 changes: 3 additions & 2 deletions examples/declarative/canvas/roundedrect/roundedrect.qml
Expand Up @@ -79,7 +79,7 @@ Item {

onPaint: {
var ctx = getContext("2d");
ctx.reset();
ctx.save();
ctx.clearRect(0,0,canvas.width, canvas.height);
ctx.strokeStyle = canvas.strokeStyle;
ctx.lineWidth = canvas.lineWidth
Expand All @@ -104,6 +104,7 @@ Item {
ctx.fill();
if (canvas.stroke)
ctx.stroke();
ctx.restore();
}
}

Expand All @@ -121,4 +122,4 @@ Item {
}
}
}
}
}
5 changes: 3 additions & 2 deletions examples/declarative/canvas/smile/smile.qml
Expand Up @@ -82,7 +82,7 @@ Item {

onPaint: {
var ctx = canvas.getContext('2d');
ctx.reset();
ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.globalAlpha = canvas.alpha;
ctx.strokeStyle = canvas.strokeStyle;
Expand All @@ -107,6 +107,7 @@ Item {
ctx.fill();
if (canvas.stroke)
ctx.stroke();
ctx.restore();
}
}

Expand All @@ -124,4 +125,4 @@ Item {
}
}
}
}
}
5 changes: 3 additions & 2 deletions examples/declarative/canvas/squircle/squircle.qml
Expand Up @@ -96,7 +96,7 @@ Item {
if (N>100) M=100;
if (N<0.00000000001) M=0.00000000001;

ctx.reset();
ctx.save();
ctx.globalAlpha =canvas.alpha;
ctx.fillStyle = "gray";
ctx.fillRect(0, 0, canvas.width, canvas.height);
Expand Down Expand Up @@ -134,6 +134,7 @@ Item {
ctx.fillStyle = "yellow";
ctx.font = "Helvetica 16px";
ctx.fillText("|X-" + Math.round(canvas.px) + "|^" + N + " + |Y-"+Math.round(canvas.py)+"|^" + N + " = |" + Math.round(R) + "|^" + N, canvas.px - 125, canvas.py);
ctx.restore();
}
}

Expand All @@ -151,4 +152,4 @@ Item {
}
}
}
}
}
5 changes: 3 additions & 2 deletions examples/declarative/canvas/stockchart/stock.qml
Expand Up @@ -688,7 +688,7 @@ Rectangle {

//console.log("painting... first:" + first + ", last:" + last + " current:" + view.currentIndex);
var ctx = canvas.getContext("2d");
ctx.reset();
ctx.save();

ctx.globalCompositeOperation = "source-over";
ctx.lineWidth = 1;
Expand Down Expand Up @@ -720,6 +720,7 @@ Rectangle {
drawPrice(ctx, first, last, Qt.rgba(0.5, 0.5, 0.5, 1),"close", points, highestPrice);
drawVolume(ctx, first, last, Qt.rgba(0.3, 0.5, 0.7, 1),"volume", points, highestValume);
drawKLine(ctx, first, last, points, highestPrice);
ctx.restore();
}
}
}
}
5 changes: 3 additions & 2 deletions examples/declarative/canvas/tiger/tiger.qml
Expand Up @@ -82,7 +82,7 @@ Item {
}
onPaint: {
var ctx = canvas.getContext('2d');
ctx.reset();
ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.globalAlpha = canvas.alpha;
ctx.scale(canvas.scaleX, canvas.scaleY);
Expand Down Expand Up @@ -110,6 +110,7 @@ Item {
ctx.stroke();
}
}
ctx.restore();
}
}
Rectangle {
Expand All @@ -125,4 +126,4 @@ Item {
}
}
}
}
}
3 changes: 2 additions & 1 deletion examples/declarative/canvas/twitterfriends/twitter.qml
Expand Up @@ -112,7 +112,7 @@ Rectangle {
onImageLoaded:requestPaint();
onPaint: {
var ctx = canvas.getContext('2d');
ctx.reset();
ctx.save();
ctx.fillStyle="black";
ctx.fillRect(0, 0, canvas.width, canvas.height);

Expand All @@ -135,6 +135,7 @@ Rectangle {
}
layoutChanged = false;
}
ctx.restore();
}
}
}

0 comments on commit dcd47af

Please sign in to comment.