background preloader

Introducing HTML5: Bruce Lawson and Remy Sharp

Introducing HTML5: Bruce Lawson and Remy Sharp

An introduction to the Canvas 2D API If the <video> element is the poster boy of HTML5, then <canvas> is definitely Danny Zuko. The <canvas> element is (still) part of the HTML5 specification, but the 2D drawing API has been moved into a separate document (in case you go looking and can’t find it). <canvas> has a wealth of features, like: drawing shapes,filling colours,creating gradients and patterns,rendering text,copying images, video frames, and other canvases,manipulating pixels, andexporting the contents of a <canvas> to a static file. In fact, the canvas API is so interesting, I wouldn’t be surprised to see entire books dedicated to it (and no, I don’t plan to write that book!). It’s important when working with <canvas> to treat it like a real painting canvas. Four of the Big Five browsers support canvas. Always consider the options Before we dive in to the canvas API, I want to remind you to make sure you’re using the right technology for the job. SVG is the alternative drawing API. Hello Canvas Code snippet Code snippet

HTML5 Canvas Demos and Applications To Make You Say WOW Our today’s post is on HTML5 Canvas Applications and Demos. Being the last day of this calender year, we were bit skeptical on topic to choose. After thinking for quite a while we chose HTML5 Canvas Applications over others as we wanted to portray a different subject. The Most astonishing facet of HTML5 is the HTML5 canvas. Advertisement DeviantART muro The tool can be used as a stand-alone web application as well as a lightweight drawing tool for adding pictures to forum comments. More Info on DeviantART muro Super Mario Kart Play JavaScript Super Mario Kart Online. More Info on Super Mario Kart Canvas Cartoon Animation that’s as good as Flash This short animation is as good as Flash, this is surely to amaze you. More Info on Canvas Cartoon Animation that’s as good as Flash Asteroid Belt sample Introducing hardware accelerated canvas, video and audio. More Info on Asteroid Belt sample Bert’s Breakdown More Info on Bert’s Breakdown Canvas + SoundManager Audio Player with Waveform effects Fishtank

» Using Multiple HTML5 Canvases as Layers DEMO Here’s our finished canvas with full source code. The reasons why you would want to layer multiple canvases on top of each other are many but they all have a common root. There is a requirement in the W3C definition of the 2d context… There is only one CanvasRenderingContext2D object per canvas, so calling the getContext() method with the 2d argument a second time must return the same object. Having just one 2d context means that you have to keep track of everything on the context even if you only want to change part of the canvas. An example of using layers is animation. In this example, our three canvases have transparent areas that allow you to see what is on the canvas beneath each. First, let’s look at our three canvases separately and then we’ll stack them on top of each other. Our bottom layer The code for this animation is fully explained here. Our middle layer Our top layer Now to stack them

HTML5 sectioning elements, headings, and document outlines A subject I have returned to a couple of times is how to use headings to make good document outlines in HTML documents. See Headings and document structure conclusions for a summary of my reasoning. Recently I’ve been taking a closer look at how HTML5 changes the way document outlines are created. I’m not entirely sure that I have understood the specification fully, but if I have, I think the new outline algorithm requires you to think carefully when using the new sectioning elements (article, section, nav, and aside) if you also want a coherent document outline without untitled sections. The HTML 4.01 outline To explain what I mean, let’s look at some examples. <body><div id="header">Site title etc. That creates the following document outline (you can use the Web Developer extension to check document outlines): Article title Article sub-heading Article sub-sub-heading Sidebar heading Sidebar sub-heading Footer heading The HTML5 outline <body><header> Site title etc. Say what?

Home | LimeJS HTML5-Handbuch - Webkompetenz Wenn Sie den Inhalt der Site diskutieren möchten - dies ist der leichteste Weg dies zu tun. Klicken Sie hier um den Inhalt der Seite zu ändern. Klicken Sie hier um auf das Ändern von einzelnen Sektionen hin- und herzuschalten (wenn möglich). Achten Sie auf die Überschriften ob daneben ein "Bearbeiten" Link erscheint. Inhalt hinzufügen ohne den ganzen Seiteninhalt zu editieren Prüfen Sie, wie Sie diese Seite sich in der Vergangenheit entwickelt hat. Betrachten und Verwalten von Datei-Anhängen für diese Seite. Einige nützliche Werkzeuge zum Verwalten Ihrer Site Ändern des Namens der Seite (auch URL Adresse, eventuell die Kategorie). Ansicht des Seiten-Quelltextes ohne Änderung. Ansicht /Einsetzen "Eltern" Seite (benutzt um "Breadcrumbs" und Layout-Struktur zu erstellen). Benachrichtigen Sie die Administratoren, wenn Sie anstößige Inhalte auf dieser Seite finden. Einiges funktioniert nicht wie erwartet? Allgemeine Wikidot.com-Dokumentation und Hilfebereich. Wikdiot.com - Datenschutz

Canvas bitmap operations - bitblt in JavaScript With Canvas you can now work with bitmaps at the pixel level. It's not difficult but you need to organise things to make it really easy. One of the operations that low-level APIs tend to give you that higher level graphics systems tend to ignore is the bitblt - bit-block operation (pronounced bit-blit). What has this got to do with graphics? The answer is that in many cases the bits represented the pixels of a bitmap and the bitblt was one way to update or modify another bitmap by copying another bitmap into it. Until the canvas object was introduced as part of HTML5 JavaScript could be used to load and display images but you couldn't dynamically modify or generate images. It is assumed that you know the basics of using the canvas tag. The first part of the canvas bitmap operations that we need to look at is the drawImage method. The source for a bitmap can either be a bitmap object, another canvas object or a video object. For example suppose the page contains an image: For example:

Dictionary Lookups in JavaScript I’ve been working on a browser-based word game, naturally written in JavaScript, and have been encountering some interesting technical challenges along the way. I’ve written up my thought process here for others to learn from (note that most of this happened over the course of a month, or so). I’ve often found that while a final solution to a problem may be rather elegant and “make perfect sense” when looking at it – it’s only through the result of much trial and error that the solution was arrived upon. To start, in my game, the user is frequently re-arranging letters – causing the game to look up words in a dictionary to see if they are valid, or not. I’ve taken multiple passes at implementing a solution to this problem, ranging all the way from “I don’t care about performance, I just want it to work” all the way up to “thousands of people could be playing simultaneously, how do I scale?” Server-Side Solution The first pass was stupid simple. Thus you would call the PHP script like so:

Semantics You are here: Home Dive Into HTML5 Diving In This chapter will take an HTML page that has absolutely nothing wrong with it, and improve it. Parts of it will become shorter. Parts will become longer. All of it will become more semantic. Here is the page in question. The Doctype From the top: This is called the “doctype.” Microsoft came up with a novel solution. This idea spread like wildfire, and soon all major browsers had two modes: “quirks mode” and “standards mode.” In his seminal work, Activating Browser Modes with Doctype, Henri Sivonen summarizes the different modes: Quirks Mode In the Quirks mode, browsers violate contemporary Web format specifications in order to avoid “breaking” pages authored according to practices that were prevalent in the late 1990s. (You should read the rest of Henri’s article, because I’m simplifying immensely here. Now then. That happens to be one of the 15 doctypes that trigger “standards mode” in all modern browsers. This is the HTML5 doctype: That’s it. <!

Related: