Thanks for the tip, but a few things:
1. I don't think clearRect uses fillStyle
2. I don't think clearRect needs a fill, as "clear" implies both color and fill op. http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_canvas_clearrect
 
 
I had played with that, including your code, no luck.
It looks like the Black Sabbath - Paraoid album cover. 
 
 
Sent: Wednesday, March 23, 2016 at 5:11 PM
From: "Jérôme Godbout" <jer...@bodycad.com>
To: "Jason H" <jh...@gmx.com>
Cc: "interest@qt-project.org Interest" <interest@qt-project.org>
Subject: Re: [Interest] Canvas keeping artifacts
You may want to clear fill with blank transparency:
 
ctx.fillStyle = 'rgba(0,0,0,0)';
ctx.clearRect(0,0,width,height);
ctx.fill();
 
for me it did the trick.
 
On Wed, Mar 23, 2016 at 4:54 PM, Jason H <jh...@gmx.com> wrote:
I have a very simple pause button:
        Canvas {
                id: pauseCanvas
                anchors.fill: parent
                onWidthChanged: requestPaint()
                onHeightChanged: requestPaint()
                onPaint: {
                        var ctx = getContext('2d');
                        ctx.save()
                        ctx.clearRect(0,0, width,height)
                        ctx.fillStyle = color;
                        ctx.rect(0.125*width, 0.05*height, 0.25*width, 0.90*height);
                        ctx.fill();
                        ctx.rect(0.625*width, 0.05*height, 0.25*width, 0.90*height);
                        ctx.fill();
                        ctx.restore();
                }
        }

The problem is when I resize the window (which in turn resizes the canvas), I get artifacts of previous draws. If the window is made larger (corner drag or maximize) I can see the smaller original rectangles. And vice-versa.

How can I get Canvas to play nice?


_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to