background preloader

JavaScript

Facebook Twitter

Language

Node. Loaders. Patterns. Underscore.js. Knockout.js vs. Backbone.js – Part 2 « If & Else. Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programm... The JavaScript Module Pattern | Blog :: The JavaScript Playground. Lets say you've got a little library like this, that just increments a number: However, people using this library are able to do jspy.count = 5 to manually adjust the value. Lets say for the purpose of this tutorial, that users should not be able to do that. In other languages you'd be able to define a private variable, but JavaScript doesn't explcitly have them. However, we are able to manipulate JavaScript to provide them to us, and that brings us on nicely to one of the most popular JavaScript design patterns, the Module or Modular pattern. The solution to the above is: Firstly I create the variable _count, with the underscore denoting that it's private.

However, you'll notice I've wrapped the entire library in a self-invoking anonymous function. Jspy.incrementCount(); jspy.getCount(); But if I attempt: It returns undefined. There are a couple of different approaches to the way I've done things above. And following on from that, Christian Heilmann coined the Revealing Module Pattern. Javascript motion tracking | Soundstep. It is very often that I have to do video motion tracking for interactive video campaign in my daily work. If I’m used used to do that in Flash, I made a quick experiment to do the same in javascript.

Thanks to Olof Storm who made me a perfect corner pin motion tracking in After Effects, and I’ve been using some code from Steven Wittens to draw an image in perspective. Click here to see the motion tracking demo (give it a bit of time to fully load). What I’m doing in this demo is drawing a video in a canvas, and using the corner pin tracking data to draw an image on top of the video. I made 2 different videos, you can switch between them using the “switch video” button. In the first video, I get the current video frame number by calculation (current time by video fps).

The idea behind the binary counter is to export the video with some white and black rectangle that describe graphically the real frame number of the video. You can see the binary counter on the right border of the video. CoffeeScript. Create a new Fiddle - jsFiddle - Online Editor for the Web (JavaScript, MooTools, jQuery, Prototype, YUI, Glow and Dojo, HTML, CSS)