Skip to content

Commit 928be15

Browse files
additional tutorial image fixes and upgrades
1 parent f22a25a commit 928be15

File tree

135 files changed

+25461
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+25461
-161
lines changed
Loading
Binary file not shown.
Loading
Binary file not shown.
Loading
Loading
Loading
Loading

content/tutorials/text/2d-transformations/index.mdx

+22-22
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ Processing has built-in functions that make it easy for you to have objects in a
2020

2121
As you know, your Processing window works like a piece of graph paper. When you want to draw something, you specify its coordinates on the graph. Here is a simple rectangle drawn with the code `rect(20, 20, 40, 40)`. The coordinate system (a fancy word for “graph paper”) is shown in gray.
2222

23-
<FixedImage center width={230} height={230}>
23+
<FixedImage center width={650} height={400}>
2424

25-
![Black rectangle on gray numbered grid](./original.png)
25+
![Black rectangle on gray numbered grid](./original.svg)
2626

2727
</FixedImage>
2828

2929
If you want to move the rectangle 60 units right and 80 units down, you can just change the coordinates by adding to the _x_ and _y_ starting point: `rect(20 + 60, 20 + 80, 40, 40)` and the rectangle will appear in a different place. (We put the arrow in there for dramatic effect.)
3030

31-
<FixedImage center width={230} height={230}>
31+
<FixedImage center width={650} height={400}>
3232

33-
![Black rectangle on gray numbered grid, moved](./new_coords.png)
33+
![Black rectangle on gray numbered grid, moved](./new_coords.svg)
3434

3535
</FixedImage>
3636

3737
But there is a more interesting way to do it: **move the graph paper instead**. If you move the graph paper 60 units right and 80 units down, you will get exactly the same visual result. Moving the coordinate system is called _translation_.
3838

39-
<FixedImage center width={240} height={240}>
39+
<FixedImage center width={650} height={600}>
4040

41-
![grid moved with arrow showing motion](./moved_grid.png)
41+
![grid moved with arrow showing motion](./moved_grid.svg)
4242

4343
</FixedImage>
4444

@@ -79,7 +79,7 @@ Yes, you could have done a `translate(-60, -80)` to move the grid back to its or
7979

8080
You may be thinking that picking up the coordinate system and moving it is a lot more trouble than just adding to coordinates. For a simple example like the rectangle, you are correct. But let's take an example of where `translate()` can make life easier. Here is some code that draws a row of houses. It uses a loop that calls a function named `house()`, which takes the _x_ and _y_ location of the house's upper-left corner as its parameters.
8181

82-
<FixedImage center width={358} height={81}>
82+
<FixedImage center width={400} height={100}>
8383

8484
![Row of stick-figure houses](./houses.png)
8585

@@ -129,15 +129,15 @@ void house(int x, int y)
129129

130130
In addition to moving the grid, you can also rotate it with the `rotate()` function. This function takes one argument, which is the number of _radians_ that you want to rotate. In Processing, all the functions that have to do with rotation measure angles in radians rather than degrees. When you talk about angles in degrees, you say that a full circle has 360&#xb0;. When you talk about angles in radians, you say that a full circle has 2&pi; radians. Here is a diagram of how Processing measures angles in degrees (black) and radians (red).
131131

132-
<FixedImage center width={158} height={157}>
132+
<FixedImage center width={650} height={400}>
133133

134-
![Degrees are measured clockwise with zero being at 3 o'clock](./degrees.png)
134+
![Degrees are measured clockwise with zero being at 3 o'clock](./degrees.svg)
135135

136136
</FixedImage>
137137

138138
Since most people think in degrees, Processing has a built-in `radians()` function which takes a number of degrees as its argument and converts it for you. It also has a `degrees()` function that converts radians to degrees. Given that background, let's try rotating a square clockwise 45 degrees.
139139

140-
<FixedImage side width={120} height={120}>
140+
<FixedImage side width={200} height={200}>
141141

142142
![square has moved and rotated](./bad_rotate.png)
143143

@@ -164,9 +164,9 @@ void setup()
164164

165165
Hey, what happened? How come the square got moved and cut off? The answer is: the square did not move. The **grid** was rotated. Here is what really happened. As you can see, on the rotated coordinate system, the square still has its upper left corner at (40, 40).
166166

167-
<FixedImage center width={275} height={250}>
167+
<FixedImage center width={650} height={500}>
168168

169-
![shows grid rotated 45 degrees clockwise](./rotated_grid.png)
169+
![shows grid rotated 45 degrees clockwise](./rotated_grid.svg)
170170

171171
</FixedImage>
172172

@@ -178,15 +178,15 @@ The correct way to rotate the square is to:
178178
2. Rotate the grid &pi;/4 radians (45&#xb0;)
179179
3. Draw the square at the origin.
180180

181-
<FixedImage center width={310} height={250}>
181+
<FixedImage center width={650} height={600}>
182182

183-
![Grid translated, then rotated](./correct_rotate_grid.png)
183+
![Grid translated, then rotated](./correct_rotate_grid.svg)
184184

185185
</FixedImage>
186186

187187
And here is the code and its result, without the grid marks.
188188

189-
<FixedImage side width={120} height={120}>
189+
<FixedImage side width={200} height={200}>
190190

191191
![result of properly rotating square](./good_rotate.png)
192192

@@ -219,7 +219,7 @@ void setup()
219219

220220
And here is a program that generates a wheel of colors by using rotation. The screenshot is reduced to save space.
221221

222-
<FixedImage side width={87} height={86}>
222+
<FixedImage side width={200} height={200}>
223223

224224
![multiply rotated rectangle in different colors](./wheel.png)
225225

@@ -250,7 +250,7 @@ void draw(){
250250

251251
The final coordinate system transformation is scaling, which changes the size of the grid. Take a look at this example, which draws a square, then scales the grid to twice its normal size, and draws it again.
252252

253-
<FixedImage side width={145} height={145}>
253+
<FixedImage side width={200} height={200}>
254254

255255
![gray square scaled up to double size](./scale1.png)
256256

@@ -284,7 +284,7 @@ There is no law saying that you have to scale the _x_ and _y_ dimensions equally
284284

285285
When you do multiple transformations, the order makes a difference. A rotation followed by a translate followed by a scale will not give the same results as a translate followed by a rotate by a scale. Here is some sample code and the results.
286286

287-
<FixedImage side width={144} height={168}>
287+
<FixedImage side width={200} height={200}>
288288

289289
![result of different orders of rotate/translate/scale](./order.png)
290290

@@ -344,7 +344,7 @@ The robot is modeled on [this drawing](http://www.openclipart.org/detail/5457),
344344

345345
When we refer to left and right in this drawing, we mean your left and right (the left and right side of your monitor), not the robot's left and right.
346346

347-
<FixedImage side width={84} height={136}>
347+
<FixedImage side width={200} height={200}>
348348

349349
![blue robot, arms at sides](./whole_robot.png)
350350

@@ -379,9 +379,9 @@ void drawRobot()
379379
380380
```
381381

382-
<FixedImage center width={82} height={52}>
382+
<FixedImage center width={650} height={250}>
383383

384-
![robot with red dots at shoulder joints](./pivot.png)
384+
![robot with red dots at shoulder joints](./pivot.svg)
385385

386386
</FixedImage>
387387

@@ -426,7 +426,7 @@ void drawRightArm()
426426

427427
Now test to see if the arms rotate properly. Rather than attempt a full animation, we will just rotate the left side arm 135 degrees and the right side arm -45 degrees as a test. Here is the code that needs to be added, and the result. The left side arm is cut off because of the window boundaries, but we'll fix that in the final animation.
428428

429-
<FixedImage side width={109} height={72}>
429+
<FixedImage side width={200} height={200}>
430430

431431
![robot with arms at angle](./rotate_test.png)
432432

Binary file not shown.

0 commit comments

Comments
 (0)