CS 4722 Computer Graphics and Multimedia Spring 2018

Slides:



Advertisements
Similar presentations
Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
Advertisements

Taking JavaScript Seriously IS NOT THE WORST IDEA.
JavaScript CMPT 281. Outline Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages.
CSE Real Time Rendering. TBT (Not So) Real Time Rendering.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
4.1 JavaScript Introduction
Build a Free Website1 Build A Website For Free 2 ND Edition By Mark Bell.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
Introduction to Applets CS 3505 Client Side Scripting with applets.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Tutorial 10 Programming with JavaScript
Introduction to Client Side Scripting CS Client Side Scripting Client side means the Browser is interpreting the script Script is downloaded with.
Programming with OpenGL Part 0: 3D API. For Further Reading Angel 7 th Ed: –2.2: JavaScript –2.3: OpenGL & WebGL –2.8: fragment & vertex shaders Beginning.
“The world’s most misunderstood language has become the world’s most popular programming language” Akshay Arora
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
MTA EXAM HTML5 Application Development Fundamentals.
Beginning JavaScript 4 th Edition. Chapter 1 Introduction to JavaScript and the Web.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript Invented 1995 Steve, Tony & Sharon. A Scripting Language (A scripting language is a lightweight programming language that supports the writing.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Cloud Computing in Systems Programming Curriculum Gustavo Rodriguez-Rivera, Purdue University Enrique Kortright, IBM.
Introduction to.
CGS 3066: Web Programming and Design Spring 2017
Web Programming Language
Web Technologies Computing Science Thompson Rivers University
>> Introduction to JavaScript
JavaScript Introduction
Tutorial 10 Programming with JavaScript
Chapter 1 Introduction to HTML.
CS4830 Computer Graphics, Fall 2016 Professor: Dr. Mihail
Nick Sims Scripting Languages.
Sampling and Aliasing Ed Angel Professor Emeritus of Computer Science
Introduction to Computer Graphics with WebGL
Introduction to JavaScript
CS 4722 Computer Graphics and Multimedia Spring 2018
14 A Brief Look at JavaScript and jQuery.
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
JavaScript an introduction.
Web Systems Development (CSC-215)
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 2: Complete Programs
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to JavaScript
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Unit 6 part 3 Test Javascript Test.
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Programming in JavaScript
Programming in JavaScript
Training & Development
JavaScript CS 4640 Programming Languages for Web Applications
The <script> Tag
Javascript Chapter 19 and 20 5/3/2019.
PHP an introduction.
Web Technologies Computing Science Thompson Rivers University
Introduction to Computer Graphics with WebGL
CS3220 Web and Internet Programming JavaScript Basics
Introduction to JavaScript
Web Programming and Design
Intro to Programming (in JavaScript)
JavaScript CS 4640 Programming Languages for Web Applications
Presentation transcript:

CS 4722 Computer Graphics and Multimedia Spring 2018 Example Code in JS CS 4722 Computer Graphics and Multimedia Spring 2018

Coding in WebGL Can run WebGL on any recent browser Chrome Firefox Safari IE Code written in JavaScript JS runs within browser Use local resources Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Example: triangle.html Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Triangle Example See notes page to get the code Will examine the code in WebStorm CS 4722

Exercise Run triangle.html from the class website Load the triangle.html and triangle.js to your computer and run them from there Edit the two files to change the color and display more than one triangle Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

JavaScript Notes JavaScript (JS) is the language of the Web References All browsers will execute JS code JavaScript is an interpreted object-oriented language References Flanagan, JavaScript: The Definitive Guide, O’Reilly Crockford, JavaScript, The Good Parts, O’Reilly Many Web tutorials Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

JS Notes Is JS slow? JS is a (too) big language JS engines in browsers are getting much faster Not a key issues for graphics since once we get the data to the GPU it doesn’t matter how we got the data there JS is a (too) big language We don’t need to use it all Choose parts we want to use Don’t try to make your code look like C or Java Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

JS Notes Very few native types: Only one numerical type: 32 bit float numbers strings booleans Only one numerical type: 32 bit float var x = 1; var x = 1.0; // same potential issue in loops two operators for equality == and === Dynamic typing Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Scoping Different from other languages Function scope variables are hoisted within a function can use a variable before it is declared Note functions are first class objects in JS Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

JS Arrays JS arrays are objects inherit methods var a = [1, 2, 3]; is not the same as in C++ or Java a.length // 3 a.push(4); // length now 4 a.pop(); // 4 avoids use of many loops and indexing Problem for WebGL which expects C-style arrays Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

Typed Arrays JS has typed arrays that are like C arrays var a = new Float32Array(3) var b = new Uint8Array(3) Generally, we prefer to work with standard JS arrays and convert to typed arrays only when we need to send data to the GPU with the flatten function in MV.js Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

A Minimalist Approach We will use only core JS and HTML no extras or variants No additional packages CSS JQuery Focus on graphics examples may lack beauty You are welcome to use other variants as long as I can run them from your URL Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

JavaScript Resource More than really needed, but this seems to be a good introduction to JavaScript Eloquent JavaScript: http://eloquentjavascript.net/ Free CS 4722

HTML Resource Mozilla introduction to HTML: https://developer.mozilla.org/en- US/docs/Learn/HTML/Introduction_to_HTML CS 4722