HTML 5 Previous version: HTML4.01, 1999 Still work in progress, most browsers support some of it.

Slides:



Advertisements
Similar presentations
Bring Life to Your Web Pages with JavaScript and HTML5 Part 2 Ole Ildsgaard Hougaard -
Advertisements

HTML5 CANVAS.  Rectangles  Arcs  Lines  Features we won’t look at  Images  Drag and drop  Animation  Widely supported DRAWING PICTURES IN HTML.
Lecture # 11 JavaScript Graphics. Scalable Vector Graphics (SVG) Scalable Vector Graphics (SVG), as the name implies, are - scalable (without pixelation):
CSS level 3. History of CSS CSS level 1 – original CSS CSS level 2 CSS level 2 Revision 1 (CSS2.1) – up to CSS2.1 monolithic structure CSS level 3 – specification.
More CSS - Page layout + HTML5 new features Boriana Koleva Room: C54
Neal Stublen Why Use a Canvas?  Flexibility… Use of drawing primitives (lines, arcs, text) Direct access to element display pixels.
Programming Club IIT Kanpur
HTML 5. What is HTML5? HTML5 will be the new standard for HTML, XHTML, and the HTML DOM. The previous version of HTML came in The web has changed.
Programming games More drawing. Text. Radian measure. Faces. Homework: Do your own drawings. Create index.html file. Upload work.
HTML 5 Tutorial Chapter 1 Introduction. What is HTML5? HTML5 will be the new standard for HTML, XHTML, and the HTML DOM. The previous version of HTML.
Lecture 18. HTML5 and JavaScript Instructor: Jie Yang Department of Computer Science University of Massachusetts Lowell Exploring the Internet,
CHAPTER 21 INTRODUCING THE HTML 5 CANVAS. LEARNING OBJECTIVES How to create a canvas using the and tag pair How to test if a browser supports canvas operations.
Canvas, SVG, Workers Doncho Minkov Telerik Corporation
Web Programming Language Week 13 Ken Cosh HTML 5.
HTML5. What is HTML5? HTML5 will be the new standard for HTML. HTML5 is the next generation of HTML. HTML5 is still a work in progress. However, the major.
HTML 5 New Standardization of HTML. I NTRODUCTION HTML5 is The New HTML Standard, New Elements New Attributes Full CSS3 Support Video and Audio 2D/3D.
CS7026 – HTML5 Canvas. What is the element 2  HTML5 defines the element as “a resolution-dependent bitmap canvas which can be used for rendering graphs,
IT Engineering I Instructor: Rezvan Shiravi
Create Interfaces College exercise. Continue HTML5: HTML5 logo, drawing images. Coin toss. Homework: acquire video & audio.
INTRODUCTION TO HTML5 Styling with CSS3. Round Border Corners  You can modify any element that supports the border property and render rounded borders.
HTML Advanced: HTML 5. Introduction to HTML 5 These slides are based on source material found at the w3schools.com website.
Getting Started with Canvas IDIA Spring 2013 Bridget M. Blodgett.
Patrick Chanezon (slides from Matthew Papakipos) June Google’s HTML5 Work: What’s Next?
HTML 5 Tutorial Chapter 5 Canvas. Canvas The tag is used to display graphics. The Canvas is a rectangular area we control each and every pixel of it.
HTML5 CANVAS. SAVING INFORMATION BETWEEN FUNCTION CALLS.
Session: 17. © Aptech Ltd. 2Canvas and JavaScript / Session 17  Describe Canvas in HTML5  Explain the procedure to draw lines  Explain the procedure.
Proglan Session 1. .  HTML5 will be the new standard for HTML.  The previous version of HTML, HTML 4.01, came in The web has changed a lot since.
Element. The element Used to dynamically draw graphics using javascript. Capable of drawing paths, circles, rectangles, text, and images.
Programming Games Show project. Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Homework: Do your own.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
New Tags, New Attributes, New JavaScript APIs, Forms, Validation, Audio, Video, SVG, Canvas Doncho Minkov Telerik Corporation
Chapter 9 Fireworks: Part I The Web Warrior Guide to Web Design Technologies.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
CS 174: Web Programming October 5 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Creating Graphics for the Web Learning & Development Team Telerik Software Academy.
Intro to the Canvas Canvas is an HTML5 element If you see this, your browser doesn't support the canvas Canvas is manipulated with javascript c = document.getElementById("mycanvas");
CHAPTER 22 ADVANCED CANVAS PROGRAMMING. LEARNING OBJECTIVES How the HTML 5 canvas supports linear and radial gradients How to fill a shape with a pattern.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 19 – Dynamic HTML: Structured Graphics ActiveX Control Outline 19.1Introduction 19.2Shape.
Programming games Review concepts. Crooked coin toss. Drawing on canvas. Homework: Complete [static] drawings. Upload files to website.
School of Computing and Information Systems RIA Animation, part I.
Presented By Nanda Kumar(972789) P. Trinesh (982816) Sk. Salma (982824) K. Madhuri (982814) HTML5.
08 – Canvas(2) Informatics Department Parahyangan Catholic University.
Can SAS Do Canvas? Creating Graphs Using HTML 5 Canvas Elements Edwin J. van Stein Astellas Pharma Global Development.
07 – HTML5 Canvas (1) Informatics Department Parahyangan Catholic University.
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
HTML 5 (Part 1) – Start from SCRATCH. HTML 5 – Start from SCRATCH.
CHAP 2. CANVAS API.  Dynamically generate and render graphics, charts, images and animations  SVG (Scalable Vector Graphics) vs. Canvas  Bitmap canvas.
12 Graphics and Java 2D™.
What is a Function Expression?
CMPE 280 Web UI Design and Development September 12 Class Meeting
Tutorial 4 Topic: CSS 3.0 Li Xu
Canvas Notes
HTML 5 Tutorial Chapter 1 Introduction.
Web Programming Language
ISC440: Web Programming II Ch14: HTML5 Canvas
The Canvas.
Progress <progress value="22" max="100"></progress>
Drawing Graphics in JavaScript
Simple Canvas Example Your browser doesn’t support canvases var canvas = document.getElementById("canvas1"); var context.
CSc 337 Lecture 21: Canvas.
Context of what we are doing.
CSc 337 Lecture 20: Canvas.
JavaScript – Let’s Draw!
CSc 337 Lecture 19: Canvas.
HTML5 – A few features L. Grewe.
Presentation transcript:

HTML 5 Previous version: HTML4.01, 1999 Still work in progress, most browsers support some of it

HTML 5 New features based on HTML, CSS, DOM, Javascript Reduces need for externals plugins (like Flash,..) “Should be” device independent

HTML 5 – interesting features element tag for 2D drawing and for media playback Other new elements (,,,...) Support for local storage New form controls (calendar,..)

HTML 5 – Canvas element Focus on element A container for graphics ( 0, 0 ) is top left corner of canvas Need to use a script to draw the graphics Supported by IE9, Firefox, Safari, Opera, Chrome

500 X 200 Canvas element (0, 0)(500, 0) (200, 0)(500, 200)

HTML 5 getContext( “2d” ) returns a CanvasRenderingContext2D object that allows to draw on the canvas  could ultimately reduce need for Flash var can = document.getElementsByTagName( “canvas” )[0]; var context = can.getContext( “2d” );

HTML 5 Draw and paint text, lines, rectangles, circles, polygons, images,.. Save and restore state of context Change coordinate system (rotate, translate,..) Gradients, shadows, images (access pixels),..

HTML 5 – setting the context Set value of fillStyle and strokeStyle of the context rgb  3 parameters rgba  4 th parameter is for opacity value context.fillStyle = "rgb(255, 0, 0 )"; context.strokeStyle = "rgba(0, 255, 0, 0.8 )"; 20% transparent (80% opaque)

HTML 5 – rectangle To paint the inside of a rectangle, use fillRect; to draw the rectangle, use strokeRect (x and y are relative to the canvas) void fillRect ( float x, float y, float width, float height); void strokeRect ( double x, double y, double width, double height);

HTML 5 – rectangle To clear a rectangle void clearRect ( float x, float y, float width, float height); Color used is the color of the canvas

HTML 5 – drawing shapes Set context (stroke and/or fill color) Start a “ path ” to draw or fill context.beginPath( ); Build the path Close the path (or not) Draw it or fill it

HTML 5 - line To draw a line context.beginPath( ); context.moveTo( 50, 50 ); // start point context.lineTo( 250, 50 ); context.stroke( ); // use current strokeStyle color

HTML 5 - polygon // build a polygon context.beginPath( ); context.moveTo( 50, 100 ); context.lineTo( 250, 100 ); context.lineTo( 120, 180 ); context.lineTo( 80, 150 ); context.closePath( ); // close the polygon

HTML 5 - polygon Now draw the polygon (defined by the current path) context.stroke( ); Now fill the polygon (defined by the current path) context.fill( );

HTML 5 – arcs and circles A circle is an arc that is full An arc is a portion of a circle defined by a start angle and an endAngle Need center, radius, and whether the drawing is clockwise or counterclockwise

HTML 5 – arcs and circles void arc ( float x, float y, float radius, float startAngle, float endAngle, boolean anticlockwise); Angles are in radians, measured from x axis, going clockwise If endAngle – startAngle = 2 * PI ( or a multiple of 2 * PI )  circle If endAngle – startAngle = PI ( or – PI)  half circle

HTML 5 – arcs and circles // build an arc context.beginPath( ); x = 200; // relative to canvas y = 100; // relative to canvas radius = 50; startAngle = 0; endAngle = Math.PI / 4; // 45 degrees anticlockwise = true;

HTML 5 – arcs and circles context.arc( x, y, radius, startAngle, endAngle, anticlockwise ); Draw the arc context.stroke( ); Fill the arc context.fill( );

HTML 5 – arcs and circles Not what you expected for the filling of the arc?  Fill 2 half circles instead

HTML 5 – Pacman Paint the Pacman, Paint the full circle, erase the full circle, Paint the Pacman,.. Need to do the above with some time between the paintings (otherwise too fast) Can make Pacman move

HTML 5 – More Pacman Can make Pacman move responding to an event ( right key for example) onkeydown event