`image.get()` failing
Closed this issue · 4 comments
tmjoen commented
Sorry for the noob question, but I can't seem to find any info on this.
I'm getting
Uncaught TypeError: $.Color is not a constructor
at $.get (q5.js:1364:14)
This is in this code
$.get = (x, y, w, h) => {
let pd = $._pixelDensity || 1
if (x !== undefined && w === undefined) {
let c = $._getImageData(x * pd, y * pd, 1, 1).data
return new $.Color(c[0], c[1], c[2], c[3] / 255)
}
I can't find any $.Color defined — is this from an external lib?
quinton-ashley commented
Can you send me a snippet of your code that triggers the error?
Also Color is from the q5-color module which is included in the default q5.js bundle.
tmjoen commented
Thanks for taking a look, I really appreciate it!
The error appears when I load an image and try to manipulate it.
let img = loadImage('/images/and03-01.png')
// then later in draw()
function draw() {
// ...
let c = img.get(x * tileSizeX, y * tileSizeY) // this triggers the $.Color error
}
quinton-ashley commented
@tmjoen ah yup this is a bug. I will try to fix it soon.
quinton-ashley commented
Fixed in v2.5.1! See changelog:
https://github.com/q5js/q5.js/releases#:~:text=%3C/script%3E-,2.5.1,-Added%20a%20new