際際滷

際際滷Share a Scribd company logo
Advanced Web Graphics
          with canvas
               jason harwig
I hate images..
quot;In general, if I can replace an
      image with code, I do so.quot;
                         - Wil Shipley
The Triangle Story
Advanced Web Graphics with Canvas
Uselesspickles.com
Advanced Web Graphics with Canvas
A better way (without images)
                        Images       Canvas
       diff / merge   not possible   possible
      changeability      hard         easy
   client download       large        small
client render speed       fast        slow
What is Canvas?
<canvas width=quot;100quot; height=quot;100quot;>

</canvas>
ctx = canvasElement.getContext('2d')

// ctx is CanvasRenderingContext2D
Advanced Web Graphics with Canvas
Advanced Web Graphics with Canvas
Advanced Web Graphics with Canvas
included in HTML 5
browser support
Safari     2.0+

Firefox    1.5+

Opera      9.0+

  IE       N/A
show me something cool
Polar clock
mario
mario kart
algorithm ink
processing.js
Mocha UI Demo
Advanced Web Graphics with Canvas
CVI - Christian Effenberger
Color picker
what should we make?
User Interface Graphics


 Nice looking UI controls
design for programmers
Shadows and Highlights
Safari
Firefox
220, 220, 220
197, 197, 197




150, 150, 150


222, 222, 222
201, 201, 201




158, 158, 158
Specular & diffuse lighting
Border shadows
2 pixel divide
most basic shadow / highlight
Advanced Web Graphics with Canvas
specular highlights
Advanced Web Graphics with Canvas
Advanced Web Graphics with Canvas
Advanced Web Graphics with Canvas
please bare with me
Advanced Web Graphics with Canvas
watch your light source
Multiple light sources

Re鍖ection

Visual complexity
be consistent
be subtle
Advanced Web Graphics with Canvas
Advanced Web Graphics with Canvas
canvas api
save      strokeRect      arcTo
   restore      beginPath       rect
     scale      closePath        arc
    rotate       moveTo          鍖ll
  translate       lineTo       stroke
 transform      quadratic        clip
setTransform    CurveTo      drawImage
  clearRect       bezier    createLinearGradient

   鍖llRect      CurveTo     createRadialGradient
Custom UI
Rich controls
 Graphing
 Star Rating control
 Loading Spinner
 際際滷r
 Button on Fire
Other Ideas?

 Icons
 Password Strength Meter
 Navigation Menu / Tabs
Drawing Text
 Support in Firefox 3

For Everything else:

  Draw Text with DOM absolutely position

  Draw text with lines manually

     strokeText.js (CVI)
lets talk about Internet
         Explorer..
 no native support today

 no word from Microsoft on this changing
Explorer Canvas
 Adapter API, canvas to VML
 No support for:
    globalComposition
    radialGradients
    drawImage with canvas
 Inserting canvas element via innerHTML
  requires document.createElement('canvas')
Browser Plugin developed by..
          Mozilla??

 Leave No Browser Behind
 ActiveX plugin that implements canvas
quot;I don't think iPhone brings anything new to
                                    the table.

It has a great user experience, but that's all.quot;
       Manjit Singh, CIO at Chiquita Brands International Inc.
Resources
quot;Triangles in CSSquot;                    quot;Processsing.jsquot;
uselesspickles.com                    ejohn.org/blog/processingjs/

quot;Polar Clockquot;                         quot;Mocha UIquot;
snipersystems.co.nz/community/        mochaui.com/demo/
polarclock/tutorial.html
                                      quot;CVIquot;
quot;JavaScript Gamesquot;                    netzgesta.de/cvi/
nihilogic.dk/labs/javascript-games/
                                      quot;Color Pickerquot;
quot;Algorithm Inkquot;                       sweetvision.com/2007/03/25/
azarask.in/projects/algorithm-ink/    enhanceing-the-javascript-color-
                                      picker-with-the-canvas-element/
More Resources
quot;Mac OS X Leopard Dockquot;            quot;No Browser Left Behindquot;
furbo.org/2007/07/03/the-hig-      blog.vlad1.com/2008/07/30/no-
still-matters-even-with-special-   browser-left-behind
effects/
                                   quot;Mozilla Canvas Tutorialquot;
quot;Navigation Menu Examplequot;          developer.mozilla.org/En/
zdotb.com                          Canvas_tutorial

quot;strokeText.jsquot;
netzgesta.de/dev/text

quot;Explorer Canvasquot;
excanvas.sourceforge.net
twitter: jharwig
jason.harwig@nearin鍖nity.com
    nearin鍖nity.com/blogs


  careers@nearin鍖nity.com


                               63

More Related Content

Advanced Web Graphics with Canvas