|
1 | | -# Module 11: Creating Advanced Graphics. |
| 1 | +# Module 11: Creating Advanced Graphics |
2 | 2 |
|
3 | | -# Lab: Creating Advanced Graphics. |
| 3 | +# Lab: Creating Advanced Graphics |
4 | 4 |
|
5 | 5 | ### Lab Setup |
6 | 6 |
|
7 | 7 | ### Preparation Steps |
8 | 8 |
|
9 | | -1. Ensure that you have cloned the 20480C directory from GitHub. It contains the code segments for this course's labs and demos. https://github.com/MicrosoftLearning/20480-Programming-in-HTML5-with-JavaScript-and-CSS3/tree/master/Allfiles. |
| 9 | +Ensure that you have cloned the 20480C directory from GitHub (**https://github.com/MicrosoftLearning/20480-Programming-in-HTML5-with-JavaScript-and-CSS3/tree/master/Allfiles**). It contains the code segments for the labs and demos in this course. |
10 | 10 |
|
11 | | -### Exercise 1: Creating an Interactive Venue Map by Using SVG. |
| 11 | +### Exercise 1: Creating an Interactive Venue Map by Using SVG |
12 | 12 |
|
13 | | -#### Task 1: Review the incomplete HTML markup for the venue map. |
| 13 | +#### Task 1: Review the incomplete HTML markup for the venue map |
14 | 14 |
|
15 | | -1. Open **Visual Studio 2017**. |
16 | | -2. In Visual Studio, on the **File** menu, point to **Open**, and then click **Project/Solution**. |
| 15 | +1. Open Microsoft Visual Studio 2017. |
| 16 | +2. In Visual Studio, on the **File** menu, point to **Open**, and then select **Project/Solution**. |
17 | 17 | 3. In the **Open Project** dialog box, browse to **Allfiles\Mod11\Labfiles\Starter\Exercise 1**, click **ContosoConf.sln**, and then click **Open**. |
18 | | -4. In Solution Explorer, expand the **ContosoConf** project node, and then double-click **location.htm**. |
| 18 | +4. In **Solution Explorer**, expand the **ContosoConf** project node, and then double-click **location.htm**. |
19 | 19 | 5. Verify that the page contains the following HTML markup: |
20 | 20 | ```html |
21 | 21 | <svg viewBox="-1 -1 302 102" width="100%" height="230"> |
|
35 | 35 | ```html |
36 | 36 | <script src="/scripts/pages/location-venue.js" type="text/javascript"></script> |
37 | 37 | ``` |
38 | | -7. On the **Debug** menu, click **Start Without Debugging**. |
| 38 | +7. On the **Debug** menu, click **Start Without Debugging**. |
39 | 39 | 8. Click **Location**. |
40 | | -9. If the message **localhost wants to track your location** appears, click **Allow once**. |
| 40 | +9. If the **localhost wants to track your location** message appears, click **Allow once**. |
41 | 41 | 10. In the **Enable Location Services** dialog box, click **Yes**. |
42 | | -11. If the message **Intranet settings are turned off by default** appears, click **Don’t show this message again**. |
| 42 | +11. If the **Intranet settings are turned off by default** message appears, click **Don’t show this message again**. |
43 | 43 | 12. Scroll down and view the venue map. |
44 | 44 |
|
45 | 45 |  |
46 | 46 |
|
47 | 47 | 13. Close Microsoft Edge. |
48 | 48 |
|
49 | | -#### Task 2: Complete the SVG venue map. |
| 49 | +#### Task 2: Complete the SVG venue map |
50 | 50 |
|
51 | 51 | 1. In Visual Studio, in **location.htm**, find the following comment: |
52 | 52 | ```html |
|
60 | 60 | </g> |
61 | 61 | ``` |
62 | 62 |
|
63 | | -#### Task 3: Add interactivity to the venue map. |
| 63 | +#### Task 3: Add interactivity to the venue map |
64 | 64 |
|
65 | | -1. In Solution Explorer, double-click **location.htm**. |
| 65 | +1. In **Solution Explorer**, double-click **location.htm**. |
66 | 66 | 2. Find the following HTML markup: |
67 | 67 | ```html |
68 | 68 | <div id="room-a-info" style="display: none"> |
|
86 | 86 | </ul> |
87 | 87 | </div> |
88 | 88 | ``` |
89 | | -3. In Solution Explorer, expand the **styles** folder, expand the **pages** folder, and then double-click **location.css**. |
| 89 | +3. In **Solution Explorer**, expand the **styles** folder, expand the **pages** folder, and then double-click **location.css**. |
90 | 90 | 4. At the end of the file, add the following CSS: |
91 | 91 | ```css |
92 | 92 | .room:hover rect { |
93 | 93 | fill: #b1f8b0; |
94 | 94 | } |
95 | 95 | ``` |
96 | | -5. In Solution Explorer, expand the **scripts** folder, expand the **pages** folder, and then double-click **location-venue.js**. |
| 96 | +5. In **Solution Explorer**, expand the **scripts** folder, expand the **pages** folder, and then double-click **location-venue.js**. |
97 | 97 | 6. Find the following comment: |
98 | 98 | ```javascript |
99 | 99 | // TODO: Get the room elements in the svg element. |
|
116 | 116 | } |
117 | 117 | ``` |
118 | 118 |
|
119 | | -#### Task 4: Test the application. |
| 119 | +#### Task 4: Test the application |
120 | 120 |
|
121 | | -1. In Solution Explorer, double-click **location.htm**. |
| 121 | +1. In **Solution Explorer**, double-click **location.htm**. |
122 | 122 | 2. On the **Debug** menu, click **Start Without Debugging**. |
123 | | -3. In Microsoft Edge, if the message **localhost wants to track your physical location** appears, click **Allow once**. |
124 | | -4. Scroll down to the venue map and hover the mouse over **Room A**. |
| 123 | +3. In Microsoft Edge, if the **localhost wants to track your physical location** message appears, click **Allow once**. |
| 124 | +4. Scroll down to the venue map and place the mouse pointer over **Room A**. |
125 | 125 | 5. Verify that the venue map looks similar to the following image: |
126 | 126 |
|
127 | 127 |  |
128 | 128 |
|
129 | | -6. Click **Room B**, verify that the room information is displayed, and that it is similar to the following image: |
| 129 | +6. Click **Room B**, verify that the room information is displayed and that it is similar to the following image: |
130 | 130 |
|
131 | 131 |  |
132 | 132 |
|
133 | 133 | 7. Close Microsoft Edge. |
134 | 134 |
|
135 | | ->**Results:** After completing this exercise, you will have a venue map that displays extra information when clicked. |
| 135 | +>**Results**: After completing this exercise, you will have a venue map that displays extra information when clicked. |
136 | 136 |
|
137 | | -### Exercise 2: Creating a Speaker Badge by Using the Canvas API. |
| 137 | +### Exercise 2: Creating a Speaker Badge by Using the Canvas API |
138 | 138 |
|
139 | | -#### Task 1: Create the canvas element. |
| 139 | +#### Task 1: Create the canvas element |
140 | 140 |
|
141 | | -1. In Visual Studio, on the **File** menu, point to **Open**, and then click **Project/Solution**. |
142 | | -2. In the **Open Project** dialog box, browse to **Allfiles\Mod11\Labfiles\Starter\Exercise 2** click **ContosoConf.sln**, and then click **Open**. |
143 | | -3. In Solution Explorer, expand the **ContosoConf** project, and then double-click **speaker-badge.htm**. |
| 141 | +1. In Visual Studio, on the **File** menu, point to **Open**, and then select **Project/Solution**. |
| 142 | +2. In the **Open Project** dialog box, browse to **Allfiles\Mod11\Labfiles\Starter\Exercise 2**, click **ContosoConf.sln**, and then click **Open**. |
| 143 | +3. In **Solution Explorer**, expand the **ContosoConf** project, and then double-click **speaker-badge.htm**. |
144 | 144 | 4. Find the following comment: |
145 | 145 | ```html |
146 | 146 | <!-- TODO: Add canvas here --> |
147 | 147 | ``` |
148 | 148 | 5. After this comment, add the following HTML markup: |
149 | | - ```html |
| 149 | + ``` |
| 150 | + html |
150 | 151 | <canvas |
151 | | - width="500" |
152 | | - height="200" |
| 152 | + width="500" |
| 153 | + height="200" |
153 | 154 | style="border: 1px solid "#888" |
154 | 155 | data-speaker-id="234724" |
155 | 156 | data-speaker-name="Mark Hanson"> |
156 | 157 | </canvas> |
157 | 158 | ``` |
158 | 159 |
|
159 | | -#### Task 2: Draw the details for the badge. |
| 160 | +#### Task 2: Draw the details for the badge |
160 | 161 |
|
161 | | -1. In Solution Explorer, expand the **scripts** folder, expand the **pages** folder, and then double-click **speaker-badge.js**. |
| 162 | +1. In **Solution Explorer**, expand the **scripts** folder, expand the **pages** folder, and then double-click **speaker-badge.js**. |
162 | 163 | 2. Verify that the file contains the following JavaScript code: |
163 | 164 | ```javascript |
164 | 165 | this.canvas = element.querySelector("canvas"); |
165 | 166 | ``` |
166 | | -3. Find the following comment: |
| 167 | +3. Find the following comment: |
167 | 168 | ```javascript |
168 | 169 | // TODO: Get the canvas's (this.canvas) context and assign to this.context |
169 | 170 | ``` |
170 | 171 | 4. After this comment, add the following JavaScript code: |
171 | 172 | ```javascript |
172 | 173 | this.context = this.canvas.getContext("2d"); |
173 | 174 | ``` |
174 | | -5. Find the comment that starts with the following line: |
| 175 | +5. Find the comment that starts with the following line: |
175 | 176 | ```javascript |
176 | 177 | // TODO: Draw the following by calling the helper methods of `this` |
177 | 178 | ``` |
|
187 | 188 | } |
188 | 189 | this.drawBarCode(this.speakerId); |
189 | 190 | ``` |
190 | | -7. Find the following comment: |
| 191 | +7. Find the following comment: |
191 | 192 | ```javascript |
192 | 193 | // TODO: Fill the canvas with a white rectangle |
193 | 194 | ``` |
|
196 | 197 | this.context.fillStyle = "white"; |
197 | 198 | this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); |
198 | 199 | ``` |
199 | | -9. Find the comment that starts with the following line: |
| 200 | +9. Find the comment that starts with the following line: |
200 | 201 | ```javascript |
201 | 202 | // TODO: Draw the image on the canvas |
202 | 203 | ``` |
203 | | -10. After the last line of this comment, add the following JavaScript code: |
| 204 | +10. After the last line of this comment, add the following JavaScript code: |
204 | 205 | ```javascript |
205 | 206 | var size = Math.min(image.width, image.height); |
206 | 207 | var sourceX = image.width / 2 - size / 2; |
207 | 208 | var sourceY = image.height / 2 - size / 2; |
208 | 209 | this.context.drawImage(image, sourceX, sourceY, size, size, 20, 20, 160, 160); |
209 | 210 | ``` |
210 | | -11. Find the comment that starts with the following line: |
| 211 | +11. Find the comment that starts with the following line: |
211 | 212 | ```javascript |
212 | 213 | // TODO: Draw this.speakerName on the canvas |
213 | 214 | ``` |
214 | | -12. After the last line of this comment, add the following JavaScript code: |
| 215 | +12. After the last line of this comment, add the following JavaScript code: |
215 | 216 | ```javascript |
216 | 217 | this.context.font = "40px sans-serif"; |
217 | 218 | this.context.fillStyle = "black"; |
|
220 | 221 | this.context.fillText(this.speakerName, 200, 60); |
221 | 222 | ``` |
222 | 223 |
|
223 | | -#### Task 3: Test the application. |
| 224 | +#### Task 3: Test the application |
224 | 225 |
|
225 | | -1. In Solution Explorer, double-click **speaker-badge.htm**. |
| 226 | +1. In **Solution Explorer**, double-click **speaker-badge.htm**. |
226 | 227 | 2. On the **Debug** menu, click **Start Without Debugging**. |
227 | | -3. On the taskbar, click **File Explorer** and then browse to the **Allfiles\Mod11\Labfiles\Resources** folder. |
228 | | -4. Drag and drop **mark-hanson.jpg** from File Explorer onto the speaker badge in Microsoft Edge. |
| 228 | +3. On the taskbar, click **File Explorer**, and then browse to the **Allfiles\Mod11\Labfiles\Resources** folder. |
| 229 | +4. From File Explorer, drag **mark-hanson.jpg** onto the speaker badge in Microsoft Edge. |
229 | 230 | 5. Verify that the speaker badge looks similar to the following image: |
230 | 231 |
|
231 | 232 |  |
232 | 233 |
|
233 | 234 | 6. Close Microsoft Edge. |
234 | 235 |
|
235 | | ->**Results:** After completing this exercise, you will have a Speaker Badge page that enables a conference speaker to create their badge. |
| 236 | +>**Results**: After completing this exercise, you will have a Speaker Badge page that enables a conference speaker to create their badge. |
236 | 237 |
|
237 | 238 | ©2018 Microsoft Corporation. All rights reserved. |
238 | 239 |
|
|
0 commit comments