programming_fundamentals_with_processing:ch02-getting-going.html
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
programming_fundamentals_with_processing:ch02-getting-going.html [2017/07/26 16:47] – [Program statements] mithat | programming_fundamentals_with_processing:ch02-getting-going.html [2017/07/26 17:44] (current) – [The console] mithat | ||
---|---|---|---|
Line 7: | Line 7: | ||
==== Source code ==== | ==== Source code ==== | ||
- | A computer program' | + | In programming, |
- | )) The source code you write is stored in files called **source code files** --- sometimes shortened to simply **sources** or **code**. Thus, source code files are text files made up of sets of instructions written in a particular programming language that express what you'd like the program to do. | + | )) The source code you write is stored in files called **source code files**---sometimes shortened to simply **sources** or **code**. Thus, source code files are text files made up of sets of instructions written in a particular programming language that express what you'd like the program to do. |
==== Entry points ==== | ==== Entry points ==== | ||
- | Some languages start executing a program at the first bit of program text that is in the program' | + | Some languages start executing a program at the first bit of program text that is in the program' |
=== Processing without an entry point === | === Processing without an entry point === | ||
- | Below is one of the simplest Processing programs you can write. When executed, it will print an important message about cranberries. | + | Below is one of the simplest Processing programs you can write. When executed, it will print an important message about cranberries.((Yes, this text output goes against the visual intent of Processing! Don't worry, we'll get to visual stuff shortly.)) |
< | < | ||
Line 31: | Line 31: | ||
</ | </ | ||
- | Processing' | + | Processing' |
=== Processing with an entry point === | === Processing with an entry point === | ||
Line 51: | Line 51: | ||
} | } | ||
</ | </ | ||
+ | |||
The code that is written between the pair of curly braces is called the **body** of the '' | The code that is written between the pair of curly braces is called the **body** of the '' | ||
Line 58: | Line 59: | ||
void setup() { | void setup() { | ||
</ | </ | ||
- | and/or after the matching | + | and/or after the matching |
- | + | ||
- | <code java> | + | |
- | } | + | |
- | </ | + | |
the program will actually start at the first statement in the '' | the program will actually start at the first statement in the '' | ||
Line 68: | Line 65: | ||
void setup() { | void setup() { | ||
</ | </ | ||
+ | |||
==== Program statements ==== | ==== Program statements ==== | ||
Line 131: | Line 129: | ||
Sending text messages to the console can be accomplished with two predefined Processing functions: '' | Sending text messages to the console can be accomplished with two predefined Processing functions: '' | ||
- | **program '' | + | <file java cranberries.pde> |
- | + | ||
- | <code java> | + | |
void setup() { | void setup() { | ||
println(" | println(" | ||
} | } | ||
- | </code> | + | </file> |
The above code consists of a definition of the '' | The above code consists of a definition of the '' | ||
Line 143: | Line 140: | ||
Cranberries are high in antioxidants. | Cranberries are high in antioxidants. | ||
</ | </ | ||
+ | |||
Notice the double quotation marks around the text. These are important. They tell '' | Notice the double quotation marks around the text. These are important. They tell '' | ||
Line 159: | Line 157: | ||
} | } | ||
</ | </ | ||
+ | |||
produces the following console output: | produces the following console output: | ||
Line 164: | Line 163: | ||
Cranberries are high in antioxidants. | Cranberries are high in antioxidants. | ||
</ | </ | ||
+ | |||
Using '' | Using '' | ||
Line 174: | Line 174: | ||
} | } | ||
</ | </ | ||
- | will outputs: | + | |
+ | will output: | ||
< | < | ||
Line 182: | Line 183: | ||
antioxidants. | antioxidants. | ||
</ | </ | ||
+ | |||
=== Outputting numbers and calculations === | === Outputting numbers and calculations === | ||
Line 217: | Line 219: | ||
</ | </ | ||
- | ---- | + | <WRAP center round box 80%> |
=== Geek break: What about input? === | === Geek break: What about input? === | ||
Line 226: | Line 227: | ||
Because text-based input is as involved as it is in Processing, we will avoid it in this text. We will, however, work with some of the interaction features that Processing makes very easy when we cover //event handling//. | Because text-based input is as involved as it is in Processing, we will avoid it in this text. We will, however, work with some of the interaction features that Processing makes very easy when we cover //event handling//. | ||
+ | </ | ||
- | ---- | ||
==== The canvas ==== | ==== The canvas ==== |
programming_fundamentals_with_processing/ch02-getting-going.html.1501087659.txt.gz · Last modified: 2017/07/26 16:47 by mithat