Skip to content

Commit 49ecb18

Browse files
added rendering tutorial with mdx
1 parent 8cbf2e3 commit 49ecb18

32 files changed

+504
-3
lines changed

content/tutorials/text/arrays/index.mdx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ void draw() {
252252

253253
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.
254254

255+
<Column float={"left"}>
256+
255257
<FixedImage left width={200}>
256258

257259
![light grey square with a black line that graphs the y position of the mouse as up and down, over time running left to right](./28_15_1.png)
@@ -270,6 +272,8 @@ As one example of how arrays may be used, this section shows how to use arrays t
270272

271273
</FixedImage>
272274

275+
</Column>
276+
273277
```
274278
int[] y;
275279
@@ -295,24 +299,28 @@ void draw() {
295299

296300
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.
297301

298-
<FixedImage left width={200}>
302+
<Column float={"left"}>
303+
304+
<FixedImage width={200}>
299305

300306
![black square with white semi-transparent circles creating a trail from the x and y position of the mouse. the older circles are larger and more faded](./28_16_1.png)
301307

302308
</FixedImage>
303309

304-
<FixedImage left width={200}>
310+
<FixedImage width={200}>
305311

306312
![same as the previous image but with different x and y mouse position data](./28_16_2.png)
307313

308314
</FixedImage>
309315

310-
<FixedImage left width={200}>
316+
<FixedImage width={200}>
311317

312318
![same as the previous image but with different x and y mouse position data](./28_16_3.png)
313319

314320
</FixedImage>
315321

322+
</Column>
323+
316324
```
317325
int num = 50;
318326
int[] x = new int[num];
4.05 KB
Loading
4.05 KB
Loading
4.06 KB
Loading
3.73 KB
Loading
3.99 KB
Loading
4.34 KB
Loading
4.5 KB
Loading
5.52 KB
Loading
6.3 KB
Loading

0 commit comments

Comments
 (0)