When I try to add text to p5.js canvas, it got displayed twice for some reason. Attached code below:
let img;
function setup() {
createCanvas(screen.availWidth, screen.availHeight);
img = loadImage('https://mediumpurpleperfumeddegrees.boyuan12.repl.co/circuit1.webp');
textOutput();
}
function draw() {
image(img, screen.availWidth / 2 - img.width, 0, img.width * 1.25, img.height * 1.25);
textSize(20);
text('5V', screen.availWidth / 2 - img.width - 20, img.height / 2 + 30);
text('50Ω', screen.availWidth / 2 - img.width + 100, img.height / 2 - 45);
text('100Ω', screen.availWidth / 2 - img.width + 220, img.height / 2 + 50);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.js"></script>
I tried to look through documentation but found none too helpful.