~/talk

Rubyist's Guide to the Canvas API

Talkat Cascadia Ruby 2012 · 2012-08-03..08-04· [ruby, web-platform]
links:none on file
slides:none on file

Canvas is a 2D immediate‑mode API that can be learned quickly, but real work comes from patterns: run a custom game loop that uses requestAnimationFrame over setTimeout to avoid millisecond drift, queue input/server events, update entity state, then draw. Use an entity + draw‑primitive split (position in the entity, pixel work in the primitive) with off‑screen canvases for double buffering. Tests stub the ~38 canvas calls and run headless with jsdom + a stubbed canvas and mocha; profiling uses Chrome Canary timeline and console.time. Entities + draw‑primitives enables swapping UI controls and gameplay sprites; requestAnimationFrame yields much smoother frames.

AI-written summary · about

  1. 0:00Introduction to canvas
  2. 2:58Canvas API overview
  3. 6:32Game loop fundamentals
  4. 11:08Optimizing with requestAnimationFrame
  5. 14:16Designing the game loop
  6. 16:45Entities and drawing primitives
  7. 23:03Testing with stubs
  8. 26:07Q&A and performance tips
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.