Automattic / Automattic/node-canvas

repeat call on loadImage does not clear the previous image

Open
#1,758 1 comment 0 reactions 0 assignees View on GitHub
Needs more info
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

## 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

```js
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.