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