Context of what we are doing.

Slides:



Advertisements
Similar presentations
HTML popo.
Advertisements

HTML 5 Previous version: HTML4.01, 1999 Still work in progress, most browsers support some of it.
Programming games Classwork: Show Favorite Sites. Show coin toss. Review concepts. Crooked coin toss. Homework: Complete coin toss examples. Upload files.
Programming games More drawing. Text. Radian measure. Faces. Homework: Do your own drawings. Create index.html file. Upload work.
Hypertext Markup Language. Platform: - Independent  This means it can be interpreted on any computer regardless of the hardware or operating system.
HTML Programming last updated 9/12/05 at 1:30pm HyperText Markup Language Reference: – HTML BasicsHTML Basics An HTML program is a set of paired tags that.
Building Web Pages With Microsoft Office. Introduction This tutorial is for the beginning web builder. It utilizes software that you already have, Microsoft.
CIS101 Introduction to Computing Week 05. Agenda Your questions CIS101 Survey Introduction to the Internet & HTML Online HTML Resources Using the HTML.
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
CS105 Introduction to Computer Concepts HTML
Chapter 16 The World Wide Web. 2 Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Write basic HTML.
Create Interfaces College exercise. Continue HTML5: HTML5 logo, drawing images. Coin toss. Homework: acquire video & audio.
Chapter 16 The World Wide Web. 2 The Web An infrastructure of information combined and the network software used to access it Web page A document that.
Programming games Recap. Upload work (Filezilla, index.html). Drawing lines. Drawing stars. Homework: Drawing exercises.
.  Entertain  Inform  Educate  Blogs  Sell  Date  Gamble  Religion.
Amber Annett David Bell October 13 th, What will happen What is this business about personal web pages? Designated location of your own web page.
WEB DESIGN USING DREAMWEAVER. The World Wide Web –A Web site is a group of related files organized around a common topic –A Web page is a single file.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Programming in HTML.  Programming Language  Used to design/create web pages  Hyper Text Markup Language  Markup Language  Series of Markup tags 
Introduction to HTML. What is a HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup tags  The.
Programming Games Google Map API examples. CSS. Classwork/homework: Catch up. Upload work. Show your [more] complex Google Maps API example. Plan your.
Programming Games Simulated ballistic motion: cannon ball. Classwork: Final day for midterm project and all projects for first part of class. Homework:
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.]
Just Enough HTML How to Create Basic HTML Documents.
Homework: New coin toss. [Start dice game.]
CS105 INTRODUCTION TO COMPUTER CONCEPTS HTML Instructor: Cuong (Charlie) Pham.
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.
1 John Magee 9 November 2012 CS120 Lecture 17: The World Wide Web and HTML Web Publishing.
Week 1 – Beginners Content McAfee & Big Fish Games CoderDojo.
Creating User Interfaces Recap HTML/HTML5 JavaScript features Homework: keep working on user observation studies. Review JavaScript.
Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on your cannonball. Homework: Finish.
Programming games Show shaking screen, quiz show. Calculations Homework: (Finish basic Javascript Projects) Make proposal. Work on project.
CS 174: Web Programming October 5 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Programming games HTML/JavaScript basics Functions, events, forms Classwork: [Show favorite sites.] Coin toss. Homework: GET WEB SPACE. Complete coin toss.
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 Logic. Slide show. Range input. Storage. Datatypes. Binary numbers. Homework: Catch up. This includes uploading projects to your server.
Programming games Review concepts. Crooked coin toss. Drawing on canvas. Homework: Complete [static] drawings. Upload files to website.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Spiderman ©Marvel Comics Creating Web Pages (part 1)
Lesson 2 – Unit B. Quick review 1. What is the name of the eGCC host that you ftp your files? 2. What type of software do you use to create and edit web.
Tutorial #1 Using HTML to Create Web Pages. HTML, XHTML, and CSS HTML – HyperText Markup Language The tags the browser uses to define the content of the.
IN THIS LESSON WE WILL REVIEW THE STRUCTURE OF THE INTERNET AND HOW BROWSERS ASSEMBLE WEBSITES BASED ON INSTRUCTIONS THEY RECEIVE FROM SERVERS. Internet.
Websites Creating Basic Course. What´s a website ? A website (or "web site") is a collection of related web pages, images, videos or other digital assets.
Programming games Show work on site. Work on slide show. Timed event for bouncing ball. Homework: [Finish slide show and upload to site.] Acquire a short.
HTML Structure & syntax
Introduction to HTML.
Section 4.1 Section 4.2 Format HTML tags Identify HTML guidelines
Classwork: Examine and enhance falling drop(s) or make your own.
JavaScript is a programming language designed for Web pages.
Web Development & Design Foundations with HTML5 7th Edition
JavaScript.
Programming Games Computer science big ideas and Computer Science jargon: review of things we have used in examples. Show virtual dog Homework: [Catch.
Arden University FTP Induction Resource
ISC440: Web Programming II Ch14: HTML5 Canvas
The Canvas.
Basic HTML and Embed Codes
Unit A.
Drawing Graphics in JavaScript
Chapter 16 The World Wide Web.
Project 4 Creating an Image Map.
Tutorial 10: Programming with javascript
Programming games Share your plans for your virtual something.
Catchup. Work on project.
Creating User Interfaces
Programming Games Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Show project. Classwork/Homework:
Introduction to JavaScript
JavaScript – Let’s Draw!
Presentation transcript:

Context of what we are doing. Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website. Now that you have some experience with random (aka stochastic) processes, you can apply it everywhere. For example, on your index.html page, you can randomly choose between two different images to decorate the page. With a little more work, you can select from a list. Homework: update your work and update index.html to point to all the projects. You don't have to update all your drawings.

Recall Source of diagram: Coursera course Programming for Everyone, (Python), Charles Severance, U of Michigan We are creating programs, aka HTML documents, with JavaScript scripts, that is, software. Software resides on hardware, shown in diagram from a Coursera course on Python. The CPU may be viewed as always "asking" what to do next. Note: when we save our programs, we save to Secondary Memory, often 'the hard drive'. When we close a program (for example, a browser), our program disappears from main memory).

Computer can be connected to other computers….

Software A browser can open files on secondary storage OR go to the Internet (using the Purchase server). An editor creates and/or opens and modifies a file on the local file system. An ftp program uploads or downloads from your account on a Purchase server. Your program Browser (Firefox) Editor (Sublime) ftp (Filezilla) Operating System, including file system (Mac OS)

Correct terminology We use the Filezilla program—it runs file transfer protocol– to upload and download our work. We do NOT store our files on Filezilla. We use Google (on google.com or the google ap) to find web sites. These are mainly NOT google web sites. BUT, later in the course, we will use google sites for information on the Google Maps API.

HTML5 drawing on canvas canvas is a new[er] type of element drawing is done using what is termed the 2d context of a drawing element This requires statement done AFTER the body is loaded can draw rectangles, paths (lines and arcs), images, text, and image from a video! can also display video element directly. Note: you (your code) can draw on a canvas. There can be more than one canvas. You (your code) can also position elements on the screen, NOT on a canvas.

Screen geometry Origin is upper left corner!!!! units are pixels (very small) Sometimes the terms top or y is used for vertical vertical values increase going down the screen. Think of “from the top” Sometimes the terms left or x is used for horizontal. Think of “from the left”. horizontal values increase going to the right. Screen geometry holds for Processing and some, though not all, programming languages/environments. Some call this upside down.

Drawings Default color is black. Drawing done for stroke versus fill. Colors are set using Names: for 16 specific colors and others http://www.tutorialspoint.com/html5/html5_color_names.htm. red-green-blue values, each as numbers 0 to 255 Hexadecimal Will get to this later. Browsers may not recognize all named colors, so sometimes the red-green-blue or hexadecimal (more on this in a later class) may be better.

0,0, default color, 10 by 10, stroke 500,0,default color,20 by 20, fill 0,0, default color, 10 by 10, stroke Code on next chart rgb(200,0,100) 0,300,green,30 by 30, stroke 500,300, 50 by 50, fill

<html> <head> <title>Four rectangles</title> <!DOCTYPE html> <html> <head> <title>Four rectangles</title> <script> var ctx; function init() { ctx = document.getElementById('canvas').getContext('2d'); ctx.lineWidth = 2; ctx.strokeRect(0,0,10,10); ctx.fillRect(500,0,20,20); ctx.strokeStyle = "green"; ctx.fillStyle = "rgb(200,0,100)"; ctx.strokeRect(0,300,30,30); ctx.fillRect(500,300,50,50); } </script> </head> <body onLoad="init();"> <canvas id="canvas" width="600" height="400"> Your browser doesn't support the HTML5 element canvas.</canvas> </body> </html> The strokeStyle and the fillStyle can be set any time before a stroke or fill is made. Remember: black is the default. Squares are made using fillRect and strokeRect.

Errors JavaScript is scripting language: interpret statements at execution time. NOT compiled, with error messages Semantic errors (errors of meaning) are more difficult to detect and fix! Syntactic errors are errors of form, analogous to grammatical errors FireFox Tools/Web Developer/Web Console can help Most common: bad bracketing ctx.fillStyle("rgb(200,0,100)"); fillStyle is attribute,not method A semantic error would be drawing a blue rectangle when I meant to draw a red one or drawing something in a different place.

Example of error given in the Web Console.

Comments The drawing is done by the init function which is called when the body element is loaded. The canvas element with id="canvas" does not exist until the body is loaded. if there was more than one canvas element, we would use different names for the ids. The name init is my choice. It could be something else. Default color is black. Red green blue values each are 0 to 255 (8 bits of intensity). The strokeStyle and the fillStyle are attributes, not methods. GO: experiment with colors (by name) and rgb (note the quotation marks) and location and width and height. The init function does not have to be called init, but that is a good name.

Classwork Do this now even if you haven't finished the coin toss programs. After you get my example working, change it! Put rectangles of different sizes in different places. Change colors. Confirm that your code does what you intended. Continue to do this yourself. Notice that you can put rectangles on top of rectangles. This is like paint on a canvas. After it is done, JavaScript doesn't "know" it was done by a fillRect or strokeRect command.

More comments Drawings are …paint on the canvas. These rectangles are not objects to be moved or referenced later. Use ctx.clearRect(…) method to erase. Need to do calculations to detect hits. See memory game in book. Alternative is dynamic placement of html markup See quiz, hangman. There are many examples to examine. Go to my HTML examples from my main site.

Reading code: sketch <html> <head> <title> Stuff </title> <script> var ctx; function init() { ctx = document.getElementById('canvas').getContext('2d'); ctx.lineWidth = 10; ctx.fillStyle = "green"; ctx.fillRect(500,10,150,300); ctx.strokeStyle = "pink"; ctx.strokeRect(10,320,650,30); } </script> </head> <body onLoad="init();"> <canvas id="canvas" width="900" height="600"> Your browser doesn't support the HTML5 element canvas.</canvas> </body> </html> If we aren't in class, try to sketch this and then copy it and save as an html file and open in a browser.

Images var himg = new Image(); himg.src = "head.jpg"; var timg = new Image(); timg.src = "tail.jpg"; … ctx.drawImage(himg,100,200, 60,60); or if you set x, y, w, h variables appropriately drawImage(himg, x, y, w, h); Note: if values are off screen, JavaScript does not complain! You can draw an image on a canvas.

Notice Compare img and Image img is the html element type Image is the built-in JavaScript object In html document: Elements: <html >, <body >, <a >, <img > Elements are Singletons: <img > Proper way is <img … /> or pairs: <a…>…. </a> Elements can contain attributes <a href=….>, <img src=….>, <body onLoad=…> Elements can contain text and/or other elements html document contains head and body head contains title, style, script body contains Write in notebook

Advice: Take notes Key concepts Questions & clarifications Ideas Drawings Combining what you know Random choice Changing img src Changing input values in a form Drawing on canvas More drawing tools coming Look at my examples, others

From now on… Modify (add to) your index.html file. Using Filezilla, Upload new programs The .html file and any other files Upload modified index.html file Also, can use web space or FILE space for unfinished work

Radians … are the units used for angles Not degrees An angle is specified in terms of the portion of a circle There are 2 * pi radians in a circle Math.PI is built in constant So Math.PI corresponds to 180 degrees Math.PI / 2 corresponds to 90 degrees

Drawing arcs If ctx is the context of a canvas element, ctx.arc(x, y, r, start, end) draws arc of circle with center at x, y, radius r, starting angle start, ending angle end, and going clockwise ctx,arc(x, y, r,start, end, true) produces arc going counterclockwise

Examples Use W3C Schools: http://www.w3schools.com/tags/canvas_arc.asp

Note/ Preview You can draw ovals using transformations. There also are other ways to draw curves Including Bezier curves. Research it!

Experiment Make drawings You can stick with rectangles or add arcs Try specifying different colors ctx.fillStyle = ctx.strokeStyle =

Classwork / homework [Finish basic coin toss, biased coin, counts] Practice drawings (your drawings). Preview (more in next class): coin toss drawing images on canvas. Saving it as new file, change your basic coin toss to draw images on the canvas. consult tutorial. You can do this. You can look at other examples. Look online for help. The logic is pretty much the same. The body element needs to hold a canvas element and a button element. The script element sets the ctx variable. More coming…