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

Add support for useDataFromBytes #203

Merged
merged 7 commits into from
Feb 25, 2022
Merged

Add support for useDataFromBytes #203

merged 7 commits into from
Feb 25, 2022

Conversation

wcandillon
Copy link
Contributor

@wcandillon wcandillon commented Feb 20, 2022

fixes #202

@wcandillon wcandillon linked an issue Feb 20, 2022 that may be closed by this pull request
@wcandillon wcandillon requested a review from chrfalch February 21, 2022 10:09
@wcandillon wcandillon self-assigned this Feb 21, 2022
@wcandillon wcandillon marked this pull request as ready for review February 21, 2022 10:09
@wcandillon
Copy link
Contributor Author

@chrfalch ready for review

@wcandillon
Copy link
Contributor Author

@chrfalch I was thinking about useData() and the fact that if you pass a typed array to it, you don't need the async nature of the hook. so maybe overloading the function to have a non-async return type when passing data that can be constructed non-async?

Copy link
Contributor

@chrfalch chrfalch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks super nice! Really love this.

I've added one suggestion that I'd like.

const SIZE = width;

const pixels = new Uint8Array(256 * 256 * 4);
pixels.fill(255);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A suggestion - since this results in a white image (and might be mistaken for a bug), what about doing something like this:

let i = 0;
for (let x = 0; x < 256 * 4; x++) {
  for (let y = 0; y < 256 * 4; y++) {
    pixels[i++] = (x * y) % 255;
  }
}

Resulting in an image like this:

image

@wcandillon wcandillon merged commit 2432eae into main Feb 25, 2022
@wcandillon wcandillon deleted the feature/data-from-bytes branch February 28, 2022 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the MakeImage from pixel data and format API
2 participants