Chars and Strings
Processing
In Processing there are two different variable types that can contain text: Chars and Strings. A char is a single letter and a String is text of any length. In 95% of all cases, using a String makes the most sense. Take a look at these two examples:
char c = 'a';
String txt = "Hi Internet!";
There are two very small syntactical differences between char and String: When using char, the variable type is written in lowercase and single quotation marks are used. For a String, the S must be capitalized and double quotes are always used.
These two rules must be respected, otherwise Processing will refuse to start the sketch.
P5.js
P5.js does not distinguish between the two during initialization.
let c = 'a';
let txt = 'Hi Internet!';
Language Comparison
- Chars and Strings
- Displaying Text
- Styling Text
- Preloading (p5.js)
- Asset-Management
- Utilizing a font
- Text-Frames
- Line-Breaks
- Line-Height
- String Methods
- String Concatenation
- Getting the Text-Width
- Example: charArt
- Example: Newsticker
- Example: 3D Typography
- Example: Circular Distribution
- Addon: Letter Spacing
- Wrapping Up