@@ -95,47 +95,47 @@ The last function we'll want to create is one that will bring functionality to t
95
95
})
96
96
.catch(err => {
97
97
console.error(`OH NO!!!`, err);
98
- });
99
- }
98
+ })
99
+ };
100
100
```
101
101
102
102
2 . Declare a ` const ` variable ` paintToCanvas ` and define it as an arrow function.
103
103
104
104
``` JavaScript
105
- const paintToCanvas = () => { /* ... */ }
105
+ const paintToCanvas = () => { /* ... */ };
106
106
```
107
107
108
- - In the body of this function , declare two `const` variables and define them
109
- as the `video` element's width and height, and update the `canvas` width and height
110
- to reflect those values.
108
+ - In the body of this function , declare two `const` variables and define them
109
+ as the `video` element's width and height, and update the `canvas` width and height
110
+ to reflect those values.
111
111
112
- ```JavaScript
112
+ ```JavaScript
113
113
const paintToCanavas = () => {
114
114
const width = video .videoWidth ;
115
115
const height = video .videoHeight ;
116
116
canvas .width = width;
117
117
canvas .height = height;
118
118
119
- /* More to do... */
120
- }
121
- ```
122
-
123
- - Still in the body of the function , return the _interval ID_ of a `setInterval ()`
124
- function call, and within the body of that function call, draw the current `video`
125
- element on to the `canvas.
126
-
127
- ```JavaScript
128
- let paintToCanavas = () => {
129
- const width = video .videoWidth ;
130
- const height = video .videoHeight ;
131
- canvas .width = width;
132
- canvas .height = height;
133
-
134
- return setInterval (() => {
135
- ctx .drawImage (video, 0 , 0 , width, height);
136
- }, 16 );
137
- }
138
- ```
119
+ /* More to do... */
120
+ };
121
+ ```
122
+
123
+ - Still in the body of the function , return the _interval ID_ of a `setInterval ()`
124
+ function call, and within the body of that function call, draw the current `video`
125
+ element on to the `canvas.`
126
+
127
+ ```JavaScript
128
+ let paintToCanavas = () => {
129
+ const width = video .videoWidth ;
130
+ const height = video .videoHeight ;
131
+ canvas .width = width;
132
+ canvas .height = height;
133
+
134
+ return setInterval (() => {
135
+ ctx .drawImage (video, 0 , 0 , width, height);
136
+ }, 16 );
137
+ };
138
+ ```
139
139
140
140
3. Declare a ` const` variable ` takePhoto` and define it as an arrow function that will
141
141
play the `audio` element on the HTML page, create a link which targets a _data URI_
@@ -154,36 +154,36 @@ The last function we'll want to create is one that will bring functionality to t
154
154
link .setAttribute (' download' , ' handsome' );
155
155
link .innerHTML = ` <img src =" ${data}" alt =" Handsome Man" />` ;
156
156
strip .insertBefore (link, strip .firsChild );
157
- }
157
+ };
158
158
```
159
159
160
160
4. Declare a ` const` variable ` greenScreen` and define it as an _arrow function_ that will
161
161
accept an argument ` pixels` .
162
162
163
163
` ` ` JavaScript
164
- const greenScreen = (pixels) => { /*...*/ }
164
+ const greenScreen = (pixels) => { /*...*/ };
165
165
` ` `
166
166
167
- - In the function body, declare a `const` variables `levels` and define it as an empty
168
- object. Iterate through a _NodeList_ of all `input` elements within the div with class
169
- `rgb` and set a key in the `levels` object as a given input's `name` property, and
170
- set the value to be the given input's `value`.
167
+ - In the function body, declare a `const` variables `levels` and define it as an empty
168
+ object. Iterate through a _NodeList_ of all `input` elements within the div with class
169
+ `rgb` and set a key in the `levels` object as a given input's `name` property, and
170
+ set the value to be the given input's `value`.
171
171
172
- ```JavaScript
172
+ ```JavaScript
173
173
/* In function body */
174
174
175
175
const levels = {};
176
176
177
177
document.querySelectorAll (' .rgb input' ).forEach((input) => {
178
178
levels[input .name ] = input .value ;
179
179
});
180
- ```
180
+ ```
181
181
182
- - Update the values of the pixels in the image so that we remove all RGB
183
- values that are within the range defined by the user, and return the given
184
- argument.
182
+ - Update the values of the pixels in the image so that we remove all RGB
183
+ values that are within the range defined by the user, and return the given
184
+ argument.
185
185
186
- ` ` ` JavaScript
186
+ ` ` ` JavaScript
187
187
/* In function body */
188
188
for (i = 0; i < pixels.data.length; i += 4) {
189
189
red = pixels.data[i + 0];
@@ -201,8 +201,8 @@ The last function we'll want to create is one that will bring functionality to t
201
201
pixels.data[i + 3] = 0;
202
202
}
203
203
}
204
- return pixels
205
- ` ` `
204
+ return pixels;
205
+ ` ` `
206
206
207
207
5. Update the ` getVideo` function so that the setInterval method within the function body
208
208
creates a variable defined as the _underlying pixel data_, passes that variable into the
0 commit comments