background preloader

Javascript

Facebook Twitter

JqPlot Charts and Graphs for jQuery. jQuery Sparklines. News 15 June 2013 - Version 2.1.2 Relased This release adds support for jQuery 1.10.0 and other bug fixes and minor improvements. See the full changelog for details of all changes. 26 January 2013 - Version 2.1.1 Relased This release adds support for jQuery 1.9.0 along with a couple of other bug fixes. If you're using a version of jQuery later than 1.8, be extra sure you're not rendering your page in quirks mode to avoid breaking tooltips for IE users. See jQuery's notes on quirks compatiblity for more info. See the full changelog for details of all changes. 15 October 2012 - Version 2.1 Released This release is primarily a bug-fix release, but also adds support for Internet Explorer 10.

See the full changelog for details of all changes. 29 April 2012 - Version 2.0 Released This release represents a significant code update. Customizable mouseover tooltips and interaction including highlighting of moused-over values. There's a few non-code updates as well: eg. This release also: Documentation. jQuery API Documentation. JavaScript reference. Make a simple html5 game with box2d in javascript – tutorial.

Demo First lets play the game that we shall be making in this tutorial. Its called Fruit Hunter. Tested on Chrome and Firefox. Click in the game then start using the arrow keys to control the monkey. Go full screen if having troubles with the iframe. That is a simple game and in this tutorial we shall learn how to make it. Pre-requisites You should already be knowing how to write object oriented code in javascript and handle closures. Theory Html5 and canvas This is a browser based game that does not use other things like flash. Box2d World Box2d is used to create a simulated environment (in short an animation) based on the rules of physics. I would suggest to read the basics of box2d in javascript if you are not already familiar with it. Box2d and the canvas viewport Recall 2d graphs and the cartesian coordinate system.

So here comes the concept the viewport to do this correctly. Imagine an infinitely sized cartesian coordinate graph on the wall behind your computer monitor. Box2d dimensions 1. HTML5 Canvas: Animation. To draw animations on an HTML5 canvas you need to draw and redraw the frames of the animation on the canvas. You need to do so really quickly to make the many images look like an animation.

To get the best performance for your animation, you should use the requestAnimationFrame call back function on the window object. You call this function and pass as parameter another function to be called when the browser is ready to draw the next frame in the animation. By letting the browser signal your application when the browser is ready to draw the next frame, the browser can enable hardware acceleration for your animation, as well as coordinate the frame redrawing with other redrawing activities in the browser.

The overall experience should be a lot better, than if you use the setTimeout() function in JavaScript to time the drawing of the animation frames. Here is a code example: This animate() function first gets a reference to the requestAnimationFrame() function. Drawing shapes with canvas. Now that we have set up our canvas environment, we can get into the details of how to draw on the canvas. By the end of this article, you will have learned how to draw rectangles, triangles, lines, arcs and curves, providing familiarity with some of the basic shapes. Working with paths is essential when drawing objects onto the canvas and we will see how that can be done.

The grid Before we can start drawing, we need to talk about the canvas grid or coordinate space. Our HTML skeleton from the previous page had a canvas element 150 pixels wide and 150 pixels high. To the right, you see this canvas with the default grid overlayed. Drawing rectangles Unlike SVG, <canvas> only supports one primitive shape: rectangles. First let's look at the rectangle. FillRect(x, y, width, height) Draws a filled rectangle. strokeRect(x, y, width, height) Draws a rectangular outline. clearRect(x, y, width, height) Clears the specified rectangular area, making it fully transparent.

Rectangular shape example stroke() The Five Best Libraries For Building Data Visualizations. An explosion in the number of available data sources and data-processing tools means that more people than ever are jumping into the world of data visualization. But with so much to learn, it can be intimidating to know just where to start. So which library is best, and what advice do the pros have? Read on and find out. Like telling the history of personal computers without mentioning Steve Jobs, it’s impossible to talk about data visualization without talking about D3. Arguably the most dominant and important programming library in the field, D3 (short for Data Driven Documents) is an open source JavaScript library usually used to generate SVG graphics.

SVG is a vector image format long supported by web browsers, but also historically underutilized. 2Reactions D3’s popularity owes a lot to the sudden interest in SVG by web designers--largely because vector graphics look superb on the kind of high-resolution screens (think Apple's Retina display), which are becoming increasingly common.

Quick tip: using HTML5 localstorage to store JSON objects on a device in your PhoneGap app. I’ve written a couple of articles about loading remote data into PhoneGap apps (sans framework), but I haven’t mentioned a good little method of storing that data on the device so you don’t need to request it from a server again. This is a quick tip for how you can do that. Of course, it depends on the type of data that you are loading from your server in the first place. You wouldn’t necessarily want to store data that would be out of date quickly – such as share prices or live sports scores. But there will certainly be times when you want to save the data you’ve just loaded for use at a later time, without having to load it again.

Loading data from a remote source When loading data from a remote source I’d use jQuery or Zepto’s ajax() function like this: In this example I’m accessing a fictional data source to load a news article. Once the article is loaded the user might browse another article but later on may return to read this particular one again. HTML5 local and session storage. Private Members in JavaScript. Douglas Crockford www.crockford.com JavaScript is the world's most misunderstood programming language. Some believe that it lacks the property of information hiding because objects cannot have private instance variables and methods. But this is a misunderstanding. JavaScript objects can have private members. Here's how. Objects JavaScript is fundamentally about objects. If a value is a function, we can consider it a method. Objects can be produced by constructors, which are functions which initialize objects. Public The members of an object are all public members.

In the constructor This technique is usually used to initialize public instance variables. Function Container(param) { this.member = param; } So, if we construct a new object var myContainer = new Container('abc'); then myContainer.member contains 'abc'. In the prototype This technique is usually used to add public methods. Container.prototype.stamp = function (string) { return this.member + string; } So, we can invoke the method Private. 31 days of Canvas tutorials. About. Callback Hell. JavaScript for Cats.