lawrence snyder university of washington, seattle © lawrence snyder 2004 more details and...
TRANSCRIPT
![Page 1: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/1.jpg)
Lawrence SnyderUniversity of Washington, Seattle
© Lawrence Snyder 2004
More details and explanation …
![Page 2: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/2.jpg)
An important part of computing is the input to the program and the output it produces
We consider three types of I/O Mouse Input Key Input Text Input
04/21/23 © 2010 Larry Snyder, CSE 2
![Page 3: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/3.jpg)
So that it is all out there, here’s the situation on the mouse (you’ve seen most of this):
mouseX and mouseY give the coordinates of the mouse on the canvas … recall:
rect(mouseX, mouseY, 20, 20); void mousePressed ( ) {
dir = 0 – dir; } There’s also mouseReleased that “fires”
when the mouse is released after being pressed
04/21/23 © 2010 Larry Snyder, CSE 3
![Page 4: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/4.jpg)
Control “looping” with the mouse
04/21/23 © 2010 Larry Snyder, CSE 4
Just Do It
Just Do It
![Page 5: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/5.jpg)
Control “looping” with the mouse
04/21/23 © 2010 Larry Snyder, CSE 5
…Looping off
Turn looping on
Turn looping off
![Page 6: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/6.jpg)
Pressing a key is like pressing mouse button …
04/21/23 © 2010 Larry Snyder, CSE 6
Result of typing g y m m y g
Just Do It
Just Do It
![Page 7: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/7.jpg)
The key keyword has the value of the key just pressed; it has the datatype of a character, that is, char
Notice that characters are enclosed in single quotes:
04/21/23 © 2010 Larry Snyder, CSE 7
![Page 8: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/8.jpg)
04/21/23 © 2010 Larry Snyder, CSE 8
![Page 9: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/9.jpg)
Processing is great for graphics and images, but it is a little more cumbersome for text
Follow these steps: 1) Go to tools and locate the font you want 2) Load font into the data directory of your
program … this happens automatically when you load
3) In the code, load the font into the computation (get name and size perfect); specify its use
4) Use text( ) to print text; color using fill( )04/21/23 © 2010 Larry Snyder, CSE 9
![Page 10: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/10.jpg)
“Create Font …”is under Tools
04/21/23 © 2010 Larry Snyder, CSE 10
![Page 11: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/11.jpg)
04/21/23 © 2010 Larry Snyder, CSE 11
Try to pickcommon fontsClick to loadfont into thedata directory
![Page 12: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/12.jpg)
04/21/23 © 2010 Larry Snyder, CSE 12
Try to pickcommon fontsClick to loadfont into thedata directory
![Page 13: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/13.jpg)
04/21/23 © 2010 Larry Snyder, CSE 13
Need to declare font name(s)
![Page 14: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/14.jpg)
04/21/23 © 2010 Larry Snyder, CSE 14
Need to declare font name(s)
Need to load named font
![Page 15: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/15.jpg)
04/21/23 © 2010 Larry Snyder, CSE 15
Need to declare font name(s)
Need to load named font
Need to select named font as “in use”
![Page 16: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/16.jpg)
04/21/23 © 2010 Larry Snyder, CSE 16
Need to declare font name(s)
Need to load named font
Need to select named font as “in use”
Then, fill( ) and write text( … );
![Page 17: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/17.jpg)
04/21/23 © 2010 Larry Snyder, CSE 17
![Page 18: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/18.jpg)
04/21/23 © 2010 Larry Snyder, CSE 18
A String is a datatype of a letter sequence. The sequence must be surrounded by (double) quotes. "" is the empty String.
![Page 19: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/19.jpg)
04/21/23 © 2010 Larry Snyder, CSE 19
A String is a datatype of a letter sequence. The sequence must be surrounded by (double) quotes. "" is the empty String.
A character can be added to a String (it’s called concatenation) using a + sign.
![Page 20: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/20.jpg)
04/21/23 © 2010 Larry Snyder, CSE 20
A String is a datatype of a letter sequence. The sequence must be surrounded by (double) quotes. "" is the empty String.
A character can be added to a String (it’s called concatenation) using a + sign.
Use the String like any quoted letter sequence.
![Page 21: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/21.jpg)
04/21/23 © 2010 Larry Snyder, CSE 21
A String is a datatype of a letter sequence. The sequence must be surrounded by (double) quotes. “” is the empty String.
A character can be added to a String (it’s called concatenation) using a + sign.
Type A B C
![Page 22: Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …](https://reader035.vdocuments.mx/reader035/viewer/2022070413/5697bf951a28abf838c90dcb/html5/thumbnails/22.jpg)
04/21/23 © 2010 Larry Snyder, CSE 22
A String is a datatype of a letter sequence. The sequence must be surrounded by (double) quotes. “” is the empty String.
A character can be added to a String (it’s called concatenation) using a + sign.
Type A B CJust Do It
Just Do It