background preloader

HTML 5 Tutorial

Facebook Twitter

JavaScript object creation: Learning to live without "new" In this article, I'm going to discuss object creation in JavaScript using prototypal inheritance as an alternative to the new operator. One significant aspect of JavaScript is that there is rarely a single right way to do any particular task.

JavaScript is a loosely-typed, dynamic, and expressive language, which means that there are usually many different ways to accomplish the same task. I'm not saying that the methods described here to create objects are the only correct ways to do so or even the best ways, but I do feel that they are closer to the true nature of the language and will help you to understand what's going on under the covers if you choose to use other methods. To help you better understand these concepts, this article describes the creation of a basic particle system with multiple rendering targets.

This is a complex enough task to represent a real world test of the concepts I'll be demonstrating, rather than a simple hello world type of application. Adding inheritance. Documentation - oCanvas - Object-based canvas drawing. Bind a handler to an event on the canvas or a display object. Description Arguments type : String Event types that will trigger the handler. If multiple types are specified, separate them by a space. handler : Function The function that will be triggered when the event is triggered.

Return Value Core / displayObject. Examples Example 1 First we create an instance of the core object. View Example Code OutputReload Example 2 We create a new core instance and a rectangle that we add to the canvas. View Example. HTML5. HTML5 « jatinder s mann. In this IEBlog post, Paul and I announce Internet Explorer 9 support for HTML5 Canvas: 1 Jul 2010 6:24 PM With the recent release of the latest IE9 platform preview, we talked about how we’re rebuilding the browser to use the power of your whole PC to browse the web, and to unlock a new class of HTML5 applications. One area that developers are especially excited about is the potential of HTML5 canvas.

Like all of the graphics in IE9, canvas is hardware accelerated through Windows and the GPU. In this blog post we discuss some of the details behind canvas and the kinds of things developers can build. Canvas enables everything from basic shapes to fully interactive graphics Canvas is a way to program graphics on the web. At the most basic level, canvas enables you to draw primitives like lines, rectangles, arcs, Bezier curves, quadratic curves, images and video like the following: Taking things a step further, you can use JavaScript to animate canvas drawings or make interactive experiences.

Ball Pool. Drawing Simple Particle Systems with HTML5's Canvas Tag—david thomas bernal. Published 22 jun 2011 Inspired by this awesome series of articles on BIT-101 (Keith Peters’ blog, which I found via a tweet from Paul Irish) intended to introduce Flash developers to <canvas>, I finally decided to get down to learning some canvas tag for myself. Here’s a few things I made. Basics: a vibrating particle system To start off, I wanted to just get a handle on drawing and animating the particles using the 2D canvas API.

Less chaos: falling particles Next, I wanted to animate the particles in a more systematic way, so I made them fall with gravity. More chaos! Another simple addition to this was to make the particles bounce off the walls. Emitting Particles The first three follow from each other in a pretty straightforward way, so I wanted to do something else. Particle networks! Finally I wanted to do something way different, so I looked again at BIT-101.

In my case, I decided I’d draw simple points that floated around and made connections with the nearby points around them. Untitled. Welcome Below you will find a step by step guide that should answer all your questions about Twitbin. You will find FAQs, how-to-guides, and videos. If you have questions not answered here, you can always email our support department and usually get a response within 72 hours. Installation Instructions Following these steps you should be able to get Twitbin running in most modern computers quickly and easily. Installing the plugin: Click here to download and install the plugin from MozillaHit Accept when Firefox asks you for permissionsRestart FirefoxClick the bird icon up top to open Twitbin Frequently Asked Questions How do I login to Twitbin? HTML5 Canvas Modify Curves with Anchor Points Using KineticJS.

CSS Buttons [Sophie’s maze] Rollover buttons & icons with CSS The goal was to create buttons for an intranet using CSS. These buttons are composed of a background image, an icon and a label. To allow for flexibility and save bandwidth, the same background image is used for all buttons, and the icon is chosen depending on the id of the button. Ok The styles of this website might interfere with the look of the button, check it in a separate window. You can view the CSS file or download it along with the button images.

Button shape To create the button, we’ll use a <a href> html tag. <a href="javascript:return false;" class="button" id="buttonOK"><span class="icon">Ok</span></a> The “javascript:return false;” part will be replaced by a link or a javascript function. That’s all the html we’ll use, everything else happens in the CSS file. The link is set to be a block element of 132×28 pixels (which matches the background image size), and we use the “buttonBackground.gif” image, without repeating it. Import. Untitled. Navigation Tab Menu Generator CSS - Tabs Generator. Defining classes and inheritance. In early versions of Prototype, the framework came with basic support for class creation: the Class.create() method.

Until now the only feature of classes defined this way was that the constructor called a method called initialize automatically. Prototype 1.6.0 now features a richer class system that's backward-compatible and adds some new features. The cornerstone of class creation in Prototype is still the Class.create method. If you have legacy Prototype code, your class-based code will continue to work as before, but now you don't have to work with prototypes directly or use Object.extend to copy properties around. Example Suppose you have legacy Prototype class-based code that looks like htis: Observe the direct interaction with class prototypes and the clumsy inheritance technique using Object.extend.

This has changed for the better. You can see how both class and subclass definitions are shorter because you don't need to hack their prototypes directly anymore. How to mix-in modules <? Top 10 custom JavaScript functions of all time. Wednesday Nov 30 2005 UPDATE: For anyone who lands on this article months after the fact, there is now a podcast entry about this article reviewing each and every function. If there was ever a universal common.js shared among the entire develosphere, you'd fine these ten (plus one bonus) functions. It would be the swiss army knife no developer would go into production without. They have no doubt been tested tried and true and have proven usefulness and helpfulness to all those who've used them. So without further ado, here are what I believe to the top ten greatest custom JavaScript functions in use today.

Upon further reading this article, it is suggested that for this article in particular the reader should use an alternate style with cleaner whitespace and larger margins. 10) addEvent() Surely a staple to event attachment! Scott Andrew's original addEvent() function 9) addLoadEvent() addLoadEvent() by Simon Willison assigning multiple load events to window 8) getElementsByClass() Model-View-Controller (MVC) with JavaScript | Alex @ Net. By Alex Netkachov, (revised BTW, check out JavaScript news feed. Hope you like it. The article demonstrates how to apply the Model-View-Controller software design pattern while developing a simple JavaScript component.

I like JavaScript because it is one of the most flexible languages in the world. My goal for this article is to demonstrate how to apply the Model-View-Controller pattern while developing a simple JavaScript component. I hope, this article will be a good reading for you, but it would be much better if you consider to run the examples and adapt them to you needs. The Model-View-Controller pattern requires some description here. Model - The domain-specific representation of the information on which the application operates.

The data of the component is just a list of items, in which one particular item can be selected and deleted. Event is a simple class for implementing the Observer pattern: The View class requires defining controls for interacting with. Example: Flexibility? HTML5 - Microdata. Microdata is a standardized way to provide additional semantics in your web pages. Microdata lets you define your own customized elements and start embedding custom properties in your web pages. At a high level, microdata consists of a group of name-value pairs. The groups are called items, and each name-value pair is a property. Items and properties are represented by regular elements. Example To create an item, the itemscope attribute is used.To add a property to an item, the itemprop attribute is used on one of the item's descendants.

Here there are two items, each of which has the property "name" − <html><body><div itemscope><p>My name is <span itemprop="name">Zara</span>. It will produce the following result − Properties generally have values that are strings but it can have following data types − Global Attributes Micro data introduces five global attributes which would be available for any element to use and give context for machines about your data.

Properties Datatypes. HTML5 Tutorials Learn Reference. A Gentle Introduction to Making HTML5 Canvas Interactive - simonsarris.com. I wrote a book on HTML5, including three chapters on Canvas! Buy it here. This is a big overhaul of one of my tutorials on making and moving shapes on an HTML5 Canvas. This new tutorial is vastly cleaner than my old one, but if you still want to see that one or are looking for the concept of a “ghost context” you can find that one here. This tutorial will show you how to create a simple data structure for shapes on an HTML5 canvas and how to have them be selectable. Click to drag the shapes. We’ll be going over a few things that are essential to interactive apps such as games (drawing loop, hit testing), and in later tutorials I will probably turn this example into a small game of some kind. The HTML5 Canvas A Canvas is made by using the <canvas> tag in HTML: A canvas isn’t smart: it’s just a place for drawing pixels.

Canvas also has no built-in way of dealing with animation. So we’ll need to add: The things we draw . They are pretty self-explanatory. Keeping track of canvas state Drawing.