|
| 1 | +--- |
| 2 | +# This is the frontmatter |
| 3 | +title: "Lost and Found" # Title and Heading 1 |
| 4 | +permalink: /lostAndFound-lessons/3 # Give your page a permalink |
| 5 | +published: true |
| 6 | + |
| 7 | +gallery: # Below is for including an image gallery |
| 8 | + - url: /assets/images/curriculum/Unit-1_Sample-2.gif |
| 9 | + image_path: /assets/images/curriculum/Unit-1_Sample-2.gif |
| 10 | + alt: "black circle following a mouse" |
| 11 | + title: "Digital Drawing Tool Step 1" |
| 12 | + - url: /assets/images/curriculum/Unit-1_Sample-3.gif |
| 13 | + image_path: /assets/images/curriculum/Unit-1_Sample-3.gif |
| 14 | + alt: "cursor drawing a black line made up of a series of translucent circles" |
| 15 | + title: "Digital Drawing Tool Step 2" |
| 16 | + - url: /assets/images/curriculum/Unit-1_Sample-4.gif |
| 17 | + image_path: /assets/images/curriculum/Unit-1_Sample-4.gif |
| 18 | + alt: "cursor drawing multiple black arches made up of translucent circles" |
| 19 | + title: "Digital Drawing Tool Step 3" |
| 20 | + - url: /assets/images/curriculum/Unit-1_Sample-5.gif |
| 21 | + image_path: /assets/images/curriculum/Unit-1_Sample-5.gif |
| 22 | + alt: "cursor creating a drawing of vertical blue lines and stamping red ellipses" |
| 23 | + title: "Digital Drawing Tool Step 4" |
| 24 | +--- |
| 25 | + |
| 26 | +## Composition |
| 27 | + |
| 28 | +### Grade 6~8 |
| 29 | + |
| 30 | +#### A. Symmetry and Asymmetry |
| 31 | + |
| 32 | +  |
| 33 | + |
| 34 | +In composition, symmetry and asymmetry are equally valuable techniques to achieve visual rhythm and harmony. |
| 35 | + |
| 36 | +In the following tutorial, we will use the [lollipop](https://editor.p5js.org/xinemata/sketches/reojWdPOp) sketch as the starting point to draw a wild flower on the sidewalk. The wild flower is going to contain both symmetrical and asymmetrical visual elements. |
| 37 | + |
| 38 | +  |
| 39 | + |
| 40 | + First, let's turn the lollipop stick into a stem just by adjusting the [fill()](https://p5js.org/reference/p5/fill/) and the [rect()](https://p5js.org/reference/p5/rect/): |
| 41 | + |
| 42 | + ```js |
| 43 | + //Stem |
| 44 | + fill(22, 102, 36); |
| 45 | + rect(200, 300, 6, 150); |
| 46 | + ``` |
| 47 | +Then, let's turn the lollipop candy into a pistil by adding another [ellipse()](https://p5js.org/reference/p5/ellipse/): |
| 48 | + |
| 49 | + ```js |
| 50 | + //Pistil |
| 51 | + fill(189, 123, 30); |
| 52 | + ellipse(200, 200, 50, 50); |
| 53 | + |
| 54 | + fill(43, 26, 1); |
| 55 | + ellipse(200, 200, 35, 35); |
| 56 | +``` |
| 57 | +We'll also add a sidewalk for the flower to sit on: |
| 58 | + |
| 59 | +```js |
| 60 | + //Ground |
| 61 | + fill(120, 130, 127); |
| 62 | + rect(200, 365, 400, 75); |
| 63 | +``` |
| 64 | + |
| 65 | +  |
| 66 | + |
| 67 | + Let's add two petals to the flower. The petals will stand behind the left and right side of the pistil: |
| 68 | + |
| 69 | + ```js |
| 70 | + //Petals |
| 71 | + fill(230, 196, 28); |
| 72 | + ellipse(200 + 30, 200, 50, 40); // offset petal 30 pixel to the right |
| 73 | + ellipse(200 - 30, 200, 50, 40); // offset petal 30 pixel to the left |
| 74 | +``` |
| 75 | + |
| 76 | +Using arithmetic operators such as addition (+) and subtraction (-) allow us to offset one petal 30 pixel to the left, and the other petal 30 pixel to the right, making it easier to create symmetrical drawings. |
| 77 | + |
| 78 | +  |
| 79 | + |
| 80 | +To add two more petals to the flower, one on the top and one on the bottom of the pistil, we will have to manipulate the Y positions of the ellipses: |
| 81 | + |
| 82 | +```js |
| 83 | + //Petals |
| 84 | + fill(230, 196, 28); |
| 85 | + ellipse(200 + 30, 200, 50, 40); // offset petal 30 pixel to the right |
| 86 | + ellipse(200 - 30, 200, 50, 40); // offset petal 30 pixel to the left |
| 87 | + ellipse(200, 200 + 30, 40, 50); // offset petal 30 pixel to the bottom |
| 88 | + ellipse(200, 200 - 30, 40, 50); // offset petal 30 pixel to the top |
| 89 | +``` |
| 90 | + |
| 91 | +  |
| 92 | + |
| 93 | + Voila! Now we have a symmetrical flower with petals perfectly offset from the center of the pistil. |
| 94 | + |
| 95 | + Let's complete this image by adding leaves: |
| 96 | + |
| 97 | + ```js |
| 98 | + //Stem and leaves |
| 99 | + fill(22, 102, 36); |
| 100 | + rect(200, 300, 6, 150); |
| 101 | + |
| 102 | + ellipse(200 + 25, 200 + 70, 50, 20); // offset leaf 25 pixel to the right, and 70 pixel to the bottom |
| 103 | + ellipse(200 - 25, 200 + 90, 50, 20); // offset leaf 25 pixel to the left, and 90 pixel to the bottom |
| 104 | +``` |
| 105 | + |
| 106 | +While the leaves are symmetrical on the X-axis, they are asymmetrical on the Y-axis, creating a cascading effect. |
| 107 | + |
| 108 | +**Code Snippet:** [flower example](https://editor.p5js.org/xinemata/sketches/kBGJj4XJH). |
| 109 | +{: .notice--info} |
| 110 | + |
| 111 | +### Grade 9~12 |
| 112 | + |
| 113 | +<iframe width="560" height="315" src="https://www.youtube.com/embed/maTfm84mLbo?si=Orx71C5hl7owLq78" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipbo a ard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> |
| 114 | + |
| 115 | +#### B. Translate |
| 116 | + |
| 117 | +As your p5.js journey unfold, you might find yourself wanting to move or resize a group of shapes all at the same time. This is achievable through features listed under the [Transform](https://p5js.org/reference/#transform) category. |
| 118 | + |
| 119 | +To begin, let's draw a cloud using the [translate()](https://p5js.org/reference/p5/translate/) feature. |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | +By default, the p5.js canvas origin (0, 0) is at the sketch's top-left corner. [translate()](https://p5js.org/reference/p5/translate/) shifts the canvas origin to a different position. |
| 124 | + |
| 125 | +```js |
| 126 | +function setup() { |
| 127 | + createCanvas(400, 400); |
| 128 | + rectMode(CENTER); |
| 129 | + noStroke(); |
| 130 | +} |
| 131 | + |
| 132 | +function draw() { |
| 133 | + background(122, 122, 190); |
| 134 | + fill(255); |
| 135 | + |
| 136 | + // Shifts canvas origin to the center of the canvas |
| 137 | + translate(400 / 2, 400 / 2); // x, y |
| 138 | + |
| 139 | + // The rectangle refers to the new canvas origin to determine X, Y positions |
| 140 | + rect(0, 0, 100, 50); |
| 141 | +} |
| 142 | + |
| 143 | +``` |
| 144 | +  |
| 145 | + |
| 146 | + Now we'll add a bunch of ellipses after the rectangle to create the cloud shape: |
| 147 | + |
| 148 | + ```js |
| 149 | + ellipse(-80, 0, 70, 70); // offset ellipse 80 pixel to the left |
| 150 | + ellipse(80, 0, 70, 70); // offset ellipse 80 pixel to the right |
| 151 | + ``` |
| 152 | +  |
| 153 | + |
| 154 | + ```js |
| 155 | + ellipse(-40, -40, 70, 70); // offset ellipse 40 pixel to the left, and 40 pixel to the top |
| 156 | + ellipse(40, 40, 70, 70); // offset ellipse 40 pixel to the right, and 40 pixel to the bottom |
| 157 | + ellipse(-40, 40, 70, 70); // offset ellipse 40 pixel to the left, and 40 pixel to the bottom |
| 158 | + ellipse(40, -40, 70, 70); // offset ellipse 40 pixel to the right, and 40 pixel to the top |
| 159 | + ``` |
| 160 | + |
| 161 | +  |
| 162 | + |
| 163 | + ```js |
| 164 | + ellipse(0, -50, 70, 70); // offset ellipse 50 pixel to the top |
| 165 | + ellipse(0, 50, 70, 70); // offset ellipse 50 pixel to the bottom |
| 166 | + ``` |
| 167 | + |
| 168 | +  |
| 169 | + |
| 170 | + Great work! Before moving on to draw another shape, make sure that you finish grouping your cloud drawing by sandwitching the code we've written so far in between [push()](https://p5js.org/reference/p5/push/) and [pop()](https://p5js.org/reference/p5/pop/). Doing this will make sure that any new shapes you draw won't get affected by the cloud's custom [translate()](https://p5js.org/reference/p5/translate/) values. |
| 171 | + |
| 172 | +**Code Snippet:** [cloud example](https://editor.p5js.org/xinemata/sketches/deDhLjr2Q). |
| 173 | +{: .notice--info} |
0 commit comments