Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image.get() failing #72

Closed
tmjoen opened this issue Sep 19, 2024 · 4 comments
Closed

image.get() failing #72

tmjoen opened this issue Sep 19, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@tmjoen
Copy link

tmjoen commented Sep 19, 2024

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
Copy link
Collaborator

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
Copy link
Author

tmjoen commented Sep 20, 2024

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 quinton-ashley changed the title $.Color is not a constructor image.get() failing Sep 20, 2024
@quinton-ashley quinton-ashley added the bug Something isn't working label Sep 20, 2024
@quinton-ashley quinton-ashley self-assigned this Sep 20, 2024
@quinton-ashley
Copy link
Collaborator

@tmjoen ah yup this is a bug. I will try to fix it soon.

@quinton-ashley quinton-ashley moved this to In Progress in q5 Sep 25, 2024
@quinton-ashley
Copy link
Collaborator

@github-project-automation github-project-automation bot moved this from Todo to Done in q5 Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants