Input and Interaction. Objectives



Similar documents
Input and Interaction

Input and Interaction. Project Sketchpad. Graphical Input. Physical Devices. Objectives

Input and Interaction. CS 432 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Tutorial 6 Creating a Web Form. HTML and CSS 6 TH EDITION

Graphics Input Primitives. 5. Input Devices Introduction to OpenGL. String Choice/Selection Valuator

Using HTML5 Pack for ADOBE ILLUSTRATOR CS5

HP LoadRunner. Software Version: Ajax TruClient Tips & Tricks

CS 378: Computer Game Technology

jquery Tutorial for Beginners: Nothing But the Goods

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

IMRG Peermap API Documentation V 5.0

Using WINK to create custom animated tutorials

Dashboard Skin Tutorial. For ETS2 HTML5 Mobile Dashboard v3.0.2

TabletWorks Help Index 1

The Keyboard One of the first peripherals to be used with a computer and is still the primary input device for text and numbers.

«W3Schools Home Next Chapter» JavaScript is THE scripting language of the Web.

PN-L702B LCD MONITOR TOUCH PANEL DRIVER OPERATION MANUAL. Version 2.1

MASTERTAG DEVELOPER GUIDE

Computer Graphics. Computer graphics deals with all aspects of creating images with a computer

Interactive Whiteboard Functionality Overview Choosing Pen Style Erasing / Modifying Writing Undo / Redo

Inteset Secure Lockdown ver. 2.0

Help. Contents Back >>

Pay with Amazon Integration Guide

No restrictions are placed upon the use of this list. Please notify us of any errors or omissions, thank you,

13-1. This chapter explains how to use different objects.

ios 9 Accessibility Switch Control - The Missing User Guide Updated 09/15/15

Kodu Curriculum: Getting Started with Keyboard and Mouse

Microsoft Expression Web

Multiprocess System for Virtual Instruments in Python

Introduction to ROOT and data analysis

PowerPoint 2007 Basics Website:

Quick installation guide for the Vista Quantum QNVR Network Video Recorder

Viewing Form Results

Advantech WebAccess Device Driver Guide. BwSNMP Advantech WebAccess to SNMP Agent (Simple Network Management Protocol) Device Driver Guide

CREATE A 3D MOVIE IN DIRECTOR

Evoluent Mouse Manager for Windows. Download the free driver at evoluent.com. The primary benefits of the Mouse Manager are:

What is Microsoft PowerPoint?

4.3. Windows. Tutorial

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

PowerPoint 2013: Basic Skills

REFERENCE GUIDE 1. INTRODUCTION

Apple Pro Training Series: Logic Pro X: Professional Music Production

Using Impatica for Power Point

Epson Brightlink Interactive Board and Pen Training. Step One: Install the Brightlink Easy Interactive Driver

Wincopy Screen Capture

STEP 7 MICRO/WIN TUTORIAL. Step-1: How to open Step 7 Micro/WIN

USER GUIDE Version 2.0

The CAD interface is comprised of two different screens: the graphic/drawing screen and the text screen.

IE Class Web Design Curriculum

Fireworks 3 Animation and Rollovers

Bitrix Site Manager 4.0. Quick Start Guide to Newsletters and Subscriptions

Cloudvue Remote Desktop Client GUI User Guide

BT CONTENT SHOWCASE. JOOMLA EXTENSION User guide Version 2.1. Copyright 2013 Bowthemes Inc.

Sharing Software. Chapter 14

Installing An ActiveX Control in InTouch

PIC 10A. Lecture 7: Graphics II and intro to the if statement

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Content Author's Reference and Cookbook

<option> eggs </option> <option> cheese </option> </select> </p> </form>

After that you can log in and start creating games or playing existing games.

Using the HOCK flash cards in Anki on Windows, Mac, mobile and web

Hauppauge Capture. Copyright 2013 Hauppauge Computer Works

USB GSM 3G modem RMS-U-GSM-3G. Manual (PDF) Version 1.0,

Introduction to WebGL

How to Add a Transparent Flash FLV movie to your Web Page Tutorial by R. Berdan Oct

STB- 2. Installation and Operation Manual

Copyright 2006 TechSmith Corporation. All Rights Reserved.

SCADA Questions and Answers

GUI and Web Programming

The mouse callback. Positioning. Working with Callbacks. Obtaining the window size. Objectives

FrenzelSoft Stock Ticker

TCP/IP Networking, Part 2: Web-Based Control

Microsoft Windows Overview Desktop Parts

Desktop Reference Guide

Scripting Language Reference. SimpleBGC 32bit

Create A Collage Of Warped Photos

X Series Application Note 43:

Event processing in Java: what happens when you click?

Example. Represent this as XML

Grandstream XML Application Guide Three XML Applications

The Smart Forms Web Part allows you to quickly add new forms to SharePoint pages, here s how:

EZ GPO. Power Management Tool for Network Administrators.

Acceleration of Gravity Lab Basic Version

Further web design: HTML forms

CCNA Discovery Networking for Homes and Small Businesses Student Packet Tracer Lab Manual

Choosing your Preferred Colours in Windows

EET 310 Programming Tools

CHAPTER 11: Flip Flops

Tecla for Android. Downloading and Installing the Tecla Access App. Activating and Selecting the Tecla Access Keyboard

MetroPro Remote Access OMP-0476F. Zygo Corporation Laurel Brook Road P.O. Box 448 Middlefield, Connecticut 06455

If you are having a problem or technical issue regarding your IP Telephone, please call the UAA IT Call Center at

WAYNESBORO AREA SCHOOL DISTRICT CURRICULUM INTRODUCTION TO COMPUTER SCIENCE (June 2014)

7 The Shopping Cart Module

3D-GIS in the Cloud USER MANUAL. August, 2014

FREE FALL. Introduction. Reference Young and Freedman, University Physics, 12 th Edition: Chapter 2, section 2.5

Component Based Rapid OPC Application Development Platform

Transcription:

Input and Interaction Thanks to Ed Angel Professor Emeritus of Computer Science, University of New Mexico Objectives Introduce the basic input devices Physical Devices Logical Devices Input Modes Event driven input Introduce double buffering for smooth animations Programming event input with javascript/html5 1

Project Sketchpad Ivan Sutherland (MIT 1963) established the basic interactive paradigm that characterizes interactive computer graphics: User sees an object on the display User points to (picks) the object with an input device (light pen, mouse, trackball) Object changes (moves, rotates, morphs) Repeat Graphical Input Devices can be described either by Physical properties Mouse Keyboard Trackball Logical Properties What is returned to program via API A position An object identifier Modes How and when input is obtained Request or event 2

Physical Devices mouse trackball Multi touch data tablet joy stick space ball Incremental (Relative) Devices Devices such as the data tablet return a position directly to the operating system Devices such as the mouse, trackball, and joy stick return incremental inputs (or velocities) to the operating system Must integrate these inputs to obtain an absolute position Rotation of cylinders in mouse Roll of trackball Difficult to obtain absolute position Can get variable sensitivity 3

Logical Devices Consider the C and C++ code C++: cin >> x; C: scanf ( %d, &x); What is the input device? Can t tell from the code Could be keyboard, file, output from another program The code provides logical input A number (an int) is returned to the program regardless of the physical device Graphical Logical Devices Graphical input is more varied than input to standard programs which is usually numbers, characters, or bits Two older APIs (GKS, PHIGS) defined six types of logical input Locator: return a position Pick: return ID of an object Keyboard: return strings of characters Stroke: return array of positions Valuator: return floating point number Choice: return one of n items 4

X Window Input The X Window System introduced a client server model for a network of workstations Client: OpenGL program Graphics Server: bitmap display with a pointing device and a keyboard Input Modes Input devices contain a trigger which can be used to send a signal to the operating system Button on mouse Pressing or releasing a key When triggered, input devices return information (their measure) to the system Mouse returns position information Keyboard returns ASCII code 5

Request Mode Input provided to program only when user triggers the device Typical of keyboard input Can erase (backspace), edit, correct until enter (return) key (the trigger) is depressed Event Mode Most systems have more than one input device, each of which can be triggered at an arbitrary time by a user Each trigger generates an event whose measure is put in an event queue which can be examined by the user program 6

Event Types Window: resize, expose, iconify Mouse: click one or more buttons Motion: move mouse Keyboard: press or release a key Idle: nonevent Define what should be done if no other event is in queue Callbacks Programming interface for event driven input uses callback functions or event listeners Define a callback for each event the graphics system recognizes Browsers enters an event loop and responds to those events for which it has callbacks registered The callback function is executed when the event occurs 7

Execution in a Browser Execution in a Browser Start with HTML file Describes the page May contain the shaders Loads files Files are loaded asynchronously and JS code is executed Then what? Browser is in an event loop and waits for an event 8

onload Event What happens with our JS file containing the graphics part of our application? All the action is within functions such as init() and draw() Consequently these functions are never executed and we see nothing Solution: use the onload window event to initiate execution of the init function onload event occurs when all files read window.onload = init; Example Canvas 0 and Canvas 1 9

Double Buffering Although we are rendering the square, it always into a buffer that is not displayed Browser uses double buffering Always display front buffer Rendering into back buffer Need a buffer swap Prevents display of a partial rendering Triggering a Buffer Swap Browsers refresh the display at ~60 Hz redisplay of front buffer not a buffer swap Trigger a buffer swap though an event Two options for triggering a buffer swap Interval timer requestanimframe 10

Interval Timer Repeatedly executes a function after a specified number of milliseconds Also generates a buffer swap setinterval(draw, interval); Note an interval of 0 generates buffer swaps as fast as possible Interval Timer GUI setinterval.html 11

Timeout Timer Executes a function once after a specified number of milliseconds Also generates a buffer swap settimeout(draw, delay); Note a delay of 0 generates buffer swaps as fast as possible Timeout Timer GUI settimeout.html 12

requestanimframe Recursively call the drawing function Also generates a buffer swap Buffer swaps as fast as possible requestanimframe GUI RAF.html GUI mousefocus.html 13

Putting it all together Learn to build interactive programs using event listeners Buttons Sliders Menus Mouse Keyboard Reshape Adding a Button Let s add a button to stop the ball. Clear the interval clearinterval(animball); 14

The Button In the HTML file <button onclick="mystopfunction()">stop Ball</button> Uses HTML button tag onclick gives the callback we can use in JS file Text Stop Ball displayed in button Clicking on button generates a click event Note we are using default style and could use CSS or jquery to get a prettier button Button Event Listener We could have defined a listener no listener and the event occurs but is ignored Two forms for event listener in JS file var mybutton = document.getelementbyid( stopbutton"); // needs an id for the button mybutton.addeventlistener("click", function() { do something as this is the callback; }); document.getelementbyid( stopbutton").onclick = function() {do something as this is the callback; }; 15

onclick Variants mybutton.addeventlistener("click", function() { if (event.button == 0) { direction =!direction; } }); mybutton.addeventlistener("click", function() { if (event.shiftkey == 0) { direction =!direction; } }); <button onclick="direction =!direction"></button> Buttons GUI setinterval.html GUI setinterval Stop.html GUI setinterval Start Stop.html GUI setinterval Stop Speed.html 16

Controlling Ball Speed GUI RAF speedcontrol.html GUI RAF speedcontrol stop.html Slider Element Puts slider on page Give it an identifier Give it minimum and maximum values Give it a step size needed to generate an event Give it an initial value Use div tag to put below canvas <div> speed 0 <input id="slide" type="range" min="0" max="100" step="10" value="50" /> 100 </div> 17

onchange Event Listener document.getelementbyid("slide").onchange = function() { delay = event.srcelement.value; }; Controlling Ball Speed GUI speedslider.html 18

Menus Use the HTML select element Each entry in the menu is an option element with an integer value returned by click event <select id = "Controls" size = "4"> <option value = "0"> Start </option> <option value = "1"> Stop </option> <option value = "2"> Slower </option> <option value = "3"> Faster </option> </select> Menu Listener document.getelementbyid("controls").onclick = function( event) { switch(event.srcelement.index) { case 0: start = 1; raf = window.requestanimationframe(draw); break; case 1: start=0; window.cancelanimationframe(raf); break; case 2: delay += 10; break; case 3: delay = 10; break; } } 19

Menu GUI RAF speedcontrol stop menu.html Using keydown Event window.onkeydown = function( event ) { var key = String.fromCharCode(event.keyCode); switch( key ) { case '0': start = 1; raf = window.requestanimationframe(draw); break; case '1': start=0; window.cancelanimationframe(raf); break; case '2': delay += 10; break; case '3': delay = 10; break; } }; 20

Keydown event w/ menu GUI RAF speedcontrol stop menu keyboard.html 21