[英]TypeError: Cannot read property 'width' of undefined when using image() in p5.js
So I'm trying to show an image that I have loaded with loadImage()
, but when i get to using the image()
function I get 所以我试图显示一个我用
loadImage()
加载的图像,但是当我开始使用image()
函数时,我得到了
TypeError: Cannot read property 'width' of undefined
TypeError:无法读取未定义的属性“width”
Here is the code: 这是代码:
let img
function preLoad() {
font = loadFont('../addons/Fonts/monof55')
img = loadImage('./yes.jpg')
}
function setup() {
createCanvas(1200, 600)
background('darkblue')
fill('#EEEEEE')
stroke(25)
strokeWeight(2)
rect(0, height - height / 20, width, height / 20)
}
function draw() {
image(img, 0, 0)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.