In this section, you are going to work using and displaying strings to the canvas and various string methods.
Write a sketch named section_13_2 .
This time, display the same lyrics, but you may use the text() function only one time.
How can this be done?
|
Write a sketch named section_13_3 .
Next, repeat the lyrics four (or more) times on the canvas, as is pictured.
Don't just copy/paste text() calls four times.
Instead, store the String into a variable, and use the variable when displaying the text.
Using the variable will help you reduce the size and reprtition in your program.
|
Write a sketch named section_13_4 .
As you can see, this sketch simulates the scrolling-space-text seen at the beginning of most Star-Wars films
(Trivia: which movie does this scrolling-space-text text not appear in?).
You can use the same text as I did, or find other text from Star-Wars online.
You should put the text into a String variable, and you may only use one String variable and one use of the text() function.
To do this, but newlines (\n ) directly into the string with the text.
Also, don't forget to incldue some stars in the background!
|
Write a sketch named section_13_5 .
This sketch will display some strings to the canvas that keep track of the mouse clicks, key clicks, and frames of your program.
Each time the mouse is clicked, the clicked count will increase by one.
Each time any key on the keyboard is pressed, the keyboard count will increase by one.
Each time a new fram is displayed (in other words, each time draw is run) the frame count will increase.
You should keep track of these three values with integer variables in your program.
To display the words to the screen, you will need to concatenate strings and numbers together with the + sign.
Also, you will probably want to make your frameRate() slow, so that the last line doe not change insanely fast.
|
The last few problems require the use of the substring()
function in processing.
We just barely got to talk about this function in class before your section.
If you don’t feel confident in using it, do one or more of the following before tackling these problems:
substring()
class slides
Write a sketch named section_13_6 .
This sketch will display one simple string, the word "COOL".
However, the only string variable that you are allowed to "hard-code" in your program is the following:
alph string.
Recall that to do this, use the substring() function, which is built-into all String variables.
For example, to access the letter "D" in the alph variable, you would do the following:
letterD variable.
This ends up just being the letter "D".
Create a new string variable the has "COOL" in it using this technique, and then display it on the canvas.
|
Write a sketch named section_13_6 .
In this program, you will build off of what you did in problem 6.
Using the same alph variable, extract three words: "COOL", "STORY" and "BRO".
Once you have extracted them, display them on the canvas in three different colors, as shown
|
Write a sketch named section_11_7 .
You can use the below code as a starting point:
str into two chunks, based on where the [x] is.
After splitting, show the string that is before it and after it on the canvas.
You should not just hard-code the indexes to work with only "ABCDEFGHIJKLMN[x]OPQRSTUVWXYZ" .
It should worf for other strings with [x] in it as well.
|