Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

3D Animated Canvas Christmas Tree (Plus: How It Works)

DZone's Guide to

3D Animated Canvas Christmas Tree (Plus: How It Works)

· Web Dev Zone ·
Free Resource

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

In the spirit of the season, how about a clever Canvas Christmas tree? which looks static like this:


but when unleashed on the browser's renderer, rotates beautifully, with shading, in the midst of the falling snow.

Cool enough simply to admire! But apropos of the falling snow and the rotating Christmas tree both, the coder behind the graphic also wrote just about the most helpful 'how I did it' piece you can imagine -- complete with screenshots and diagrams of each stage in the JavaScript, for those of us who can develop web apps but don't easily intuit the language of computer graphics.

The JavaScript comes in at exactly 1024 bytes&characters, too -- the piece won the JS1K Xmas contest last year -- so the code (click on 'view source and description') is a great example of highly condensed programming.

Check out the rotating tree here, and the 'how I did it' here.

And have a great holiday, everyone!!

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}