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

Coordinate of getImageData seems to be wrong #26

Closed
Ovilia opened this issue Aug 17, 2015 · 4 comments
Closed

Coordinate of getImageData seems to be wrong #26

Ovilia opened this issue Aug 17, 2015 · 4 comments

Comments

@Ovilia
Copy link

Ovilia commented Aug 17, 2015

I'm using Stage.js to implement a magnifying glass effect like this.

soap

The circle in the top shows the magnified area around mouse position. I tried to read the pixels rendered by Stage.js using getImageData but got all 0 in data. My code is available here.

I'm not sure if transformation of canvas in your game engine changed anything for getImageData, but I don't think this should be an issue since canvas spec states:

The current path, transformation matrix, shadow attributes, global alpha, the clipping region, and global composition operator must not affect the getImageData() and putImageData() methods.

Any idea how should I get the pixels around mouse position in this way? Or, what else game engine should I use to implement this magnifying glass effect?

Thanks!

@shakiba
Copy link
Collaborator

shakiba commented Aug 18, 2015

Have you considered using the canvas create by Stage.js as an image in your second canvas? If you do that you will not need to get and copy image data.

@Ovilia
Copy link
Author

Ovilia commented Aug 18, 2015

@shakiba How can I use it as an image? By toDataURL?

@shakiba
Copy link
Collaborator

shakiba commented Aug 18, 2015

Just use context as image object. But anyway because canvas is raster, scaling rendered result is going to be pixelated.

Another option is adding a new node type which clones another node and is pinned independently. Therfore your graphics are rendered as they are. But I'm not yet sure how to cut a circle.

@Ovilia
Copy link
Author

Ovilia commented Aug 18, 2015

Thanks! It works when I use it as an image. Helped a lot!

@Ovilia Ovilia closed this as completed Aug 18, 2015
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

No branches or pull requests

2 participants