CANVAS Fundamentals. What is Canvas? Canvas is a medium for oil painting. One of the earliest oils on canvas is a French Madonna from 1410. Canvas is.

Slides:



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

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.
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):
Neal Stublen Why Use a Canvas?  Flexibility… Use of drawing primitives (lines, arcs, text) Direct access to element display pixels.
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.
Dell Optiplex with a 3.0 GHz Core 2 Duo Intel processor, 4 GB RAM, and Intel integrated vide; running Windows 7.
Spring /6.831 User Interface Design and Implementation1 Lecture 11: Output.
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.
Mark Branom, Continuing Studies.  HTML5 overview – what’s new?  New HTML5 elements  New HTML5 features  Guided Demonstrations  Forms  Video  Geolocation.
CHAPTER 24 PERFORMING CSS TRANSITIONS AND ANIMATIONS.
Web Programming Language Week 13 Ken Cosh HTML 5.
Director of Computer Center, DaYeh University Ku-Yaw Chang.
IT Engineering I Instructor: Rezvan Shiravi
INT222 – Internet Fundamentals Weekly Notes: AJAX and Canvas 1.
@ 翁玉礼 HTML5 Discuss. Compare to html4 Canvas Video and audio Local offline store New form control.
Create Interfaces College exercise. Continue HTML5: HTML5 logo, drawing images. Coin toss. Homework: acquire video & audio.
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.
CHAPTER 2 HTML & HTML5 II อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
New Features of HTML 5.0 Barbara Ericson
Brent M. Dingle, Ph.D Game Design and Development Program Mathematics, Statistics and Computer Science University of Wisconsin - Stout HTML5 – Canvas.
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.
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 User Interfaces Recap HTML/HTML5 JavaScript features Homework: keep working on user observation studies. Review JavaScript.
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");
Types of Spatial Data Sites Data portals: Find and download data –Humboldt County, National Atlas “Atlases”: General information –GoogleMaps, MapQuest.
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.
HTML – Other Tags Semantic Tags, Frames, Embed Multimedia Content, Others SoftUni Team Technical Trainers Software University
HTML – Other Tags Semantic Tags, Frames, Embed Multimedia Content, Others SoftUni Team Technical Trainers Software University
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.
HTML 5 Hands On By Rohit Ghatol
Programming games Review concepts. Crooked coin toss. Drawing on canvas. Homework: Complete [static] drawings. Upload files to website.
Basic HTML.
Creating User Interfaces HTML5 video & audio. Role of video and audio. Homework: Complete your own [small/simple] HTML5 video and audio projects.
School of Computing and Information Systems RIA Animation, part I.
Lab 5: More on Events and Introduction to the Canvas Tag User Interface Lab: GUI Lab Sep. 23 rd, 2013.
CSCI 3100 Tutorial 2 Web Development Tools 1 HTML 5 & CSS 3 1.
HTML 5 (Part 1) – Start from SCRATCH. HTML 5 – Start from SCRATCH.
Part – 3 : HTML 5 SVG Tag. † SVG stands for Scalable Vector Graphics. † SVG is used to define vector-based graphics for the Web. † SVG defines the graphics.
HTML5 ProgLan HTML5 Making a Game on the Canvas Part 1.
HTML5 ارائه درس مهندسی اینترنت عرفان عطارزاده
Game Development with JS and Canvas 2D
That Gauge is COOL! 
Web Basics: HTML/CSS/JavaScript What are they?
CMPE 280 Web UI Design and Development September 12 Class Meeting
Canvas Notes
A framework to create SVG graphics
מדעי המחשב ורובוטיקה בחט"ב
ISC440: Web Programming II Ch14: HTML5 Canvas
HTML5 Drawing Canvas and Video
HTML HYPERTEXT MARKUP LANGUAGE.
Types of Spatial Data Sites
Drawing Graphics in JavaScript
HTML5 – Canvas JavaScript Simple Drawing
Types of Spatial Data Sites
Graphics Canvas.
CSc 337 Lecture 20: Canvas.
Types of Spatial Data Sites
Creating User Interfaces
Programming Games Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Show project. Classwork/Homework:
JavaScript – Let’s Draw!
Javascript canvas graphics
Presentation transcript:

CANVAS Fundamentals

What is Canvas? Canvas is a medium for oil painting. One of the earliest oils on canvas is a French Madonna from Canvas is typically stretched across a wooden frame. On the HTML canvas, you can draw all kinds of graphics, from simple lines, to complex graphic objects.

The HTML Element The HTML element (introduced in HTML5) is a container for canvas graphics. An HTML canvas is a rectangular area on an HTML page. Canvas has several methods for drawing paths, boxes, circles, text, and graphic images.

Basic Canvas Example Your browser does not support the HTML5 canvas tag.

Basic Canvas Example

Drawing with JavaScript Your browser does not support the HTML5 canvas tag. var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.fillStyle = "#FF0000"; ctx.fillRect(0,0,150,75);

Drawing with JavaScript

Draw a Line Your browser does not support the HTML5 canvas tag. var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.moveTo(0,0); ctx.lineTo(200,100); ctx.stroke();

Draw a Line

Draw a Circle Your browser does not support the HTML5 canvas tag. var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.beginPath(); ctx.arc(95,50,40,0,2*Math.PI); ctx.stroke();

Draw a Circle

Draw a Text Your browser does not support the HTML5 canvas tag. var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.font = "30px Arial"; ctx.fillText("Hello World",10,50);

Draw a Text

Stroke Text Your browser does not support the HTML5 canvas tag. var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.font = "30px Arial"; ctx.strokeText("Hello World",10,50);

Stroke Text

Draw Gradient Your browser does not support the HTML5 canvas tag. var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d");

Draw Gradient // Create gradient var grd = ctx.createLinearGradient(0,0,200,0); grd.addColorStop(0,"red"); grd.addColorStop(1,"white"); // Fill with gradient ctx.fillStyle = grd; ctx.fillRect(10,10,150,80);

Draw Gradient

Draw Circular Gradient Your browser does not support the HTML5 canvas tag. var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d");

Draw Circular Gradient // Create gradient var grd = ctx.createRadialGradient(75,50,5,90,60,100); grd.addColorStop(0,"red"); grd.addColorStop(1,"white"); // Fill with gradient ctx.arc(50, 50, 50, 0, 2*Math.PI); ctx.fillStyle = grd; ctx.fill();

Draw Circular Gradient

Draw Image Image to use: Canvas to fill: Your browser does not support the HTML5 canvas tag. Try it

Draw Image function myCanvas() { var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); var img = document.getElementById("scream"); ctx.drawImage(img,10,10); }

Draw Image