Download presentation
Presentation is loading. Please wait.
Published byDaniella Fleming Modified over 9 years ago
1
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 More details and explanation …
2
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 12/13/2015© 2010 Larry Snyder, CSE2
3
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 12/13/2015© 2010 Larry Snyder, CSE3
4
Control “looping” with the mouse 12/13/2015© 2010 Larry Snyder, CSE4 Just Do It
5
Control “looping” with the mouse 12/13/2015© 2010 Larry Snyder, CSE5 … Looping off Turn looping on Turn looping off
6
Pressing a key is like pressing mouse button … 12/13/2015© 2010 Larry Snyder, CSE6 Result of typing g y m m y g Just Do It
7
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: 12/13/2015© 2010 Larry Snyder, CSE7
8
12/13/2015© 2010 Larry Snyder, CSE8
9
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( ) 12/13/2015© 2010 Larry Snyder, CSE9
10
“Create Font …” is under Tools 12/13/2015© 2010 Larry Snyder, CSE10
11
12/13/2015© 2010 Larry Snyder, CSE11 Try to pick common fonts Click to load font into the data directory
12
12/13/2015© 2010 Larry Snyder, CSE12 Try to pick common fonts Click to load font into the data directory
13
12/13/2015© 2010 Larry Snyder, CSE13 Need to declare font name(s)
14
12/13/2015© 2010 Larry Snyder, CSE14 Need to declare font name(s) Need to load named font
15
12/13/2015© 2010 Larry Snyder, CSE15 Need to declare font name(s) Need to load named font Need to select named font as “in use”
16
12/13/2015© 2010 Larry Snyder, CSE16 Need to declare font name(s) Need to load named font Need to select named font as “in use” Then, fill( ) and write text( … );
17
12/13/2015© 2010 Larry Snyder, CSE17
18
12/13/2015© 2010 Larry Snyder, CSE18 A String is a datatype of a letter sequence. The sequence must be surrounded by (double) quotes. "" is the empty String.
19
12/13/2015© 2010 Larry Snyder, CSE19 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.
20
12/13/2015© 2010 Larry Snyder, CSE20 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.
21
12/13/2015© 2010 Larry Snyder, CSE21 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
22
12/13/2015© 2010 Larry Snyder, CSE22 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 Just Do It
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.