-
Notifications
You must be signed in to change notification settings - Fork 66
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 a Canvas example? #42
Comments
One change that would need to happen is "erasing" the ball's previous position. If you want to make it noticeably different, it could use the "offscreen |
Ok, I think I'm leaning towards adding it then. Let's plan on putting together a code snippet and dropping it in this issue so I can take a look before adding it to the site. |
Example from http://blog.bob.sh/2012/12/double-buffering-with-html-5-canvas.html /* Prepare your canvas */
mainCanvas = $('#myCanvas');
offscreenCanvas = document.createElement('canvas');
/* Make sure your offscreen size matches your on screen
* size */
offscreenCanvas.width = mainCanvas.width;
offscreenCanvas.height = mainCanvas.height;
/* Do some drawing on the offscreen canvas */
ctxOffscreen = offscreenCanvas.getContext('2d');
ctxOffscreen.strokeRect(0, 0, 10, 10);
/* Now flip the offscreen canvas to the onscreen
* one */
ctxMain = mainCanvas.getContext('2d');
ctxMain.drawImage(offscreenCanvas, 0, 0); |
I'm a bit on the fence about this one because I picture it as being 95% the same as the "Vanilla Javascript" technique, the only difference being that the position is applied to a canvas instead of an html element.
It being so similar seems to go against the no "slight variations on existing techniques" principle in the Contribution guidelines, but I'm open to suggestions. Anybody have thoughts?
The text was updated successfully, but these errors were encountered: