HTML5 Canvas, 2nd Edition and Dart

html5 canvas with dartSome time ago I picked up HTML5 Canvas, 2nd Edition by Steve Fulton and Jeff Fulton, from O’Reilly. I wanted to learn some Canvas tricks for myself and just get a feel for it (plus I love learning new things!). O’Reilly has since gone ahead and made this book available for free online. Check out HTML5 Canvas. The online version also includes interactive components.

But I’m very much into Dart and all the samples were, understandably, written in JavaScript. So as a personal project I began writing the samples in Dart. As I progressed, I thought that these samples would be a great way to help introduce Dart developers to the HTML5 Canvas as well. But being a shady area of reuse I wasn’t sure on where exactly I would stand on O’Reilly’s fair use policy. So I reached out to O’Reilly directly to see how they felt about my making the sources generally available. As it turns out they were happy to grant me permission to share my Dart port of the samples freely!

Now for the bad news… The original examples I had converted have all been lost due to a botched OS update before I had them hosted on an external repository. So I will be starting the process over from scratch and continually adding new examples as I proceed through the book again. You can see the example I have completed on my GitHub Repository. Feel free to watch or star this repository to be notified as I upload new examples.

A few things to note regarding the examples. First I tried to stay relatively true to the examples from the book. That said, I also used some more Dart-ish conventions in a number of areas to make the most of the functionality that Dart offers, such as cascades (oh the type those alone saved me!) and class-based inheritance. The examples are listed under the web/ directory (per standard Pub Package Layout Conventions), and then are subdivided into their respective directories.

While the code itself will be commented, I will not include the accompanying text explanations from the book. I highly recommend that you follow the online version (mentioned previously), or better yet buy the eBook and support the original authors! In a couple of instances I have left the code as it is from the original samples, however I have added comments indicating that some statements may not be required (possible errata for the book?). I’d love to hear your thoughts on the ports and if they were helpful in anyway.

This entry was posted in Dart and tagged , . Bookmark the permalink.

Have Something To Add?

Loading Facebook Comments ...
Loading Disqus Comments ...