Skip to content

repeat call on loadImage does not clear the previous image #1758

Open
@shen-lin

Description

@shen-lin

Issue or Feature

The code below can be triggered repeatedly. E.g. by click a button. Everything a dynamically generated image is returned by the backend. I already clear the context before drawing the image. But the image is still repeated drawing over the previous images. The only thing I can think about is the loadImage is returning image that draws over previous image.

Steps to Reproduce

var {loadImage, createCanvas} = require('canvas');
const image = await loadImage(`/newimage?${Math.random()}`);
const canvas = createCanvas(200, 200);
const context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "rgba(0, 0, 0, 1)";
context.fillRect(0, 0, canvas.width, canvas.height);
context.drawImage(terrain, 0, 0, canvas.width, canvas.height);

Your Environment

Version: "2.6.1"
Environment: Chrome browser

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions