Skip to content

Commit a9c9bae

Browse files
committed
Adjusted images in tutorials
1 parent 9f18c92 commit a9c9bae

File tree

23 files changed

+629
-586
lines changed

23 files changed

+629
-586
lines changed

content/tutorials/text/2darray/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int[][] myArray = { {0, 1, 2, 3},
4343

4444
We can use this type of data structure to encode information about an image. For example, the following grayscale image could be represented by the following array:
4545

46-
<FixedImage width={650}>
46+
<FixedImage side width={200}>
4747

4848
![](./grid.jpg)
4949

@@ -83,7 +83,7 @@ for (int i = 0; i < cols; i++) {
8383

8484
For example, we might write a program using a two-dimensional array to draw a grayscale image.
8585

86-
<FixedImage center width={650} >
86+
<FixedImage side width={200} >
8787

8888
![](./points.jpg)
8989

@@ -115,7 +115,7 @@ for (int i = 0; i < cols; i++) {
115115

116116
A two-dimensional array can also be used to store objects, which is especially convenient for programming sketches that involve some sort of "grid" or "board." The following example displays a grid of Cell objects stored in a two-dimensional array. Each cell is a rectangle whose brightness oscillates from 0-255 with a sine function.
117117

118-
<FixedImage center width={650} >
118+
<FixedImage side width={200} >
119119

120120
![](./cells.jpg)
121121

content/tutorials/text/arrays/index.mdx

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ int x9 = 39;
4848

4949
Using what we know about drawing without arrays, ten variables are needed to store the data; each variable is used to draw a single rectangle. This is tedious:
5050

51+
<FixedImage side width={100} height={100}>
52+
5153
![](./28_01.png)
5254

55+
</FixedImage>
56+
5357
```
5458
int x0 = 50;
5559
int x1 = 61;
@@ -76,8 +80,12 @@ rect(0, 90, x9, 8);
7680

7781
In contrast, the following example shows how to use an array within a program. The data for each bar is accessed in sequence with a for loop. The syntax and usage of arrays is discussed in more detail in the following pages.
7882

83+
<FixedImage side width={100} height={100}>
84+
7985
![](./28_02.png)
8086

87+
</FixedImage>
88+
8189
```
8290
int[] x = {
8391
50, 61, 83, 69, 71, 50, 29, 31, 17, 39
@@ -156,8 +164,12 @@ int[] data = { 19, 40, 75, 76, 90 }; // Declare, create, assign
156164

157165
After an array is defined and assigned values, its data can be accessed and used within the code. An array element is accessed with the name of the array variable, followed by brackets around the element position to read.
158166

167+
<FixedImage side width={100} height={100}>
168+
159169
![](./28_09.png)
160170

171+
</FixedImage>
172+
161173
```
162174
int[] data = { 19, 40, 75, 76, 90 };
163175
@@ -192,8 +204,13 @@ println(data3.length); // Prints "127" to the console
192204

193205
Usually, a for loop is used to access array elements, especially with large arrays. The following example draws the same lines as code 28-09 but uses a for loop to iterate through every value in the array.
194206

207+
<FixedImage side width={100} height={100}>
208+
195209
![](./28_12.png)
196210

211+
</FixedImage>
212+
213+
197214
```
198215
int[] data = { 19, 40, 75, 76, 90 };
199216
@@ -204,8 +221,13 @@ for (int i = 0; i < data.length; i++) {
204221

205222
A for loop can also be used to put data inside an array. For instance, it can calculate a series of numbers and then assign each value to an array element. The following example stores the values from the `sin()` function in an array within `setup()` and then displays these values as the stroke values for lines within `draw()`.
206223

224+
<FixedImage side width={100} height={100}>
225+
207226
![](./28_13.png)
208227

228+
</FixedImage>
229+
230+
209231
```
210232
float[] sineWave;
211233
@@ -232,12 +254,25 @@ void draw() {
232254

233255
As one example of how arrays may be used, this section shows how to use arrays to store data from the mouse. The `pmouseX` and `pmouseY` variables store the cursor coordinates from the previous frame, but there is no built-in way to access the cursor values from earlier frames. At every frame, the `mouseX`, `mouseY`, `pmouseX`, and `pmouseY` variables are replaced with new numbers and their previous numbers are discarded. Creating an array is the easiest way to store the history of these values. In the following example, the most recent 100 values from `mouseY` are stored and displayed on screen as a line from the left to the right edge of the screen. At each frame, the values in the array are shifted to the right and the newest value is added to the beginning.
234256

257+
<FixedImage side width={100} height={100}>
258+
235259
![](./28_15_1.png)
236260

261+
</FixedImage>
262+
263+
<FixedImage side width={100} height={100}>
264+
237265
![](./28_15_2.png)
238266

267+
</FixedImage>
268+
269+
<FixedImage side width={100} height={100}>
270+
239271
![](./28_15_3.png)
240272

273+
</FixedImage>
274+
275+
241276
```
242277
int[] y;
243278
@@ -263,12 +298,25 @@ void draw() {
263298

264299
Apply the same code simultaneously to the `mouseX` and `mouseY` values to store the position of the cursor. Displaying these values each frame creates a trail behind the cursor.
265300

301+
<FixedImage side width={100} height={100}>
302+
266303
![](./28_16_1.png)
267304

305+
</FixedImage>
306+
307+
<FixedImage side width={100} height={100}>
308+
268309
![](./28_16_2.png)
269310

311+
</FixedImage>
312+
313+
<FixedImage side width={100} height={100}>
314+
270315
![](./28_16_3.png)
271316

317+
</FixedImage>
318+
319+
272320
```
273321
int num = 50;
274322
int[] x = new int[num];
@@ -455,12 +503,25 @@ Working with arrays of objects is technically similar to working with arrays of
455503

456504
These steps are translated into code in the following example. It uses the Ring class from page 371, so copy it over or retype it. This code creates a `rings[]` array to hold fifty `Ring` objects. Space in memory for the `rings[]` array is allocated in `setup()` and each `Ring` object is created. The first time a mouse button is pressed, the first `Ring` object is turned on and its `x` and `y` variables are assigned to the current values of the cursor. Each time a mouse button is pressed, a new `Ring` is turned on and displayed in the subsequent trip through `draw()`. When the final element in the array has been created, the program jumps back to the beginning of the array to assign new positions to earlier `Rings`.
457505

506+
<FixedImage side width={100} height={100}>
507+
458508
![](./28_24_1.png)
459509

510+
</FixedImage>
511+
512+
<FixedImage side width={100} height={100}>
513+
460514
![](./28_24_2.png)
461515

516+
</FixedImage>
517+
518+
<FixedImage side width={100} height={100}>
519+
462520
![](./28_24_3.png)
463521

522+
</FixedImage>
523+
524+
464525
```
465526
Ring[] rings; // Declare the array
466527
int numRings = 50;
@@ -523,10 +584,19 @@ class Ring {
523584

524585
The next example requires the `Spot` class from page 363. Unlike the prior example, variable values are generated within the `setup()` and are passed into each array elements through the object's constructor. Each element in the array starts with a unique set of x-coordinate, diameter, and speed values. Because the number of objects is dependent on the width of the display window, it is not possible to create the array until the program knows how wide it will be. Therefore, the array is declared outside of `setup()` to make it global (see p. 12), but it is created inside setup, after the width of the display window is defined.
525586

587+
<FixedImage center width={700} height={100}>
588+
526589
![](./28_25_1.png)
527590

591+
</FixedImage>
592+
593+
<FixedImage center width={700} height={100}>
594+
528595
![](./28_25_2.png)
529596

597+
</FixedImage>
598+
599+
530600
```
531601
Spot[] spots; // Declare array
532602
void setup() {
@@ -614,8 +684,13 @@ println(x[9][1]); // Prints "204"
614684

615685
This sketch shows how it all fits together.
616686

687+
<FixedImage side width={100} height={100}>
688+
617689
![](./28_27.png)
618690

691+
</FixedImage>
692+
693+
619694
```
620695
int[][] x = { {50, 0}, {61,204}, {83,51}, {69,102},
621696
{71, 0}, {50,153}, {29, 0}, {31,51},

content/tutorials/text/color/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ In addition, if we draw two shapes, Processing will always use the most recently
5353

5454
Remember finger painting? By mixing three &ldquo;primary&rdquo; colors, any color could be generated. Swirling all colors together resulted in a muddy brown. The more paint you added, the darker it got. Digital colors are also constructed by mixing three primary colors, but it works differently from paint. First, the primaries are diff erent: red, green, and blue (i.e., &ldquo;RGB&rdquo; color). And with color on the screen, you are mixing light, not paint, so the mixing rules are different as well.
5555

56+
<FixedImage center width={645} height={247}>
57+
5658
![](./rgb.jpg)
5759

60+
</FixedImage>
61+
5862
- Red + Green = Yellow
5963
- Red + Blue = Purple
6064
- Green + Blue = Cyan (blue-green)

content/tutorials/text/coordinate-system-and-shapes/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ It is important to acknowledge that these ellipses do not look particularly circ
126126
"point" over and over again), but for now, we are content with allowing the "ellipse" statement to do the hard work. (For more about pixels, start with: [the pixels reference page](http://processing.org/reference/pixels.html), though be warned this is a great deal more advanced than this tutorial.)
127127
Now let's look at what some code with shapes in more realistic setting, with window dimensions of 200 by 200. Note the use of the [`size()`](http://www.processing.org/reference/size_.html) function to specify the width and height of the window.
128128

129-
<FixedImage width={200} marginLeft={0}>
129+
<FixedImage side width={200} height={200}>
130130

131131
![](./1.11.jpg)
132132

0 commit comments

Comments
 (0)