Agenda & Assignment 11, March 17

CSC 101/IMM 120

Spring 2009

Summary of Class Activities:

You will need a folder of examples for this exercise.
(you can also find this folder on the front page as "Programming Examples"

Processing Code Sharing: put your Processing project from last week up on a computer and then walk around the room looking at the code others have written.

Three big topics today focus in HUMAN INTERFACE

  1. Typography - is remarkably like images, but the bits mean something different!
  2. Strings of characters. An ancient form of human expression
  3. Mouse & keyboard input: simple communication
  Wolz Examples Book Pages Processing Examples Reference page commands
Typography

_01BasicTypography
_02AnimatedTypography
_30MouseTypography

737-740 Basics/Typography Pfont, loadFont, textFont, text, textAlign,textSize, textLeading, textWidth
Strings

_04CharAndString
_05OperationsOnCharAndString
_06EqualsString
_07Tickertape

679-682 Nothing simple enough char, String, "+" operator concatenates.
Keyboard events

_08KeyEventMethods
_09KeyVariables
_10KeyMovement

603-612 Input key, keyCode,keyPressed, keyPressed(),keyReleased()
Mouse events _11MouseExample 564-603 Input mouseDragged(),mouseMoved(),mouseButton,mouseX,mouseReleased(),pmouseX,mousePressed(),mouseY,mousePressed,pmouseY

 

A Brief Summary of "Written" communication:

Typography:

Same idea as images: a class of objects called "PFont" holds the data representation of the fonts.

Review of the notion of the "data" file attached to the folder where the Processing project is stored.
Like an image, the Pfont file is stored here. You create the Pfont file using the "Tools" pulldown menu. (You can also programmatically use "createFont" but we won't.

The steps are:

  1. Load the font (loadFont). This just prepares it.
  2. Specify the font to use for subsequent text (textFont).
  3. Optionally specify the text alignment. (textAlign)
  4. Color the text (fill).
  5. Place the text on the screen (text).

Strings:

A symbolic "character" is one of the oldest ideas in programming.
You might want to look up "ASCII" or "UNICODE" on the internet....

char is a primitive datatype (like int, float, color)
To specify a character surround it with single quotation marks: 'a'.

String is a composite datatype (like Array). It holds a sequence of characters.
To specify a string surround it with double quotations marks: "hello"
A String is also a "class" and has methods! Look them up in the reference

Important String methods and operations:

+ concatenates two strings: "hi " + "there" becomes "hi there". (note the space in the first string!)

length() is very helpful and determines the length of the string

equals() determines whether two strings have the same characters. Don't use "==" for strings. (Long story, not now.)

Others: charAt(), indexOf(), substring(), toLowerCase(), toUpperCase()

Keyboard & Mouse Input

Keyboard input is based on the idea of an event. You've seen events in Scratch.
Event METHODS are like event SCRIPTS in Scratch, they are called by the operating system when an event such as a key press occurs.

You can also use the keypress variable but this isn't as useful.

Detecting particular keys is done with the "key" and "keyCode" variables.

Mouse detection acts pretty much the same way.

Detecting other kinds of sensors also works this way.......

 

HOMEWORK

Reading: (Due March 24) Read Chapters 9 & 10. But read for your own pleasure and edification, not like this was a textbook where you have to remember EVERYTHING for the multiple choice test. Make notes on what is interesting and what you might find useful in the future. Pick one example and try running it. Or run all the examples.....or some of them.

Programming Assignment: (Due Tuesday, March 24)

Once again you will be asked to create a simple sketch of your own based on the examples presented this week. Begin by working through the questions in the set of sketches presented in class. If you have trouble figuring something out, work with a classmate, post a question on the wiki, bring the question to class on Friday or email Dr. Wolz. Your sketch this week should include two of the following: typogrpahy, string manipulation and keyboard input.

Journal Assignment: (Due Tuesday, March 10) Events are a big deal in user interactivity. Contrast the way events are implemented in Scratch and Processing.