SlideShare a Scribd company logo
1 of 14
D I N A G O L D S H T E I N
HTML5 Canvas
Agenda
 HTML5 Introduction
 Canvas Motivation
 Canvas Basics
 One Big Demo 
Why HTML5?
 Internet has changed a lot since 1996
 SpaceJam vs. Google Docs
 HTML5 is the latest HTML standard
 Delivers rich content without the need for external
plugins
 Replaces some scripting with more markup
 All major browsers support it (to some extent*)
 * http://html5test.com/
What’s New in HTML5?
 <canvas> element for 2D drawing
 <video> and <audio> for media playback
 Local storage support
 Geolocation API
 Web Workers for background calculations
 Semantic elements like <article>, <footer>,
<header>, <aside>
 Tons of input controls: color, email, date, time
 And much more…
What Can Canvas do for You?
 Well, pretty much anything…
 Cloth Experiment
 Angry Birds
 Shared Canvas
 Lots of other (less cool) examples
Canvas Basic
 The Canvas element allows you to draw 2D graphics,
on the fly, on a Web page, using JavaScript
 The HTML5 canvas is a lot like a real-world painting
canvas
 You can use different colors and different brushes
 You can rotate it or move it around
 Anything you paint on it stays in place until you delete it
 You can resize it
 But it’s also a bit different, duh 
Hello Canvas
DEMO
Canvas Basic Recipe
 Get Canvas element
 Get drawing context from element
 Repeat:
 Save context properties
 Set new properties: fill style, stroke style, transform
 Begin path
 Define path
 Close path (if needed)
 Fill and/or stroke
 Restore original properties
What is a Path?
 A path is a series of points connected by lines
 Use beginPath to initialize a path
 Use lineTo, arcTo, etc. to connect lines
 Stroke and/or fill as see fit
 A path can be closed
 Use closePath to connect last point to first point
 A path doesn’t have to be continuous
 Use moveTo to create discontinuous sections in a path
Paths
DEMO
Canvas Features
Styling
• fillStyle
• strokeStyle
• lineCap
• lineWidth
Shapes
• rect
• fillRect
• srokeRect
• clearRect
• arc
Paths
• fill
• stroke
• beginPath
• closePath
• moveTo
Lines
• lineTo
• quadraticCurveTo
• bezierCurveTo
• arcTo
Text
• font
• fillText
• strokeText
• measureText
Images
• drawImage
Pixel Manipulation
• createImageData
• getImageData
• putImageData
Transformations
• scale
• rotate
• translate
• transform
Transformations
DEMO
Grand Finale - PaintJS
DEMO
Questions?

More Related Content

Similar to HTML5 Canvas

Html5workshop
Html5workshopHtml5workshop
Html5workshop
shiv3110
 
Fii Practic Frontend - BeeNear - laborator 4
Fii Practic Frontend - BeeNear - laborator 4Fii Practic Frontend - BeeNear - laborator 4
Fii Practic Frontend - BeeNear - laborator 4
BeeNear
 

Similar to HTML5 Canvas (20)

Html5workshop
Html5workshopHtml5workshop
Html5workshop
 
P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218
 
Graphics on the Go
Graphics on the GoGraphics on the Go
Graphics on the Go
 
Fii Practic Frontend - BeeNear - laborator 4
Fii Practic Frontend - BeeNear - laborator 4Fii Practic Frontend - BeeNear - laborator 4
Fii Practic Frontend - BeeNear - laborator 4
 
Meetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergMeetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - Gutenberg
 
Meetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergMeetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - Gutenberg
 
A forest of designs without subthemes
A forest of designs without subthemesA forest of designs without subthemes
A forest of designs without subthemes
 
Google tools for webmasters
Google tools for webmastersGoogle tools for webmasters
Google tools for webmasters
 
An introduction to inkscape
An introduction to inkscapeAn introduction to inkscape
An introduction to inkscape
 
Bootstrap Paragraphs for Drupal 8
Bootstrap Paragraphs for Drupal 8Bootstrap Paragraphs for Drupal 8
Bootstrap Paragraphs for Drupal 8
 
New Elements & Features in HTML5
New Elements & Features in HTML5New Elements & Features in HTML5
New Elements & Features in HTML5
 
Html canvas
Html canvasHtml canvas
Html canvas
 
Building Blocks For Your Modules Ui
Building Blocks For Your Modules UiBuilding Blocks For Your Modules Ui
Building Blocks For Your Modules Ui
 
MTA html5 text_graphics_media
MTA html5 text_graphics_mediaMTA html5 text_graphics_media
MTA html5 text_graphics_media
 
Cut psd to xthml
Cut psd to xthmlCut psd to xthml
Cut psd to xthml
 
Introduction to Bootstrap: Design for Developers
Introduction to Bootstrap: Design for DevelopersIntroduction to Bootstrap: Design for Developers
Introduction to Bootstrap: Design for Developers
 
Auto cad hatch layer tips &amp; tricks
Auto cad hatch layer tips &amp; tricksAuto cad hatch layer tips &amp; tricks
Auto cad hatch layer tips &amp; tricks
 
Fabricjs ppt
Fabricjs pptFabricjs ppt
Fabricjs ppt
 
Html5
Html5Html5
Html5
 
Building appsinsilverlight4 part_1
Building appsinsilverlight4 part_1Building appsinsilverlight4 part_1
Building appsinsilverlight4 part_1
 

More from Dina Goldshtein

More from Dina Goldshtein (17)

How Does the Internet Work? (Wix she codes; branch)
How Does the Internet Work? (Wix she codes; branch)How Does the Internet Work? (Wix she codes; branch)
How Does the Internet Work? (Wix she codes; branch)
 
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
 
Look Mommy, No GC! (TechDays NL 2017)
Look Mommy, No GC! (TechDays NL 2017)Look Mommy, No GC! (TechDays NL 2017)
Look Mommy, No GC! (TechDays NL 2017)
 
Self-Aware Applications: Automatic Production Monitoring (TechDays NL 2017)
Self-Aware Applications: Automatic Production Monitoring (TechDays NL 2017)Self-Aware Applications: Automatic Production Monitoring (TechDays NL 2017)
Self-Aware Applications: Automatic Production Monitoring (TechDays NL 2017)
 
ETW - Monitor Anything, Anytime, Anywhere (Velocity NYC 2017)
ETW - Monitor Anything, Anytime, Anywhere (Velocity NYC 2017)ETW - Monitor Anything, Anytime, Anywhere (Velocity NYC 2017)
ETW - Monitor Anything, Anytime, Anywhere (Velocity NYC 2017)
 
Look Mommy, no GC! (.NET Summit 2017)
Look Mommy, no GC! (.NET Summit 2017)Look Mommy, no GC! (.NET Summit 2017)
Look Mommy, no GC! (.NET Summit 2017)
 
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
 
Look Mommy, no GC! (BrightSource)
Look Mommy, no GC! (BrightSource)Look Mommy, no GC! (BrightSource)
Look Mommy, no GC! (BrightSource)
 
ETW - Monitor Anything, Anytime, Anywhere (NDC Oslo 2017)
ETW - Monitor Anything, Anytime, Anywhere (NDC Oslo 2017)ETW - Monitor Anything, Anytime, Anywhere (NDC Oslo 2017)
ETW - Monitor Anything, Anytime, Anywhere (NDC Oslo 2017)
 
Look Mommy, no GC! (SDP May 2017)
Look Mommy, no GC! (SDP May 2017)Look Mommy, no GC! (SDP May 2017)
Look Mommy, no GC! (SDP May 2017)
 
Look Mommy, No GC! (Codecamp Iasi 2017)
Look Mommy, No GC! (Codecamp Iasi 2017)Look Mommy, No GC! (Codecamp Iasi 2017)
Look Mommy, No GC! (Codecamp Iasi 2017)
 
Look Mommy, No GC! (NDC London 2017)
Look Mommy, No GC! (NDC London 2017)Look Mommy, No GC! (NDC London 2017)
Look Mommy, No GC! (NDC London 2017)
 
How does the Internet Work?
How does the Internet Work?How does the Internet Work?
How does the Internet Work?
 
How does the Internet Work?
How does the Internet Work?How does the Internet Work?
How does the Internet Work?
 
Things They Don’t Teach You @ School
Things They Don’t Teach You @ SchoolThings They Don’t Teach You @ School
Things They Don’t Teach You @ School
 
What's New in C++ 11/14?
What's New in C++ 11/14?What's New in C++ 11/14?
What's New in C++ 11/14?
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Recently uploaded (20)

Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

HTML5 Canvas

  • 1. D I N A G O L D S H T E I N HTML5 Canvas
  • 2. Agenda  HTML5 Introduction  Canvas Motivation  Canvas Basics  One Big Demo 
  • 3. Why HTML5?  Internet has changed a lot since 1996  SpaceJam vs. Google Docs  HTML5 is the latest HTML standard  Delivers rich content without the need for external plugins  Replaces some scripting with more markup  All major browsers support it (to some extent*)  * http://html5test.com/
  • 4. What’s New in HTML5?  <canvas> element for 2D drawing  <video> and <audio> for media playback  Local storage support  Geolocation API  Web Workers for background calculations  Semantic elements like <article>, <footer>, <header>, <aside>  Tons of input controls: color, email, date, time  And much more…
  • 5. What Can Canvas do for You?  Well, pretty much anything…  Cloth Experiment  Angry Birds  Shared Canvas  Lots of other (less cool) examples
  • 6. Canvas Basic  The Canvas element allows you to draw 2D graphics, on the fly, on a Web page, using JavaScript  The HTML5 canvas is a lot like a real-world painting canvas  You can use different colors and different brushes  You can rotate it or move it around  Anything you paint on it stays in place until you delete it  You can resize it  But it’s also a bit different, duh 
  • 8. Canvas Basic Recipe  Get Canvas element  Get drawing context from element  Repeat:  Save context properties  Set new properties: fill style, stroke style, transform  Begin path  Define path  Close path (if needed)  Fill and/or stroke  Restore original properties
  • 9. What is a Path?  A path is a series of points connected by lines  Use beginPath to initialize a path  Use lineTo, arcTo, etc. to connect lines  Stroke and/or fill as see fit  A path can be closed  Use closePath to connect last point to first point  A path doesn’t have to be continuous  Use moveTo to create discontinuous sections in a path
  • 11. Canvas Features Styling • fillStyle • strokeStyle • lineCap • lineWidth Shapes • rect • fillRect • srokeRect • clearRect • arc Paths • fill • stroke • beginPath • closePath • moveTo Lines • lineTo • quadraticCurveTo • bezierCurveTo • arcTo Text • font • fillText • strokeText • measureText Images • drawImage Pixel Manipulation • createImageData • getImageData • putImageData Transformations • scale • rotate • translate • transform
  • 13. Grand Finale - PaintJS DEMO

Editor's Notes

  1. שלום לכולן. קוראים לי דינה גולדשטיין. אני מפתחת תוכנה בחברת ברייטסורס. אני חלק מצוות תשתיות תוכנה שמתעסק בהרבה מאוד תחומים וכותב בכמה שפות ומשתמש בהרבה טכנולוגיות. בשנה האחרונה התחלנו להיכנס לתחום הווב ולי ספציפית יצא להתעסק די הרבה עם ה-canvas. החברה שאני עובדת בה בונה שדות סולריים שמורכבים מעשרות אלפי מראות שמכוונות את אנרגיית השמש לדוד שמש גדול. שם המים מתחממים עד שנוצר קיטור ואני אמנם לא מומחית בזה אבל הפיסיקאים מספרים שמשם המרחק לחשמל הוא כבר לא מאוד גדול. בכל מקרה, המשימה העיקרית שלי בצוות התשתיות הייתה ליצור תשתית שמאפשרת תצוגה של השדה הסולרי הזה, עם עשרות אלפי המראות שיכולות לזוז ולהיצבע בצבעים שונים לפי פרמטרים שונים. אלה מכן שקצת יש להן ניסיון בווב בטח יודעות שאי אפשר לשים ב-HTML אלפי אלמנטים, שלא לדבר על עשרות אלפים. בשביל תצוגה בסדר גודל כזה שתהיה גם יפה ויעילה וללא תתקע את הדפדפן צריך לפנות לשיטות אחרות. ה-canvas הוא שבא לעזרה. בסוף ההרצאה תכירו מושגים בסיסיים ושיטות עבודה עם ה-canvas ותוכלו להתחיל לכתוב פיצ׳רים מגניבים לאתרים שלכן 
  2. נחלק היום את הזמן שלנו לכמה חלקים. ראשית, אציג בפניכן את הסטנדרד החדש HTML5 אשר canvas הוא חלק ממנו. אחר כך נסתכל על כמה דוגמאות מגניבות לשימוש ב-canvas. אני אמנם לא יכולה להראות לכן את מה שעשיתי בברייטסורס אבל האינטרנט מלא מדברים ממש מגניבים ומרשימים. לאחר מכן נעשה דוגמה קצרה סגנון hello world ואז נפנה למשימה העיקרית שלנו שהיא פיתוח אתר שאת התוכן שלו אשמור בסוד עד רגע האמת (אלה שקראו את התקציר בפייסבוק או ב-meetup מתבקשים לשמור על ההפתעה יחד איתי)
  3. אני הולכת לחזור על חלק קטן מהרצאת המבוא שהייתה כאן לפני כמה דקות אז לאלה שהיו בהקדמה – אני מתנצלת. זה לא יהיה ארוך. כדי להעריך את מה שאנחנו הולכים ללמוד היום אני רוצה להראות לכן איך האינטרנט נראה פעם. הרבה דברים קרו מאז שנת 1996. חיפשתי קצת באינטרנט ויש אתר ממש מפורסם ששרד בצורתו המקורית עוד משנת 1996. זה האתר של הסרט ספייס ג׳אם. הכל סטטי ודי מכוער אם לומר את האמת. ממש זועק מזה שנות ה-90 ככה  לעומתו, כבר מזה זמן מה יש לנו גישה לאתרים כמו גוגל דוקס. זה ממש מדהים בעיני. זו כבר לא אפליקציה שצריך להתקין (שלא לדבר על לקנות) ואז להתקין עדכונים ועוד עדכונים ועוד עדכונים, ולחכות שנה עד שתצא גרסה חדשה עם כל תיקוני הבאגים. זה פשוט אתר אינטרנט שהגרסה שלו יכולה להתעדכן פעם בשבוע או אפילו יותר מפעם אחת ביום בלי שהמשתמשים בכלל ישימו לב, והוא מתפקד כמו וורד או אקסל או פאוור פוינט. אפשר לשמור מסמכים, לחלוק מסמכים עם חברים, אפילו לערוך מסמכים במקביל בזמן שאתם מחוברים לרשת. ומצד שני כל הפלא הזה יכול לעבוד אפילו אם אתם לא מחוברים. וכשמתישהו תתחברו אז הכל יסתנכרן ויעבוד כאילו לא קרה כלום. אז אכן הרבה השתנה מאז 1996... לאחרונה גם הצטרף לחגיגה הסטנדרט החדש HTML5. הוא מוסיף כל מיני פיצ׳רים חדשים שעד כה היה צורך בפלאגינים חיצוניים בשבילם (למשל פלאש) או בכתיבת קוד מאחורי העמוד. כל הדפדפנים הראשיים תומכים בו (לא באופן מלא אבל כמעט הכל). את הפיצ׳רים הנתמכים אפשר לבדוק באינטרנט. יש הרבה אתרים שמספקים את הרשימות. זה אחד מהם. יש גם ספריה שנקראית modernizer שמאפשרת לבדוק בקוד תמיכה בפיצ׳ר מסוים בדפדפן שאתם רצים בו.
  4. הסטנדרט החדש נותן המון פיצ׳רים חדשים. את הרשימה המלאה אפשר למצוא באינטרנט אבל כתבתי כאן את הדברים שנראו לי יותר מעניינים. הדבר הראשון הוא כמובן ה-canvas שעליו אנחנו נבלה את שאר הזמן שלנו ביחד. אבל יש עוד כמה דברים נחמדים מאוד. למשל, אלמנטים חדשים לתצוגה של וידאו או לקבצי שמע. זה אפילו תומך בהצגה של כתוביות. יש תמיכה בשמירה מקומית של נתונים (ככה אתם יכולים לכתוב מיילים בג׳ימייל למרות שאתם לא מחוברים לאינטרנט). יש ממשק חדש שמאפשר לכם לקבל מיקום גיאוגרפי של המשתמש. אז למשל תוכלו להתאים את שפת האתר לפי הארץ שממנה מתחברים או שתוכלו לברר באיזו עיר נמצא המשתמש ולהציג לו נתונים של מזג אוויר או מפת פקקים. עד שהגיע HTML5 כל העבודה של הג׳אווה סקריפט והתצוגה של האתר היו מתבצעות בתהליכון אחד. כעת בעזרת web workers ניתן להעביר עבודות ארוכות שעלולות לתקוע את הממשק לתהליכון שיריץ אותן ברקע. כשהעבודה מסתיימת ניתן להעביר הודעה לתהליכון הראשי ולעדכן את ממשק המשתמש בהתאם. יש גם הרבה אלמנטים חדשים שבאים לתת משמעות סמנטית. הם לא משנים את האופן שבו הדף נראה, אבל כשמשתמשים בהם ניתן להבין קצת יותר בקלות מה הכוונה. למשל article מייצג תוכן שקשור לנושא מסוים. בעמוד אחד יכולים להיות כמה articles. ואילו header ו-footer מייצגים את ראש העמוד ותחתיתו בהתאמה. אם נשים את ה-header בלמטה של ה-HTML הוא יופיע בתחתית העמוד. זאת הכוונה כאשר אנחנו אומרים שאלה אלמנטים סמנטיים. האחריות היא עלינו לשים אותם במקום הנכון, אבל כשנקרא את הקוד אחר כך תהיה ברורה הכוונה שהאזור הזה הוא הלמעלה של הדף ואילו אזור אחד הוא הלמטה. aside לעומת זאת זה משהו שאמור להופיע בצד הדף. יחד עם האלמנטים הסמנטיים נוספו גם המון אלמנטים חדשים לסוגים שונים של קלט – צבעים, אימייל, תאריכים, זמן וכו׳. זה דווקא משהו שלא כל הדפדפנים תומכים בו באופן מלא וחלק מהדפדפנים לא מממשים חלק מסוגי הקלט. אבל מה שנחמד הוא שבמקרה הגרוע פשוט תופיעה לכם תיבת טקסט שצריך להכניס בה את הערכים ידנית, אז אמנם ההכנסה לא תהיה מאוד נוחה אבל חוץ מזה ניתן להשתמש בערך שהוכנס כרגיל. את האלמנט שמאפשר בחירת צבעים אנחנו נראה בהמשך.
  5. לפני שניכנס לפרטים הטכניים אני רוצה לתת קצת מוטיבציה.
  6. מה קורה מאחורי הקלעים? אלמנט ה-canvas מאפשר למפתח לצייר גרפיקה דו-ממדית על המסך בזמן אמת (לא במובן של מערכות זמן אמת אלא במובן שבזמן שהאתר רץ והמשתמש עושה פעולות – online לעומת real time) באמצעות כתיבת קוד ג׳אווה סקריפט. שמעתי באיזו הרצאה אנלוגיה שהקנבס של HTML הוא ממש כמו קנבס ציור בעולם האמיתי. מאוד התחברתי לאנלוגיה הזאת ואני חושבת שכדאי לזכור אותה. הדימיון העיקרי הוא לדעתי בשני דברים: הראשון, כל מה שמציירים על הקנבס נשאר שם עד שמוחקים אותו באופן מפורש והשני, אם מזיזים או מסובבים את הקנבס אז הוא לא חוזר למצב המקורי שלו עד שלא עושים זאת באופן מפורש. חוץ מזה כמובן שיש את הדברים המתבקשים – אפשר לבחור צבעים שונים, לסייר בסוגים שונים של מכחולים (בגודל שונה או בצורה שונה), אפשר לשנות את הגודל (ע״י הדבקה של קנבס נקי בצדדים או חיתוך לגודל קטן יותר על חשבון איבוד מידע). ובכל זאת, כמובן שזה לא בדיוק אותו הדבר 
  7. זאת תהיה דוגמת ה-hello world שלנו. נעשה משהו ממש בסיסי שמצייר מלבן ומציג קצת טקסט.
  8. אז מה למדנו מההדגמה הקודמת? למדנו את שיטת העבודה הכללית עם ה-canvas.
  9. מסלולים מאפשרים לנו להגדיר כל צורה שאותה נרצה לצייר – לא רק מלבנים ומעגלים. מסלול הוא פשוט אוסף נקודות שמחוברות ביניהם בקווים (ישרים או מעוגלים). המסלול יכול להיות סגור או פתוח והוא יכול להיות רציף למקוטעין. מה שנחמד במסלולים הוא שלא צריך לצבוע על קטע בנפרד. אפשר להגדיר את המסלול פעם בבת אחת והתשתית זוכרת את כל הרכיבים אותו. בסיום ההגדרה ניתן לצייר את הקו ו/או למלא את הצורה. זה הרבה יותר יעיל מאשר לצייר כל קו בנפרד ולצבוע אותו. אבל שימו לב שכל המסלול כולו משתמש באותו הצבע לקו ובאותו הצבע למילוי. אם כל צלע בצורה שלנו היא בעלת צבע אחר אין ברירה אלא לצבוע כל צלע בנפרד.
  10. כאן אנחנו רואים רשימת מכולת של פונקציות ושדות שיש ל-canvas. זו לא רשימה מלאה אך אלה הדברים שנראו לי יותר חשובים. בגדול אנחנו יכולים לראות שיש חלוקה לכמה קבוצות: קווים, צורות, טקסט, תמונות, עיצוב, מידע גולמי וטרנספורמציות.
  11. טרנספורמציות זה נושא מאוד חשוב לקנבס, אבל מאחר שבדמו הראשי שלנו לא יהיה שימוש בטרנספורמציות אני רוצה להראות לכם דוגמה בנפרד.