SlideShare uma empresa Scribd logo
1 de 20
Canvas: we must go deeper

                Szymon Piłkowski
   (freelancer, previously crytek & bigpoint)

            http://twitter.com/ard
Canvas?!




The canvas element provides scripts with a resolution-
dependent bitmap canvas, which can be used for
rendering graphs, game graphics, or other visual images
on the fly.
Canvas is a bitmap

•   one-dimensional array

•   [R,G,B,A,// pixel 0,0
     R,G,B,A,// pixel 1,0
     R,G,B,A,// pixel 2,0 (...)
    ]

•   point 0,0 placed in top left corner
Canvas basics
•   Immediate access (almost)

•   Low-level API




•   No scene graph, no direct access to drawn elements

•   Basic animation = redrawing everything each frame
Drawing on canvas




    (example from MDN)
Simple Game Loop
Pre-rendering / Buffering

•   Buffer is a copy of bitmap state (single frame) which is
    kept in memory

•   Buffers are known in Computer Graphics for 40 years

•   Using buffers you’re able to save and restore drawn
    states

•   ... and you can use them in JavaScript, too
Buffers in JS
• Wrong way:


• Slow, slow, slow
• still popular
Buffers in JS
• Good way
    context.drawImage: “can take either an HTMLImageElement,
    an HTMLCanvasElement, or an HTMLVideoElement for the image
    argument.”




    (another way: use toDataURL method)

•   As fast as drawing normal images
Buffers: performance
    optimisation
Buffers in games




(image from isocity by Rob Evans)
Render cycle
   Background layer (rendered once, never
   cleared)



    Static layer (rendered anew when
    invalidated)


    Dynamic layer (rendered anew each
    frame)
Render cycle (code)



 (needs to be tweaked per game)
Pre-processing sprites
• Saving disk space
• Saving designers time
• Improving the pipeline


 (from onslaught! arena case study on html5rocks.com)
Pre-processing sprites
Collision detection

• Problem: canvas is just a bitmap.
• You can’t attach events to drawn objects
• Detecting collision between a point (mouse
  pointer) and any rendered shape (image or
  primitive) is not straight-forward
Hitmap / Collision map

  1. map objects to unique colors
Hitmap / Collision map
  2. store in memory a copy of each
  object drawn in single color (using
        composite operations)
Hitmap / Collision map
3. when checking collisions, do a single render
          of candidates to a buffer



4. grab color from point and compare with
                 colorMap
end()

•   questions?

•   http://twitter.com/ard

•   szymon.pilkowski@gmail.com

•   Thanks!

Mais conteúdo relacionado

Mais procurados

Overview of graphics systems
Overview of  graphics systemsOverview of  graphics systems
Overview of graphics systemsJay Nagar
 
Animation software by Er. Suvisha Gupta
Animation software by Er. Suvisha GuptaAnimation software by Er. Suvisha Gupta
Animation software by Er. Suvisha GuptaSuvisha Gupta
 
Computer animation Computer Graphics
Computer animation Computer Graphics Computer animation Computer Graphics
Computer animation Computer Graphics University of Potsdam
 
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張Unite2017Tokyo
 
TMD2063 | Digital Animation - Chapter 2
TMD2063 | Digital Animation - Chapter 2TMD2063 | Digital Animation - Chapter 2
TMD2063 | Digital Animation - Chapter 2Diyana Harithuddin
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer GraphicsAdri Jovin
 
How Facebook cut image load times in half
How Facebook cut image load times in halfHow Facebook cut image load times in half
How Facebook cut image load times in halfTyrone Nicholas
 
Facebook tricks for image handling in Android
Facebook tricks for image handling in AndroidFacebook tricks for image handling in Android
Facebook tricks for image handling in AndroidTyrone Nicholas
 
Computer_Graphics_basic_definitions_summary
Computer_Graphics_basic_definitions_summaryComputer_Graphics_basic_definitions_summary
Computer_Graphics_basic_definitions_summaryDr. Mohamed Kazim
 
Armand Rousso describes about the Computer graphic
Armand Rousso describes about the Computer graphicArmand Rousso describes about the Computer graphic
Armand Rousso describes about the Computer graphicArmand Rousso
 
Animation techniques for CG students
Animation techniques for CG studentsAnimation techniques for CG students
Animation techniques for CG studentsMahith
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicschangehee lee
 

Mais procurados (20)

Overview of graphics systems
Overview of  graphics systemsOverview of  graphics systems
Overview of graphics systems
 
Deepak
DeepakDeepak
Deepak
 
Animation software by Er. Suvisha Gupta
Animation software by Er. Suvisha GuptaAnimation software by Er. Suvisha Gupta
Animation software by Er. Suvisha Gupta
 
Computer animation Computer Graphics
Computer animation Computer Graphics Computer animation Computer Graphics
Computer animation Computer Graphics
 
ANIMATION SEQUENCE
ANIMATION SEQUENCEANIMATION SEQUENCE
ANIMATION SEQUENCE
 
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
【Unite 2017 Tokyo】スクリプタブル・レンダーパイプラインのカスタマイズと拡張
 
TMD2063 | Digital Animation - Chapter 2
TMD2063 | Digital Animation - Chapter 2TMD2063 | Digital Animation - Chapter 2
TMD2063 | Digital Animation - Chapter 2
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Animation
AnimationAnimation
Animation
 
How Facebook cut image load times in half
How Facebook cut image load times in halfHow Facebook cut image load times in half
How Facebook cut image load times in half
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Facebook tricks for image handling in Android
Facebook tricks for image handling in AndroidFacebook tricks for image handling in Android
Facebook tricks for image handling in Android
 
Ch06
Ch06Ch06
Ch06
 
Animation
AnimationAnimation
Animation
 
Computer_Graphics_basic_definitions_summary
Computer_Graphics_basic_definitions_summaryComputer_Graphics_basic_definitions_summary
Computer_Graphics_basic_definitions_summary
 
Animations
AnimationsAnimations
Animations
 
Armand Rousso describes about the Computer graphic
Armand Rousso describes about the Computer graphicArmand Rousso describes about the Computer graphic
Armand Rousso describes about the Computer graphic
 
Animation techniques for CG students
Animation techniques for CG studentsAnimation techniques for CG students
Animation techniques for CG students
 
VFX
VFXVFX
VFX
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphics
 

Destaque

Inleiding social media
Inleiding social media Inleiding social media
Inleiding social media Lara Simons
 
Malta Ltd Company Formation - A Walk Through - 2014 - Acumum Legal & Advisory
Malta Ltd Company Formation - A Walk Through - 2014 - Acumum Legal & AdvisoryMalta Ltd Company Formation - A Walk Through - 2014 - Acumum Legal & Advisory
Malta Ltd Company Formation - A Walk Through - 2014 - Acumum Legal & AdvisoryAcumum - Legal & Advisory
 
fanscala1 1 インストールとreplまで
fanscala1 1 インストールとreplまでfanscala1 1 インストールとreplまで
fanscala1 1 インストールとreplまでToshiki Shinozaki
 
Summary Bisnis Plan Mikro Financing
Summary Bisnis Plan Mikro FinancingSummary Bisnis Plan Mikro Financing
Summary Bisnis Plan Mikro FinancingAmal Rifadly
 
Haskell vs. F# vs. Scala
Haskell vs. F# vs. ScalaHaskell vs. F# vs. Scala
Haskell vs. F# vs. Scalapt114
 
History of photography
History of photographyHistory of photography
History of photographymeganbvb
 
Закон об Aвиации Регистрация & Сервис - Мальтийская Международная Правовая фи...
Закон об Aвиации Регистрация & Сервис - Мальтийская Международная Правовая фи...Закон об Aвиации Регистрация & Сервис - Мальтийская Международная Правовая фи...
Закон об Aвиации Регистрация & Сервис - Мальтийская Международная Правовая фи...Acumum - Legal & Advisory
 
Malta Investor Funds - A Walk Through - By Acumum; Legal & Advisory
Malta Investor Funds - A Walk Through - By Acumum; Legal & AdvisoryMalta Investor Funds - A Walk Through - By Acumum; Legal & Advisory
Malta Investor Funds - A Walk Through - By Acumum; Legal & AdvisoryAcumum - Legal & Advisory
 
Malta - Tax Efficient Asset Structuring by Acumum
Malta - Tax Efficient Asset Structuring by AcumumMalta - Tax Efficient Asset Structuring by Acumum
Malta - Tax Efficient Asset Structuring by AcumumAcumum - Legal & Advisory
 

Destaque (18)

Inleiding social media
Inleiding social media Inleiding social media
Inleiding social media
 
fanscala1 3 sbt
fanscala1 3 sbtfanscala1 3 sbt
fanscala1 3 sbt
 
篠崎Lt20160909
篠崎Lt20160909篠崎Lt20160909
篠崎Lt20160909
 
Protest 簡介
Protest 簡介Protest 簡介
Protest 簡介
 
Malta Ltd Company Formation - A Walk Through - 2014 - Acumum Legal & Advisory
Malta Ltd Company Formation - A Walk Through - 2014 - Acumum Legal & AdvisoryMalta Ltd Company Formation - A Walk Through - 2014 - Acumum Legal & Advisory
Malta Ltd Company Formation - A Walk Through - 2014 - Acumum Legal & Advisory
 
fanscala1 2 scalaの基本
fanscala1 2 scalaの基本fanscala1 2 scalaの基本
fanscala1 2 scalaの基本
 
Malta’s Remittance System
Malta’s Remittance SystemMalta’s Remittance System
Malta’s Remittance System
 
fanscala1 1 インストールとreplまで
fanscala1 1 インストールとreplまでfanscala1 1 インストールとreplまで
fanscala1 1 インストールとreplまで
 
fanscala1 4 その他資料
fanscala1 4 その他資料fanscala1 4 その他資料
fanscala1 4 その他資料
 
Summary Bisnis Plan Mikro Financing
Summary Bisnis Plan Mikro FinancingSummary Bisnis Plan Mikro Financing
Summary Bisnis Plan Mikro Financing
 
Haskell vs. F# vs. Scala
Haskell vs. F# vs. ScalaHaskell vs. F# vs. Scala
Haskell vs. F# vs. Scala
 
History of photography
History of photographyHistory of photography
History of photography
 
Maritime by Acumum
Maritime by AcumumMaritime by Acumum
Maritime by Acumum
 
Закон об Aвиации Регистрация & Сервис - Мальтийская Международная Правовая фи...
Закон об Aвиации Регистрация & Сервис - Мальтийская Международная Правовая фи...Закон об Aвиации Регистрация & Сервис - Мальтийская Международная Правовая фи...
Закон об Aвиации Регистрация & Сервис - Мальтийская Международная Правовая фи...
 
Malta Investor Funds - A Walk Through - By Acumum; Legal & Advisory
Malta Investor Funds - A Walk Through - By Acumum; Legal & AdvisoryMalta Investor Funds - A Walk Through - By Acumum; Legal & Advisory
Malta Investor Funds - A Walk Through - By Acumum; Legal & Advisory
 
篠崎Lt20141215
篠崎Lt20141215篠崎Lt20141215
篠崎Lt20141215
 
Malta - Tax Efficient Asset Structuring by Acumum
Malta - Tax Efficient Asset Structuring by AcumumMalta - Tax Efficient Asset Structuring by Acumum
Malta - Tax Efficient Asset Structuring by Acumum
 
Malta Gaming Memo - Acumum Legal & Advisory
Malta Gaming Memo - Acumum Legal & AdvisoryMalta Gaming Memo - Acumum Legal & Advisory
Malta Gaming Memo - Acumum Legal & Advisory
 

Semelhante a Canvas: we must go deeper

Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)Marakana Inc.
 
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014
Benoit fouletier guillaume martin   unity day- modern 2 d techniques-gce2014Benoit fouletier guillaume martin   unity day- modern 2 d techniques-gce2014
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014Mary Chan
 
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...Lviv Startup Club
 
Overview of graphics systems.ppt
Overview of graphics systems.pptOverview of graphics systems.ppt
Overview of graphics systems.pptMalleshBettadapura1
 
Making a game with Molehill: Zombie Tycoon
Making a game with Molehill: Zombie TycoonMaking a game with Molehill: Zombie Tycoon
Making a game with Molehill: Zombie TycoonJean-Philippe Doiron
 
Introduction to Computer graphics
Introduction to Computer graphicsIntroduction to Computer graphics
Introduction to Computer graphicsLOKESH KUMAR
 
Mo devtablet johncromartie-graphicsperformance
Mo devtablet johncromartie-graphicsperformanceMo devtablet johncromartie-graphicsperformance
Mo devtablet johncromartie-graphicsperformancejohncromartie
 
Chapter 3 : IMAGE
Chapter 3 : IMAGEChapter 3 : IMAGE
Chapter 3 : IMAGEazira96
 
Game development terminologies
Game development terminologiesGame development terminologies
Game development terminologiesAhmed Badr
 
Prinsip gambar digital
Prinsip gambar digitalPrinsip gambar digital
Prinsip gambar digitalOno Trader
 
GJU MM Unit 3.pdf
GJU MM Unit 3.pdfGJU MM Unit 3.pdf
GJU MM Unit 3.pdfdiljots78
 
Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptxAvinashJain66
 
Stupid Canvas Tricks
Stupid Canvas TricksStupid Canvas Tricks
Stupid Canvas Tricksdeanhudson
 
OpenLayers 3.0
OpenLayers 3.0OpenLayers 3.0
OpenLayers 3.0Camptocamp
 
West Coast DevCon 2014: The Slate UI Framework (Part 2) - Game UI & Unreal Mo...
West Coast DevCon 2014: The Slate UI Framework (Part 2) - Game UI & Unreal Mo...West Coast DevCon 2014: The Slate UI Framework (Part 2) - Game UI & Unreal Mo...
West Coast DevCon 2014: The Slate UI Framework (Part 2) - Game UI & Unreal Mo...Gerke Max Preussner
 
TMD2063 | Digital Animation - Chapter 3
TMD2063 | Digital Animation - Chapter 3TMD2063 | Digital Animation - Chapter 3
TMD2063 | Digital Animation - Chapter 3Diyana Harithuddin
 

Semelhante a Canvas: we must go deeper (20)

Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)
 
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014
Benoit fouletier guillaume martin   unity day- modern 2 d techniques-gce2014Benoit fouletier guillaume martin   unity day- modern 2 d techniques-gce2014
Benoit fouletier guillaume martin unity day- modern 2 d techniques-gce2014
 
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...
 
Overview of graphics systems.ppt
Overview of graphics systems.pptOverview of graphics systems.ppt
Overview of graphics systems.ppt
 
Making a game with Molehill: Zombie Tycoon
Making a game with Molehill: Zombie TycoonMaking a game with Molehill: Zombie Tycoon
Making a game with Molehill: Zombie Tycoon
 
Introduction to Computer graphics
Introduction to Computer graphicsIntroduction to Computer graphics
Introduction to Computer graphics
 
Unit 11. Graphics
Unit 11. GraphicsUnit 11. Graphics
Unit 11. Graphics
 
Mo devtablet johncromartie-graphicsperformance
Mo devtablet johncromartie-graphicsperformanceMo devtablet johncromartie-graphicsperformance
Mo devtablet johncromartie-graphicsperformance
 
Chapter 3 : IMAGE
Chapter 3 : IMAGEChapter 3 : IMAGE
Chapter 3 : IMAGE
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Game development terminologies
Game development terminologiesGame development terminologies
Game development terminologies
 
Prinsip gambar digital
Prinsip gambar digitalPrinsip gambar digital
Prinsip gambar digital
 
Cocos2d programming
Cocos2d programmingCocos2d programming
Cocos2d programming
 
GJU MM Unit 3.pdf
GJU MM Unit 3.pdfGJU MM Unit 3.pdf
GJU MM Unit 3.pdf
 
K2P workshop 3-23-13
K2P workshop 3-23-13K2P workshop 3-23-13
K2P workshop 3-23-13
 
Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptx
 
Stupid Canvas Tricks
Stupid Canvas TricksStupid Canvas Tricks
Stupid Canvas Tricks
 
OpenLayers 3.0
OpenLayers 3.0OpenLayers 3.0
OpenLayers 3.0
 
West Coast DevCon 2014: The Slate UI Framework (Part 2) - Game UI & Unreal Mo...
West Coast DevCon 2014: The Slate UI Framework (Part 2) - Game UI & Unreal Mo...West Coast DevCon 2014: The Slate UI Framework (Part 2) - Game UI & Unreal Mo...
West Coast DevCon 2014: The Slate UI Framework (Part 2) - Game UI & Unreal Mo...
 
TMD2063 | Digital Animation - Chapter 3
TMD2063 | Digital Animation - Chapter 3TMD2063 | Digital Animation - Chapter 3
TMD2063 | Digital Animation - Chapter 3
 

Último

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Canvas: we must go deeper

  • 1. Canvas: we must go deeper Szymon Piłkowski (freelancer, previously crytek & bigpoint) http://twitter.com/ard
  • 2. Canvas?! The canvas element provides scripts with a resolution- dependent bitmap canvas, which can be used for rendering graphs, game graphics, or other visual images on the fly.
  • 3. Canvas is a bitmap • one-dimensional array • [R,G,B,A,// pixel 0,0 R,G,B,A,// pixel 1,0 R,G,B,A,// pixel 2,0 (...) ] • point 0,0 placed in top left corner
  • 4. Canvas basics • Immediate access (almost) • Low-level API • No scene graph, no direct access to drawn elements • Basic animation = redrawing everything each frame
  • 5. Drawing on canvas (example from MDN)
  • 7. Pre-rendering / Buffering • Buffer is a copy of bitmap state (single frame) which is kept in memory • Buffers are known in Computer Graphics for 40 years • Using buffers you’re able to save and restore drawn states • ... and you can use them in JavaScript, too
  • 8. Buffers in JS • Wrong way: • Slow, slow, slow • still popular
  • 9. Buffers in JS • Good way context.drawImage: “can take either an HTMLImageElement, an HTMLCanvasElement, or an HTMLVideoElement for the image argument.” (another way: use toDataURL method) • As fast as drawing normal images
  • 10. Buffers: performance optimisation
  • 11. Buffers in games (image from isocity by Rob Evans)
  • 12. Render cycle Background layer (rendered once, never cleared) Static layer (rendered anew when invalidated) Dynamic layer (rendered anew each frame)
  • 13. Render cycle (code) (needs to be tweaked per game)
  • 14. Pre-processing sprites • Saving disk space • Saving designers time • Improving the pipeline (from onslaught! arena case study on html5rocks.com)
  • 16. Collision detection • Problem: canvas is just a bitmap. • You can’t attach events to drawn objects • Detecting collision between a point (mouse pointer) and any rendered shape (image or primitive) is not straight-forward
  • 17. Hitmap / Collision map 1. map objects to unique colors
  • 18. Hitmap / Collision map 2. store in memory a copy of each object drawn in single color (using composite operations)
  • 19. Hitmap / Collision map 3. when checking collisions, do a single render of candidates to a buffer 4. grab color from point and compare with colorMap
  • 20. end() • questions? • http://twitter.com/ard • szymon.pilkowski@gmail.com • Thanks!

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n