Skip to content

Commit a8412e9

Browse files
author
philiptr
committed
Rendering tutorial layout
1 parent 18b9e0d commit a8412e9

File tree

1 file changed

+37
-57
lines changed

1 file changed

+37
-57
lines changed

content/static/tutorials/rendering/index.html

Lines changed: 37 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,15 @@ <h3>Another drawing surface</h3>
7777
<p>
7878
Based on this example, the most obvious differences to working with PGraphics objects are the additional lines of code and the extra step of prepending each drawing function with the name of the object. This example is simplified to demonstrate the mechanics of the technique, but it doesn’t do anything to justify it. The following example reveals a typical issue that creating a new drawing surface can fix. The goal of the program is to use a crosshair to show the position of the cursor and to draw a new circle to the screen each time the mouse is clicked. For the circles to accumulate on screen, the background() function isn’t used. This has the unintended effect of also accumulating the crosshairs as seen in this code:
7979
</p>
80-
<img src="imgs/35_04_1.png" style= "width: 100px; height: 100px; float: left;">
80+
<div style = "float: left;">
81+
<img src="imgs/35_04_1.png" style= "width: 100px; height: 100px;">
8182
<br />
8283
<br />
84+
<img src="imgs/35_04_2.png" style= "width: 100px; height: 100px;">
8385
<br />
8486
<br />
85-
<img src="imgs/35_04_2.png" style= "width: 100px; height: 100px; float: left;">
86-
<br />
87-
<br />
88-
<br />
89-
<br />
90-
<img src="imgs/35_04_3.png" style= "width: 100px; height: 100px; float: left;">
87+
<img src="imgs/35_04_3.png" style= "width: 100px; height: 100px;">
88+
</div>
9189
<pre>
9290
void setup() {
9391
size(100, 100);
@@ -109,22 +107,18 @@ <h3>Another drawing surface</h3>
109107
<p>
110108
To allow for the circles to accumulate in the display window, but to have a different effect for the crosshairs, a new drawing surface is created to render the circles, while the crosshairs are drawn in the main display window. The surface with the circles is redrawn each frame in draw(), followed by the lines so they are on top of the circles layer.
111109
</p>
112-
<img src="imgs/35_05_1.png" style= "width: 100px; height: 100px; float: left;">
113-
<br />
114-
<br />
115-
<br />
116-
<br />
117-
<img src="imgs/35_05_2.png" style= "width: 100px; height: 100px; float: left;">
118-
<br />
110+
<div style = "float: left;">
111+
<img src="imgs/35_05_1.png" style= "width: 100px; height: 100px;">
119112
<br />
113+
<br />
114+
<img src="imgs/35_05_2.png" style= "width: 100px; height: 100px;">
120115
<br />
116+
<br />
117+
<img src="imgs/35_05_3.png" style= "width: 100px; height: 100px;">
121118
<br />
122-
<img src="imgs/35_05_3.png" style= "width: 100px; height: 100px; float: left;">
123119
<br />
124-
<br />
125-
<br />
126-
<br />
127-
<img src="imgs/35_05_4.png" style= "width: 100px; height: 100px; float: left;">
120+
<img src="imgs/35_05_4.png" style= "width: 100px; height: 100px;">
121+
</div>
128122
<pre>
129123
PGraphics circles;
130124

@@ -203,22 +197,18 @@ <h3>Another drawing surface</h3>
203197
<h3>OpenGL surfaces</h3>
204198
Just as the the size() function defines the main renderer for a program, each createGraphics() function defines the renderer for the PGraphics object with a third, optional parameter. When the third parameter isn’t used, as in the examples seen already in this chapter, the default renderer is set. The P2D and P3D renderers are the other options. For instance, to create a new drawing surface for 3D shapes, use P3D as the third parameter to size() and createGraphics():
205199
</p>
206-
<img src="imgs/35_07_1.png" style= "width: 100px; height: 100px; float: left;">
207-
<br />
208-
<br />
200+
<div style = "float: left;">
201+
<img src="imgs/35_07_1.png" style= "width: 100px; height: 100px;">
209202
<br />
210203
<br />
211-
<img src="imgs/35_07_2.png" style= "width: 100px; height: 100px; float: left;">
204+
<img src="imgs/35_07_2.png" style= "width: 100px; height: 100px;">
212205
<br />
213206
<br />
214-
<br />
215-
<br />
216-
<img src="imgs/35_07_3.png" style= "width: 100px; height: 100px; float: left;">
207+
<img src="imgs/35_07_3.png" style= "width: 100px; height: 100px;">
217208
<br />
218209
<br />
219-
<br />
220-
<br />
221-
<img src="imgs/35_07_4.png" style= "width: 100px; height: 100px; float: left;">
210+
<img src="imgs/35_07_4.png" style= "width: 100px; height: 100px;">
211+
</div>
222212
<pre>
223213
PGraphics cube;
224214

@@ -266,17 +256,15 @@ <h3>OpenGL surfaces</h3>
266256
<h3>Combine surfaces</h3>
267257
The final section in this chapter demonstrates techniques for combining more than one drawing surface together within the display window. This builds on the code earlier in the chapter, but extends it further. The next example builds on code 35-07 with two changes. First, another drawing surface was added and second, the background() was removed from each layer and replaced with clear(). The clear() method is similar to defining the background because it erases everything in the drawing surface, but it makes each pixel transparent instead of filling each with a color. Here, clear() is used to make it easier to combine the two drawing surfaces together because the shapes drawn into each buffer are surrounded by transparent pixels. Transparent backgrounds aren’t possible for the display window, the default PGraphics object. They are one of the primary advantages of creating a new drawing surface.
268258
</p>
269-
<img src="imgs/35_09_1.png" style= "width: 100px; height: 100px; float: left;">
259+
<div style = "float: left;">
260+
<img src="imgs/35_09_1.png" style= "width: 100px; height: 100px;">
270261
<br />
271262
<br />
263+
<img src="imgs/35_09_2.png" style= "width: 100px; height: 100px;">
272264
<br />
273-
<br />
274-
<img src="imgs/35_09_2.png" style= "width: 100px; height: 100px; float: left;">
275-
<br />
276-
<br />
277-
<br />
278-
<br />
279-
<img src="imgs/35_09_3.png" style= "width: 100px; height: 100px; float: left;">
265+
<br />
266+
<img src="imgs/35_09_3.png" style= "width: 100px; height: 100px;">
267+
</div>
280268
<pre>
281269
PGraphics cubeA;
282270
PGraphics cubeB;
@@ -326,22 +314,18 @@ <h3>Combine surfaces</h3>
326314
<p>
327315
Move the cursor around in the display window to modify the transparency of each layer. The visibility of each other is set by the tint() that precedes the image() function. A quick look at the drawCubeA() and drawCubeB() functions reveal there might be a better way to write the program. Both functions are nearly identical with three differences: the name of the surface to draw to, the rotation amount for the x-axis, the rotation amount for the y-axis. These values can be passed into a function as parameters so a single function can be used in place of two. The unknown syntax is how to pass in a PGraphics object as a parameter to a function. Fortunately, it follows the same pattern as all parameters, the name of the data type is followed by a variable name. The updated program follows.
328316
</p>
329-
<img src="imgs/35_10_1.png" style= "width: 100px; height: 100px; float: left;">
317+
<div style = "float: left;">
318+
<img src="imgs/35_10_1.png" style= "width: 100px; height: 100px;">
330319
<br />
331320
<br />
321+
<img src="imgs/35_10_2.png" style= "width: 100px; height: 100px;">
332322
<br />
333323
<br />
334-
<img src="imgs/35_10_2.png" style= "width: 100px; height: 100px; float: left;">
335-
<br />
336-
<br />
337-
<br />
338-
<br />
339-
<img src="imgs/35_10_3.png" style= "width: 100px; height: 100px; float: left;">
324+
<img src="imgs/35_10_3.png" style= "width: 100px; height: 100px;">
340325
<br />
341326
<br />
342-
<br />
343-
<br />
344-
<img src="imgs/35_10_4.png" style= "width: 100px; height: 100px; float: left;">
327+
<img src="imgs/35_10_4.png" style= "width: 100px; height: 100px;">
328+
</div>
345329
<pre>
346330
PGraphics cubeA;
347331
PGraphics cubeB;
@@ -382,22 +366,18 @@ <h3>Combine surfaces</h3>
382366
<br />
383367
The next example is similar to the previous example, but it blends the two drawing surfaces together with the blendMode() function. The blend mode is defined at the end of setup() and is then applied for the duration of the program.
384368
</p>
385-
<img src="imgs/35_11_1.png" style= "width: 100px; height: 100px; float: left;">
386-
<br />
387-
<br />
369+
<div style="float: left;">
370+
<img src="imgs/35_11_1.png" style= "width: 100px; height: 100px;">
388371
<br />
389372
<br />
390-
<img src="imgs/35_11_2.png" style= "width: 100px; height: 100px; float: left;">
373+
<img src="imgs/35_11_2.png" style= "width: 100px; height: 100px;">
391374
<br />
392375
<br />
393-
<br />
394-
<br />
395-
<img src="imgs/35_11_3.png" style= "width: 100px; height: 100px; float: left;">
376+
<img src="imgs/35_11_3.png" style= "width: 100px; height: 100px;">
396377
<br />
397378
<br />
398-
<br />
399-
<br />
400-
<img src="imgs/35_11_4.png" style= "width: 100px; height: 100px; float: left;">
379+
<img src="imgs/35_11_4.png" style= "width: 100px; height: 100px;">
380+
</div>
401381
<pre>
402382
PGraphics cubeA;
403383
PGraphics cubeB;

0 commit comments

Comments
 (0)