INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.

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):
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.
HTML 5 Previous version: HTML4.01, 1999 Still work in progress, most browsers support some of it.
Tutorial 8 Designing a Web Site with Frames. XP Objectives Explore the uses of frames in a Web site Create a frameset consisting of rows and columns of.
The Power of Tables They aren't just for sitting stuff on anymore...
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.
Chapter 6 Working with Frames.
Director of Computer Center, DaYeh University Ku-Yaw Chang.
IT Engineering I Instructor: Rezvan Shiravi
INT222 – Internet Fundamentals Weekly Notes: AJAX and Canvas 1.
XP 1 Tutorial 5 Using Frames in a Web Site. XP 2 Tutorial Objectives  Describe the uses of frames in a Web site  Lay out frames within a browser window.
CHAPTER 2 HTML & HTML5 II อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Getting Started with Canvas IDIA Spring 2013 Bridget M. Blodgett.
Tutorial 8 Designing a Web Site with Frames. XP Objectives Explore the uses of frames in a Web site Create a frameset consisting of rows and columns of.
Chapter 12 FRAMES. HOW FRAMES WORK When you view a framed page in a browser, you are actually looking at several HTML documents at once. The key to making.
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.
Session: 17. © Aptech Ltd. 2Canvas and JavaScript / Session 17  Describe Canvas in HTML5  Explain the procedure to draw lines  Explain the procedure.
Working with HTML Frames The Good, The Bad & The Ugly.
Element. The element Used to dynamically draw graphics using javascript. Capable of drawing paths, circles, rectangles, text, and images.
Tutorial 8 Enhancing a Web Site with Advanced CSS
HTML, CSS, and XML Tutorial 8 Enhancing a Web Site with Advanced CSS.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
Windows and frames and the anchor tag. Frames Independent, scrollable portions of a Web browser window, with each frame capable of containing its own.
XP Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
Tutorial 8 Designing a Web Site with Frames. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore the uses of frames.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Adding Graphical Elements Essentials for.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
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
Creating Graphics for the Web Learning & Development Team Telerik Software Academy.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
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");
Windows and frames and the anchor tag. Frames Independent, scrollable portions of a Web browser window, with each frame capable of containing its own.
Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website.
11/12/2015 Box Model Reed Crouch. 11/12/2015  HTML elements can be considered as boxes. In CSS, the term "box model" is used when referring to layout.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 19 – Dynamic HTML: Structured Graphics ActiveX Control Outline 19.1Introduction 19.2Shape.
HTML IMAGES. CONTENTS IMG Tag Alt Attribute Setting Width and Height Of An Image Summary Exercise.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Programming games Review concepts. Crooked coin toss. Drawing on canvas. Homework: Complete [static] drawings. Upload files to website.
20-753: Fundamentals of Web Programming 1 Lecture 6: Advanced HTML Fundamentals of Web Programming Lecture 6: Advanced HTML.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
07 – HTML5 Canvas (1) Informatics Department Parahyangan Catholic University.
HTML 5 (Part 1) – Start from SCRATCH. HTML 5 – Start from SCRATCH.
CSS.
CMPE 280 Web UI Design and Development September 12 Class Meeting
Inserting and Working with Images
Flash Interface, Commands and Functions
Canvas Notes
Creating Links – Lesson 3
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
Objectives Create a figure box Add a background image
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
ISC440: Web Programming II Ch14: HTML5 Canvas
The Canvas.
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
موضوع بحث: تعریف علم اصول جلسه 43.
اشاره به نتایج قیاس های فقهی گاهی، حکم شرعی است
علم اصول، «نفس قواعد» است نه «علم به قواعد»
Drawing Graphics in JavaScript
CSc 337 Lecture 21: Canvas.
Graphics Canvas.
CSc 337 Lecture 20: Canvas.
قاعده لا ضرر، تنها در شبهات حکمیه جاری است
جلسه 34.
JavaScript – Let’s Draw!
CSc 337 Lecture 19: Canvas.
1 ج : اشاره بعضی از اصولیون به تعریف ترکیبی آخوند با «یک لفظ»
Presentation transcript:

INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE

2 Outline Questions? Asgns, labs? Canvas

Browser Object - window Method – open() Opens a new browser window winRef = window.open(URL,name,specs,replace); winRef = window.open(' 400,height=200, scrollbars = yes'); winRef.document.write(" write to new window in blue. "); 3 window_open.html

4 Browser Object - window Syntax: window.open(URL,name,specs,replace)  URL, optional. Open the page in the URL. If no URL, a new window with about:blank is opened  Name, Optional. Specifies the target attribute or the name of the window.  _blank - URL is loaded into a new window. default  _parent - URL is loaded into the parent frame  _self - URL replaces the current page  _top - URL replaces any framesets that may be loaded  name - The name of the window

5 Specs:

- an element to give you a drawing space in JavaScript on your Web pages. - only a container for graphics. Need a script to actually draw the graphics. Canvas has several methods for drawing paths, boxes, circles, characters, and adding images. 6 canvas.html

Create a Canvas A canvas is a rectangular area on an HTML page, By default, element has no border and no content.  Always specify id (to be referred to in a script), and  width and height to define the size of the canvas. You can have multiple elements on one HTML page. 7

Create a Canvas add a border to the canvas: 8

Draw onto the Canvas Using JavaScript. 9 var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.fillStyle="#FF0000"; ctx.fillRect(10,10,20,50); ctx.strokeStyle = "green"; ctx.strokeRect(0,0,150,75);

Canvas Coordinates The canvas is a two-dimensional grid. The upper-left corner, coordinate (0,0) ctx.fillRect(0,0,150,75) – Start at the upper-left corner (0,0) and draw a 150x75 pixels rectangle. 10

Canvas - Paths Draw straight lines on a canvas: moveTo(x,y): the starting point of the line lineTo(x,y): the ending point of the line To actually draw the line, use stroke(). 11 var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.moveTo(0,0); ctx.lineTo(300,150); ctx.stroke();

Canvas – draw a circle arc(x,y,r,start,stop, boolean) x, y: coordinate Start: starting angle (e.g. 0) Stop: stopping angle (e.g., 2 * Matho.PI) Boolean: whether counterclockwise. Default is false. To actually draw the circle, use stroke() or fill(). 12

Canvas - Text Draw text on a canvas: font - defines the font properties for text fillText(text,x,y) - Draws "filled" text on the canvas 13 var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.font="30px Arial"; ctx.fillText("Hello World",10,50);

Canvas - Text strokeText(text,x,y) - Draws text on the canvas (no fill) 14 var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.font="30px Arial"; ctx.strokeText("Hello World",10,50);

Canvas - Gradients Gradients can be used to fill rectangles, circles, lines, text, etc. Shapes on the canvas are not limited to solid colors. Two types of gradients: createLinearGradient(x,y,x1,y1) - Creates a linear gradient createRadialGradient(x,y,r,x1,y1,r1) - Creates a radial/circular gradient Once we have a gradient object, we must add two or more color stops. The addColorStop() method specifies the color stops, and its position along the gradient. Gradient positions can be anywhere between 0 to 1. Set the fillStyle or strokeStyle property to the gradient, and then draw the shape, like a rectangle, text, or a line. 15

Canvas - Gradients context.createLinearGradient(x0,y0,x1,y1); Creates a linear gradient object. The gradient can be used to fill rectangles, circles, lines, text, etc. Tip: Use the addColorStop() method to specify different colors, and where to position the colors in the gradient object.addColorStop() 16

Canvas - Gradients // Create gradient var grd=ctx.createLinearGradient(0,0,200,0); grd.addColorStop(0.5,"red"); grd.addColorStop(0.6,"green"); // Fill with gradient ctx.fillStyle=grd; ctx.fillRect(10,10,150,80); 17

Canvas - Gradients context.createRadialGradient(x0,y0,r0,x1,y1,r1); var grd=ctx.createRadialGradient(75,50,5,90,60,100); creates a radial/circular gradient object. The gradient can be used to fill rectangles, circles, lines, text, etc. Use addColorStop() to specify different colors, and where to position the colors in the gradient object.addColorStop() 18

Canvas - Image Draw an image, canvas, or video onto the canvas. Can also draw parts of an image, and/or increase/reduce the image size Position the image on the canvas: – context.drawImage(img,x,y); Position the image, and specify width and height of the image: – context.drawImage(img,x,y,width,height); Clip the image and position the clipped part on the canvas: – context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height); Note: the above img is an object. 19

20 Property Values

Canvas -Transparent Canvases are transparent by default. – Set a page background image, – put a canvas over it. – If nothing on the canvas, you can fully see the page background. 21

Canvas -Transparent Property: globalAlpha number 0 to 1, 0 is fully transparent and 1 is fully opaque. ctx.globalAlpha = 0.5; Property: fillStyle ctx2.fillStyle="rgba(0, 0, 200, 0.5)"; // the 4 th parameter is the opacity 22

Canvas Reference

24 Canvas Reference

25 Canvas Reference

26 Canvas Reference

Next Class Ajax & Questions

Thank you!