HTML5 CANVAS. SAVING INFORMATION BETWEEN FUNCTION CALLS.

Slides:



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

Lecture # 11 JavaScript Graphics. Scalable Vector Graphics (SVG) Scalable Vector Graphics (SVG), as the name implies, are - scalable (without pixelation):
Using Bitmap graphics Having looked at vector graphics in the canvas, we will now look at using bitmap graphics.
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 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.
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
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
Web Programming Language Week 13 Ken Cosh HTML 5.
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,
INT222 – Internet Fundamentals Weekly Notes: AJAX and Canvas 1.
HTML, HTML5 Canvas, JavaScript PART 3 LOOKING MORE CLOSELY AT FULL BLOWN GAME DESIGN A PATTERNED BACKGROUND (CREATED WTIH LOOPS) WITH A MOVING OBJECT CHALLENGES.
Getting Started with Canvas IDIA Spring 2013 Bridget M. Blodgett.
CHAPTER 4 LINKS Creating links between pages Linking to other sites links.
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.
Canvas academy.zariba.com 1. Lecture Content 1.What is Canvas? 2.Including Canvas in your HTML 3.Commands in Canvas 4.Drawing Shapes with Canvas 5.Animations.
Session: 17. © Aptech Ltd. 2Canvas and JavaScript / Session 17  Describe Canvas in HTML5  Explain the procedure to draw lines  Explain the procedure.
Programming games Reprise: coin toss on canvas. Dice game rules. Global and local variables. Homework: [Catch up. Upload projects, including index.html.]
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.
Code for touch, get mouse and pen for free Pointer API captures pen motion, passing coordinates to Ink API Ink API helps render and stores motion.
New Tags, New Attributes, New JavaScript APIs, Forms, Validation, Audio, Video, SVG, Canvas Doncho Minkov Telerik Corporation
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.
Aim: What is Adobe Illustrator?. Adobe Illustrator is a vector based drawing program.
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.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Programming games Review concepts. Crooked coin toss. Drawing on canvas. Homework: Complete [static] drawings. Upload files to website.
1 Introduction to Graphics b The last one or two sections of each chapter of the textbook focus on graphical issues b Most computer programs have graphical.
Web Technologies Lecture 8 JQuery. “A fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax.
School of Computing and Information Systems RIA Animation, part I.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
08 – Canvas(2) Informatics Department Parahyangan Catholic University.
Tabs with Rounded Corners (Sliding Doors). Sliding Doors Tutorial  doors/
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.
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.
CHAP 2. CANVAS API.  Dynamically generate and render graphics, charts, images and animations  SVG (Scalable Vector Graphics) vs. Canvas  Bitmap canvas.
That Gauge is COOL! 
What is a Function Expression?
SVG & DOM Manipulation via Javascript
Internet of the Past.
CMPE 280 Web UI Design and Development September 12 Class Meeting
Canvas Notes
Web Programming Language
Computer Programming I
JavaScript, continued.
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.
Topics Graphical User Interfaces Using the tkinter Module
CSc 337 Lecture 21: Canvas.
CSc 337 Lecture 20: Canvas.
Programming Games Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Show project. Classwork/Homework:
JavaScript – Let’s Draw!
CSc 337 Lecture 19: Canvas.
HTML5 – A few features L. Grewe.
Presentation transcript:

HTML5 CANVAS

SAVING INFORMATION BETWEEN FUNCTION CALLS

 Can I keep information between calls to a function?  Why would I want to do it?  Possibilities  Store and retrieve values from the HTML page  Possible but can be cumbersome  Have a javaScript variable OUTSIDE the function  Known as a global variable  Snippets for the carousel  elem_ illustrates writing to src outside of a form SAVING INFORMATION

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(“c"); var context = canvas.getContext("2d");  Code needs to wait until loading completes  Onload  Faster alternative 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

 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