HTML5 CANVAS.  Rectangles  Arcs  Lines  Features we won’t look at  Images  Drag and drop  Animation  Widely supported DRAWING PICTURES IN HTML.

Slides:



Advertisements
Similar presentations
HTML5 Overview Owen Williams owen at dynabooks daht com Owen Williams owen at dynabooks daht com.
Advertisements

HTML5 Golsana Ghaemi
SD1230 Unit 10 Mobile Web.
Bring Life to Your Web Pages with JavaScript and HTML5 Part 2 Ole Ildsgaard Hougaard -
CHAPTER 20 CREATING SVG GRAPHICS. LEARNING OBJECTIVES How to embed a graphic stored within a.SVG file in an HTML page How to use the and tag pair to specify.
1 HTML5 Audio and Video Credits: Dr. Jay Urbain
Backwards Compatible HTML5/CSS3 Apps in ASP.NET Nik Kalyani, Founder/CEO, HyperCrunch, Inc.
CSCI 3100 Tutorial 6 Web Development Tools 1 Cuiyun GAO 1.
Lecture # 11 JavaScript Graphics. Scalable Vector Graphics (SVG) Scalable Vector Graphics (SVG), as the name implies, are - scalable (without pixelation):
Introduction to HTML5 Programming donghao. HTML5 is the New HTML Standard New Elements, Attributes. Full CSS3 Support Video and Audio 2D/3D Graphics Local.
Programming Club IIT Kanpur
HTML 5 Previous version: HTML4.01, 1999 Still work in progress, most browsers support some of it.
Programming games More drawing. Text. Radian measure. Faces. Homework: Do your own drawings. Create index.html file. Upload work.
1 L38 Graphics and Java 2D™ (3). 2 OBJECTIVES In this chapter you will learn:  To understand graphics contexts and graphics objects.  To understand.
Graphics in Android 1 Fall 2012 CS2302: Programming Principles.
Canvas, SVG, Workers Doncho Minkov Telerik Corporation
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
CIS 205—Web Design & Development Flash Chapter 1 Getting Started with Adobe Flash CS3.
Programming games Recap. Upload work (Filezilla, index.html). Drawing lines. Drawing stars. Homework: Drawing exercises.
Getting Started with Canvas IDIA Spring 2013 Bridget M. Blodgett.
Programming Games Simulated ballistic motion: cannon ball. Classwork: Final day for midterm project and all projects for first part of class. Homework:
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.
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.
Creating HUD Rings. Step 1 Open a new document in Illustrator. You can set it to the size you prefer to work in. In my case I have it set at 500px by.
CS 174: Web Programming October 5 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
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");
Drawing With Lines and Shapes!
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.
Programming games Review concepts. Crooked coin toss. Drawing on canvas. Homework: Complete [static] drawings. Upload files to website.
Graphics in Android 1 CS7030: Mobile App Development.
School of Computing and Information Systems RIA Animation, part I.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
07 – HTML5 Canvas (1) Informatics Department Parahyangan Catholic University.
Lecture 9: Extra Features and Web Design Tarik Booker CS 120 California State University, Los Angeles.
HTML 5 (Part 1) – Start from SCRATCH. HTML 5 – Start from SCRATCH.
Martin Kruliš by Martin Kruliš (v1.1)1.
What is a Function Expression?
Internet of the Past.
CMPE 280 Web UI Design and Development September 12 Class Meeting
Canvas Notes
Levels of Organization Ecology Flow
What? Learn how to program at FIU Register for: COP 1000 – #59660
Add animated sparkles to a picture (Basic)
Animated picture changes during motion path (Advanced)
ISC440: Web Programming II Ch14: HTML5 Canvas
Order of Operations Problems
The Canvas.
Graphics in Android Fall 2012 CS2302: Programming Principles.
First line of text Second line of text Third line of text here
Order of Operations Problems
Levels of Organization Ecology Flow
Pictures with reflection and blurred background (Basic)
Sample statement or caption goes here
Pictures with reflection and blurred background (Basic)
Pictures in 3-D flip book (Intermediate)
Pictures with reflection and blurred background (Basic)
Drawing Graphics in JavaScript
CSc 337 Lecture 21: Canvas.
Context of what we are doing.
Pictures with reflection and blurred background (Basic)
Programming Games Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Show project. Classwork/Homework:
Week 10 - HTML SVG Student: Vladislovas Karalius
JavaScript – Let’s Draw!
CSc 337 Lecture 19: Canvas.
Presentation transcript:

HTML5 CANVAS

 Rectangles  Arcs  Lines  Features we won’t look at  Images  Drag and drop  Animation  Widely supported DRAWING PICTURES IN HTML (AND JAVASCRIPT)

 Canvas tag in HTML  Id required  Resizing must be done in tag, NOT CSS  If you go outside canvas, no error, just doesn’t show  JavaScript to DRAW: step by step HOW TO DO IT

 Need to identify the canvas  Create a javaScript object that represents the canvas (context)  Methods associated with object var canvas = document.getElementById("rectangles"); var context = canvas.getContext("2d");  Code needs to wait until loading completes document.addEventListener('DOMContentLoaded',domloaded,false); function domloaded() { }  Drawn in order of execution SET UP

 Most straightforward  Define by location of upper left corner and size  Grid is defined with (0,0) as upper left corner context. fillRect(x, y, width, height);  Set color and then define the rectangle context.fillStyle = "#EF5B84"; context.fillRect(100, 100, 100, 200);  Color  Always a string  Same formats as in CSS  Opacity: applies to what follows context.globalAlpha = 0.5; RECTANGLES

 Need to create a gradient object var gradient = context.createLinearGradient(x 0, y 0, x 1, y 1 );  If x’s or y’s are 0, no change in that direction  If non-zero, must match the rectangle locations  Stops gradient.addColorStop(0, “blue"); gradient.addColorStop(1, “#FFFFFF");  Can have as many transitions as you want  Define at relative points from 0 to 1  Define color at that point  Use gradient rather than color in fillStyle context.fillStyle = gradient; GRADIENTS

 Circles and arcs context.arc(x, y, radius, start-angle, end-angle, dir);  Outline (“pencil”) and then draw (“ink”)  Pencil context.beginPath(); context.arc(x, y, radius, 0, Math.PI * 2, false); context.closePath(); /* closes the shape */  Fill context.fillStyle = "#000"; context.fill();  Ink context.strokeStyle = "#000"; context.stroke(); ARCS

 Pencil up, pencil down  Start (same as arcs) context.beginPath();  Position context.moveTo(x,y);  Draw (pencil) context.lineTo(x,y);  If you want to close the shape (same as arcs) context.closePath();  Ink (same as arc) context.strokeStyle = "#000"; context.stroke(); LINES

 Mark Pilgrim, Dive into HTML5  Chapter 4: Let’s Call it a Draw(ing Surface) Chapter 4: Let’s Call it a Draw(ing Surface)  HTML5 Canvas Basic Tutorials HTML5 Canvas Basic Tutorials RESOURCES