From a8b0e430c8e3c11fd8f54696451bfb911c6518b8 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Tue, 13 Dec 2016 15:52:58 -0600 Subject: [PATCH 01/16] completes drum kit --- 01 - JavaScript Drum Kit/index-FINISHED.html | 83 -------------------- 01 - JavaScript Drum Kit/index-START.html | 66 ---------------- 01 - JavaScript Drum Kit/index.html | 30 +++---- 3 files changed, 16 insertions(+), 163 deletions(-) delete mode 100644 01 - JavaScript Drum Kit/index-FINISHED.html delete mode 100644 01 - JavaScript Drum Kit/index-START.html diff --git a/01 - JavaScript Drum Kit/index-FINISHED.html b/01 - JavaScript Drum Kit/index-FINISHED.html deleted file mode 100644 index 1a16d0997c..0000000000 --- a/01 - JavaScript Drum Kit/index-FINISHED.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - JS Drum Kit - - - - - -
-
- A - clap -
-
- S - hihat -
-
- D - kick -
-
- F - openhat -
-
- G - boom -
-
- H - ride -
-
- J - snare -
-
- K - tom -
-
- L - tink -
-
- - - - - - - - - - - - - - - - diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html deleted file mode 100644 index 4070d32767..0000000000 --- a/01 - JavaScript Drum Kit/index-START.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - JS Drum Kit - - - - - -
-
- A - clap -
-
- S - hihat -
-
- D - kick -
-
- F - openhat -
-
- G - boom -
-
- H - ride -
-
- J - snare -
-
- K - tom -
-
- L - tink -
-
- - - - - - - - - - - - - - - - diff --git a/01 - JavaScript Drum Kit/index.html b/01 - JavaScript Drum Kit/index.html index 246639f990..da4b94849e 100644 --- a/01 - JavaScript Drum Kit/index.html +++ b/01 - JavaScript Drum Kit/index.html @@ -58,26 +58,28 @@ + From e093e36ae055545ac0fb98e9747bd11507042ee5 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Tue, 13 Dec 2016 16:14:08 -0600 Subject: [PATCH 02/16] completes clock --- 02 - JS + CSS Clock/index-FINISHED.html | 98 ------------------------- 02 - JS + CSS Clock/index-START.html | 73 ------------------ 02 - JS + CSS Clock/index.html | 39 +++++----- 3 files changed, 20 insertions(+), 190 deletions(-) delete mode 100644 02 - JS + CSS Clock/index-FINISHED.html delete mode 100644 02 - JS + CSS Clock/index-START.html diff --git a/02 - JS + CSS Clock/index-FINISHED.html b/02 - JS + CSS Clock/index-FINISHED.html deleted file mode 100644 index d4cb3b56a8..0000000000 --- a/02 - JS + CSS Clock/index-FINISHED.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - JS + CSS Clock - - - - -
-
-
-
-
-
-
- - - - - - - diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html deleted file mode 100644 index 2712384201..0000000000 --- a/02 - JS + CSS Clock/index-START.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - JS + CSS Clock - - - - -
-
-
-
-
-
-
- - - - - - - diff --git a/02 - JS + CSS Clock/index.html b/02 - JS + CSS Clock/index.html index 1c777557da..57b646f43e 100644 --- a/02 - JS + CSS Clock/index.html +++ b/02 - JS + CSS Clock/index.html @@ -64,33 +64,34 @@ transform-origin: 100%; transform: rotate(90deg); transition: all 0.05s; - transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1); + transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1); } - - + From f0f52cd11e72f2b909e4fd125eefd1108e6800f1 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Tue, 13 Dec 2016 16:53:10 -0600 Subject: [PATCH 03/16] completes CSS vars --- 03 - CSS Variables/index-START.html | 54 ------------------- .../{index-FINISHED.html => index.html} | 15 +++--- 2 files changed, 7 insertions(+), 62 deletions(-) delete mode 100644 03 - CSS Variables/index-START.html rename 03 - CSS Variables/{index-FINISHED.html => index.html} (87%) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html deleted file mode 100644 index 7171607a8b..0000000000 --- a/03 - CSS Variables/index-START.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - Scoped CSS Variables and JS - - -

Update CSS Variables with JS

- -
- - - - - - - - -
- - - - - - - - - diff --git a/03 - CSS Variables/index-FINISHED.html b/03 - CSS Variables/index.html similarity index 87% rename from 03 - CSS Variables/index-FINISHED.html rename to 03 - CSS Variables/index.html index c3217fc003..a758d2f377 100644 --- a/03 - CSS Variables/index-FINISHED.html +++ b/03 - CSS Variables/index.html @@ -33,7 +33,7 @@

Update CSS Variables with JS

filter: blur(var(--blur)); } - .hl { + .h1{ color: var(--base); } @@ -63,17 +63,16 @@

Update CSS Variables with JS

- From b6a58344f01aa49b4a00a5e3ba1a5ee15acfe6e5 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Wed, 14 Dec 2016 11:33:58 -0600 Subject: [PATCH 04/16] completes array meths --- 04 - Array Cardio Day 1/index-FINISHED.html | 106 ------------------ .../{index-START.html => index.html} | 19 +++- 2 files changed, 18 insertions(+), 107 deletions(-) delete mode 100644 04 - Array Cardio Day 1/index-FINISHED.html rename 04 - Array Cardio Day 1/{index-START.html => index.html} (78%) diff --git a/04 - Array Cardio Day 1/index-FINISHED.html b/04 - Array Cardio Day 1/index-FINISHED.html deleted file mode 100644 index e61b94c006..0000000000 --- a/04 - Array Cardio Day 1/index-FINISHED.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Array Cardio 💪 - - -

Psst: have a look at the JavaScript Console 💁

- - - diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index.html similarity index 78% rename from 04 - Array Cardio Day 1/index-START.html rename to 04 - Array Cardio Day 1/index.html index 4162bce339..27dc3e1d32 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index.html @@ -33,28 +33,45 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const oldInventors = inventors.filter(inventor => /^15[0-9]{2}$/.test(inventor.year)) // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + const fullNames = inventors.map(inventor => `${inventor.first} ${inventor.last}`) // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + const sorted = inventors.sort((a, b) => a.year > b.year ? 1 : -1) // Array.prototype.reduce() // 4. How many years did all the inventors live? + const totalYears = inventors.reduce((acc, curr) => acc += curr.passed - curr.year, 0) // 5. Sort the inventors by years lived + const yrsLived = inventors.sort((a, b) => (a.passed - a.year) > (b.passed - b.year) ? 1 : -1) // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris - + const links = [...document.querySelectorAll('.mw-category a')] || [] + const titles = links.map(l => l.title) + const de = titles.filter(t => t.includes('de')) // 7. sort Exercise // Sort the people alphabetically by last name + const alpha = people.sort((a, b) => { + const aLast = a.split(",")[0] + const bLast = b.split(", ")[0] + return aLast > bLast ? 1 : -1 + }) // 8. Reduce Exercise // Sum up the instances of each of these const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; + const inst = data.reduce(function(acc, curr){ + if (!acc[curr]) acc[curr] = 0 + acc[curr]++ + return acc + }, {}) From d7a90b73b35eb6b649ba4c4ce070bce819a05ab1 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Wed, 14 Dec 2016 11:59:28 -0600 Subject: [PATCH 05/16] completes flex gallery --- 05 - Flex Panel Gallery/index-START.html | 116 ------------------ .../{index-FINISHED.html => index.html} | 46 ++++--- 2 files changed, 28 insertions(+), 134 deletions(-) delete mode 100644 05 - Flex Panel Gallery/index-START.html rename 05 - Flex Panel Gallery/{index-FINISHED.html => index.html} (84%) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html deleted file mode 100644 index e1d643ad5c..0000000000 --- a/05 - Flex Panel Gallery/index-START.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - Flex Panels 💪 - - - - - - -
-
-

Hey

-

Let's

-

Dance

-
-
-

Give

-

Take

-

Receive

-
-
-

Experience

-

It

-

Today

-
-
-

Give

-

All

-

You can

-
-
-

Life

-

In

-

Motion

-
-
- - - - - - - diff --git a/05 - Flex Panel Gallery/index-FINISHED.html b/05 - Flex Panel Gallery/index.html similarity index 84% rename from 05 - Flex Panel Gallery/index-FINISHED.html rename to 05 - Flex Panel Gallery/index.html index 243f8a221d..b4d15a9863 100644 --- a/05 - Flex Panel Gallery/index-FINISHED.html +++ b/05 - Flex Panel Gallery/index.html @@ -33,6 +33,7 @@ color:white; text-align: center; align-items:center; + flex: 1; /* Safari transitionend event.propertyName === flex */ /* Chrome + FF transitionend event.propertyName === flex-grow */ transition: @@ -42,7 +43,7 @@ font-size: 20px; background-size:cover; background-position:center; - flex: 1; + align-content: center; justify-content: center; display: flex; flex-direction: column; @@ -55,21 +56,31 @@ .panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); } .panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); } - /* Flex Items */ .panel > * { margin:0; width: 100%; transition:transform 0.5s; flex: 1 0 auto; - display:flex; - justify-content: center; + display: flex; align-items: center; + justify-content: center; + } + + .panel > *:first-child { + transform: translateY(-100%); } - .panel > *:first-child { transform: translateY(-100%); } - .panel.open-active > *:first-child { transform: translateY(0); } - .panel > *:last-child { transform: translateY(100%); } - .panel.open-active > *:last-child { transform: translateY(0); } + .panel.open-active > *:first-child { + transform: translateY(0); + } + + .panel > *:last-child { + transform: translateY(100%); + } + + .panel.open-active > *:last-child { + transform: translateY(0); + } .panel p { text-transform: uppercase; @@ -82,8 +93,8 @@ } .panel.open { - flex: 5; font-size:40px; + flex: 5; } .cta { @@ -123,22 +134,21 @@ From 8d7dbb61eca87bec81ce36d913fdd23a48a9ad75 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Wed, 14 Dec 2016 13:43:19 -0600 Subject: [PATCH 06/16] completes type ahead --- 06 - Type Ahead/index-FINISHED.html | 61 ---------------------------- 06 - Type Ahead/index-START.html | 22 ---------- 06 - Type Ahead/index.html | 63 +++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 83 deletions(-) delete mode 100644 06 - Type Ahead/index-FINISHED.html delete mode 100644 06 - Type Ahead/index-START.html create mode 100644 06 - Type Ahead/index.html diff --git a/06 - Type Ahead/index-FINISHED.html b/06 - Type Ahead/index-FINISHED.html deleted file mode 100644 index 5902b43936..0000000000 --- a/06 - Type Ahead/index-FINISHED.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Type Ahead 👀 - - - - -
- -
    -
  • Filter for a city
  • -
  • or a state
  • -
-
- - - diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html deleted file mode 100644 index 1436886918..0000000000 --- a/06 - Type Ahead/index-START.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - Type Ahead 👀 - - - - -
- -
    -
  • Filter for a city
  • -
  • or a state
  • -
-
- - - diff --git a/06 - Type Ahead/index.html b/06 - Type Ahead/index.html new file mode 100644 index 0000000000..ab48d5b9a4 --- /dev/null +++ b/06 - Type Ahead/index.html @@ -0,0 +1,63 @@ + + + + + Type Ahead 👀 + + + + +
+ +
    +
  • Filter for a city
  • +
  • or a state
  • +
+
+ + + From 3c52f277260ec974bb141d1e3b21cd2121b8d714 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Wed, 14 Dec 2016 14:18:31 -0600 Subject: [PATCH 07/16] completes array meth 2 --- 07 - Array Cardio Day 2/index-FINISHED.html | 68 ------------------- .../{index-START.html => index.html} | 13 ++++ 2 files changed, 13 insertions(+), 68 deletions(-) delete mode 100644 07 - Array Cardio Day 2/index-FINISHED.html rename 07 - Array Cardio Day 2/{index-START.html => index.html} (68%) diff --git a/07 - Array Cardio Day 2/index-FINISHED.html b/07 - Array Cardio Day 2/index-FINISHED.html deleted file mode 100644 index c8e5b25d3b..0000000000 --- a/07 - Array Cardio Day 2/index-FINISHED.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - Array Cardio 💪💪 - - -

Psst: have a look at the JavaScript Console 💁

- - - diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index.html similarity index 68% rename from 07 - Array Cardio Day 2/index-START.html rename to 07 - Array Cardio Day 2/index.html index 206ec31aa0..65522d5ab4 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index.html @@ -26,15 +26,28 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19? + const nineteenA = people.some(person => { + const now = new Date().getFullYear() + return now - person.year >= 19 + }) + // Array.prototype.every() // is everyone 19? + const nineteenB = people.every(person => { + const now = new Date().getFullYear() + return now - person.year >= 19 + }) // Array.prototype.find() // Find is like filter, but instead returns just the one you are looking for // find the comment with the ID of 823423 + const found = comments.find(comment => comment.id === 823423) + // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + const index = comments.findIndex(comment => comment.id === 823423) + const newComments = [...comments.slice(0, index), ...comments.slice(index + 1)] From 138f95808c832b441345db56e5ffb86bc4ff0be4 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Wed, 14 Dec 2016 14:50:04 -0600 Subject: [PATCH 08/16] completes canvas --- .../index-FINISHED.html | 73 ------------------- 08 - Fun with HTML5 Canvas/index-START.html | 19 ----- 08 - Fun with HTML5 Canvas/index.html | 66 +++++++++++++++++ 3 files changed, 66 insertions(+), 92 deletions(-) delete mode 100644 08 - Fun with HTML5 Canvas/index-FINISHED.html delete mode 100644 08 - Fun with HTML5 Canvas/index-START.html create mode 100644 08 - Fun with HTML5 Canvas/index.html diff --git a/08 - Fun with HTML5 Canvas/index-FINISHED.html b/08 - Fun with HTML5 Canvas/index-FINISHED.html deleted file mode 100644 index 0791e17d0d..0000000000 --- a/08 - Fun with HTML5 Canvas/index-FINISHED.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - HTML5 Canvas - - - - - - - - - diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html deleted file mode 100644 index 37c148df07..0000000000 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - HTML5 Canvas - - - - - - - - - diff --git a/08 - Fun with HTML5 Canvas/index.html b/08 - Fun with HTML5 Canvas/index.html new file mode 100644 index 0000000000..4866de34cc --- /dev/null +++ b/08 - Fun with HTML5 Canvas/index.html @@ -0,0 +1,66 @@ + + + + + HTML5 Canvas + + + + + + + + + + From 984c659125b2ef3f7b5e0f68ab55c487f5d82d31 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Thu, 15 Dec 2016 18:24:50 -0600 Subject: [PATCH 09/16] completes shift checks --- .../index-FINISHED.html | 137 ------------------ .../{index-START.html => index.html} | 17 +++ 2 files changed, 17 insertions(+), 137 deletions(-) delete mode 100644 10 - Hold Shift and Check Checkboxes/index-FINISHED.html rename 10 - Hold Shift and Check Checkboxes/{index-START.html => index.html} (83%) diff --git a/10 - Hold Shift and Check Checkboxes/index-FINISHED.html b/10 - Hold Shift and Check Checkboxes/index-FINISHED.html deleted file mode 100644 index 3ce296cc4b..0000000000 --- a/10 - Hold Shift and Check Checkboxes/index-FINISHED.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - - Document - - - - -
-
- -

This is an inbox layout.

-
-
- -

Check one item

-
-
- -

Hold down your Shift key

-
-
- -

Check a lower item

-
-
- -

Everything inbetween should also be set to checked

-
-
- -

Try do it with out any libraries

-
-
- -

Just regular JavaScript

-
-
- -

Good Luck!

-
-
- -

Don't forget to tweet your result!

-
-
- - - - diff --git a/10 - Hold Shift and Check Checkboxes/index-START.html b/10 - Hold Shift and Check Checkboxes/index.html similarity index 83% rename from 10 - Hold Shift and Check Checkboxes/index-START.html rename to 10 - Hold Shift and Check Checkboxes/index.html index eb7ed310bb..1976e7d733 100644 --- a/10 - Hold Shift and Check Checkboxes/index-START.html +++ b/10 - Hold Shift and Check Checkboxes/index.html @@ -104,6 +104,23 @@ From afef869f065f62609232eaa02d253de870f319f8 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Thu, 15 Dec 2016 18:57:26 -0600 Subject: [PATCH 10/16] completes custom html5 player --- 11 - Custom Video Player/scripts-FINISHED.js | 55 -------------------- 11 - Custom Video Player/scripts.js | 49 +++++++++++++++++ 2 files changed, 49 insertions(+), 55 deletions(-) delete mode 100644 11 - Custom Video Player/scripts-FINISHED.js diff --git a/11 - Custom Video Player/scripts-FINISHED.js b/11 - Custom Video Player/scripts-FINISHED.js deleted file mode 100644 index cedacf2f68..0000000000 --- a/11 - Custom Video Player/scripts-FINISHED.js +++ /dev/null @@ -1,55 +0,0 @@ -/* Get Our Elements */ -const player = document.querySelector('.player'); -const video = player.querySelector('.viewer'); -const progress = player.querySelector('.progress'); -const progressBar = player.querySelector('.progress__filled'); -const toggle = player.querySelector('.toggle'); -const skipButtons = player.querySelectorAll('[data-skip]'); -const ranges = player.querySelectorAll('.player__slider'); - -/* Build out functions */ -function togglePlay() { - const method = video.paused ? 'play' : 'pause'; - video[method](); -} - -function updateButton() { - const icon = this.paused ? '►' : '❚ ❚'; - console.log(icon); - toggle.textContent = icon; -} - -function skip() { - video.currentTime += parseFloat(this.dataset.skip); -} - -function handleRangeUpdate() { - video[this.name] = this.value; -} - -function handleProgress() { - const percent = (video.currentTime / video.duration) * 100; - progressBar.style.flexBasis = `${percent}%`; -} - -function scrub(e) { - const scrubTime = (e.offsetX / progress.offsetWidth) * video.duration; - video.currentTime = scrubTime; -} - -/* Hook up the event listners */ -video.addEventListener('click', togglePlay); -video.addEventListener('play', updateButton); -video.addEventListener('pause', updateButton); -video.addEventListener('timeupdate', handleProgress); - -toggle.addEventListener('click', togglePlay); -skipButtons.forEach(button => button.addEventListener('click', skip)); -ranges.forEach(range => range.addEventListener('change', handleRangeUpdate)); -ranges.forEach(range => range.addEventListener('mousemove', handleRangeUpdate)); - -let mousedown = false; -progress.addEventListener('click', scrub); -progress.addEventListener('mousemove', (e) => mousedown && scrub(e)); -progress.addEventListener('mousedown', () => mousedown = true); -progress.addEventListener('mouseup', () => mousedown = false); diff --git a/11 - Custom Video Player/scripts.js b/11 - Custom Video Player/scripts.js index e69de29bb2..7b11da4823 100644 --- a/11 - Custom Video Player/scripts.js +++ b/11 - Custom Video Player/scripts.js @@ -0,0 +1,49 @@ +// get our elements +const player = document.querySelector('.player') +const video = player.querySelector('.viewer') +const progress = player.querySelector('.progress') +const progressBar = player.querySelector('.progress_filled') +const toggle = player.querySelector('.toggle') +const skipButtons = player.querySelector('[data-skip]') +const ranges = player.querySelector('.player-slider') + +//build our functions +function togglePlay(){ + video[video.paused ? 'play' : 'pause']() +} + +function updateButton(){ + toggle.textContent = this.paused ? '►' : '❚ ❚' +} + +function skip(){ + video.currentTime += parseFloat(this.dataset.skip) +} + +function handleRangeUpdate(){ + video[this.name] = this.value +} + +function handleProgress(){ + const percent = (video.currentTime / video.duration) * 100 + progressBar.style.flexBasis = `${percent}%` +} + +function scrub(e){ + const scrubTime = (e.offsetX / progress.offsetWidth) * video.duration + video.currentTime = scrubTime +} + +//hookup the event listeners +video.addEventListener('click', togglePlay) +video.addEventListener('play', updateButton) +video.addEventListener('pause', updateButton) +video.addEventListener('timeupdate', handleProgress) +toggle.addEventListener('click', togglePlay) +skipButtons.forEach(button => button.addEventListener('click', skip)) +ranges.forEach(range => range.addEventListener('change', handleRangeUpdate)) +let mousedown = false +progress.addEventListener('click', scrub) +progress.addEventListener('mousemove', (e) => mousedown && scrub(e))) +progress.addEventListener('mouseup', () => mousedown = true) +progress.addEventListener('mousedown', mousedown = false) From 4474806e417838cd616a2f936c2552f46e2264b5 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Tue, 20 Dec 2016 14:46:13 -0800 Subject: [PATCH 11/16] completes kanomi --- .../index-FINISHED.html | 25 ------------------- 12 - Key Sequence Detection/index-START.html | 12 --------- 12 - Key Sequence Detection/index.html | 22 ++++++++++++++++ 3 files changed, 22 insertions(+), 37 deletions(-) delete mode 100644 12 - Key Sequence Detection/index-FINISHED.html delete mode 100644 12 - Key Sequence Detection/index-START.html create mode 100644 12 - Key Sequence Detection/index.html diff --git a/12 - Key Sequence Detection/index-FINISHED.html b/12 - Key Sequence Detection/index-FINISHED.html deleted file mode 100644 index 562127a0d2..0000000000 --- a/12 - Key Sequence Detection/index-FINISHED.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - Key Detection - - - - - - diff --git a/12 - Key Sequence Detection/index-START.html b/12 - Key Sequence Detection/index-START.html deleted file mode 100644 index 8cab786140..0000000000 --- a/12 - Key Sequence Detection/index-START.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - Key Detection - - - - - - diff --git a/12 - Key Sequence Detection/index.html b/12 - Key Sequence Detection/index.html new file mode 100644 index 0000000000..38a88dbd98 --- /dev/null +++ b/12 - Key Sequence Detection/index.html @@ -0,0 +1,22 @@ + + + + + Key Detection + + + + + + From b94e00a04129acb3a32563669a15dff08347c934 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Tue, 20 Dec 2016 15:25:30 -0800 Subject: [PATCH 12/16] completes picture scrolls --- 13 - Slide in on Scroll/index-FINISHED.html | 140 ------------------ .../{index-START.html => index.html} | 29 ++-- 2 files changed, 15 insertions(+), 154 deletions(-) delete mode 100644 13 - Slide in on Scroll/index-FINISHED.html rename 13 - Slide in on Scroll/{index-START.html => index.html} (95%) diff --git a/13 - Slide in on Scroll/index-FINISHED.html b/13 - Slide in on Scroll/index-FINISHED.html deleted file mode 100644 index bbaf0b6f22..0000000000 --- a/13 - Slide in on Scroll/index-FINISHED.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - - Document - - - -
- -

Slide in on Scroll

- -

Consectetur adipisicing elit. Tempore tempora rerum, est autem cupiditate, corporis a qui libero ipsum delectus quidem dolor at nulla, adipisci veniam in reiciendis aut asperiores omnis blanditiis quod quas laborum nam! Fuga ad tempora in aspernatur pariaturlores sunt esse magni, ut, dignissimos.

-

Lorem ipsum cupiditate, corporis a qui libero ipsum delectus quidem dolor at nulla, adipisci veniam in reiciendis aut asperiores omnis blanditiis quod quas laborum nam! Fuga ad tempora in aspernatur pariatur fugit quibusdam dolores sunt esse magni, ut, dignissimos.

-

Adipisicing elit. Tempore tempora rerum..

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore tempora rerum, est autem cupiditate, corporis a qui libero ipsum delectus quidem dolor at nulla, adipisci veniam in reiciendis aut asperiores omnis blanditiis quod quas laborum nam! Fuga ad tempora in aspernatur pariatur fugit quibusdam dolores sunt esse magni, ut, dignissimos.

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore tempora rerum, est autem cupiditate, corporis a qui libero ipsum delectus quidem dolor at nulla, adipisci veniam in reiciendis aut asperiores omnis blanditiis quod quas laborum nam! Fuga ad tempora in aspernatur pariatur fugit quibusdam dolores sunt esse magni, ut, dignissimos.

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore tempora rerum, est autem cupiditate, corporis a qui libero ipsum delectus quidem dolor at nulla, adipisci veniam in reiciendis aut asperiores omnis blanditiis quod quas laborum nam! Fuga ad tempora in aspernatur pariatur fugit quibusdam dolores sunt esse magni, ut, dignissimos.

- - - -

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates, deserunt facilis et iste corrupti omnis tenetur est. Iste ut est dicta dolor itaque adipisci, dolorum minima, veritatis earum provident error molestias. Ratione magni illo sint vel velit ut excepturi consectetur suscipit, earum modi accusamus voluptatem nostrum, praesentium numquam, reiciendis voluptas sit id quisquam. Consequatur in quis reprehenderit modi perspiciatis necessitatibus saepe, quidem, suscipit iure natus dignissimos ipsam, eligendi deleniti accusantium, rerum quibusdam fugit perferendis et optio recusandae sed ratione. Culpa, dolorum reprehenderit harum ab voluptas fuga, nisi eligendi natus maiores illum quas quos et aperiam aut doloremque optio maxime fugiat doloribus. Eum dolorum expedita quam, nesciunt

- - - -

at provident praesentium atque quas rerum optio dignissimos repudiandae ullam illum quibusdam. Vel ad error quibusdam, illo ex totam placeat. Quos excepturi fuga, molestiae ea quisquam minus, ratione dicta consectetur officia omnis, doloribus voluptatibus? Veniam ipsum veritatis architecto, provident quas consequatur doloremque quam quidem earum expedita, ad delectus voluptatum, omnis praesentium nostrum qui aspernatur ea eaque adipisci et cumque ab? Ea voluptatum dolore itaque odio. Eius minima distinctio harum, officia ab nihil exercitationem. Tempora rem nemo nam temporibus molestias facilis minus ipsam quam doloribus consequatur debitis nesciunt tempore officiis aperiam quisquam, molestiae voluptates cum, fuga culpa. Distinctio accusamus quibusdam, tempore perspiciatis dolorum optio facere consequatur quidem ullam beatae architecto, ipsam sequi officiis dignissimos amet impedit natus necessitatibus tenetur repellendus dolor rem! Dicta dolorem, iure, facilis illo ex nihil ipsa amet officia, optio temporibus eum autem odit repellendus nisi. Possimus modi, corrupti error debitis doloribus dicta libero earum, sequi porro ut excepturi nostrum ea voluptatem nihil culpa? Ullam expedita eligendi obcaecati reiciendis velit provident omnis quas qui in corrupti est dolore facere ad hic, animi soluta assumenda consequuntur reprehenderit! Voluptate dolor nihil veniam laborum voluptas nisi pariatur sed optio accusantium quam consectetur, corrupti, sequi et consequuntur, excepturi doloremque. Tempore quis velit corporis neque fugit non sequi eaque rem hic. Facere, inventore, aspernatur. Accusantium modi atque, asperiores qui nobis soluta cumque suscipit excepturi possimus doloremque odit saepe perferendis temporibus molestiae nostrum voluptatum quis id sint quidem nesciunt culpa. Rerum labore dolor beatae blanditiis praesentium explicabo velit optio esse aperiam similique, voluptatem cum, maiores ipsa tempore. Reiciendis sed culpa atque inventore, nam ullam enim expedita consectetur id velit iusto alias vitae explicabo nemo neque odio reprehenderit soluta sint eaque. Aperiam, qui ut tenetur, voluptate doloremque officiis dicta quaerat voluptatem rerum natus magni. Eum amet autem dolor ullam.

- - - -

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio maiores adipisci quibusdam repudiandae dolor vero placeat esse sit! Quibusdam saepe aperiam explicabo placeat optio, consequuntur nihil voluptatibus expedita quia vero perferendis, deserunt et incidunt eveniet temporibus doloremque possimus facilis. Possimus labore, officia dolore! Eaque ratione saepe, alias harum laboriosam deserunt laudantium blanditiis eum explicabo placeat reiciendis labore iste sint. Consectetur expedita dignissimos, non quos distinctio, eos rerum facilis eligendi. Asperiores laudantium, rerum ratione consequatur, culpa consectetur possimus atque ab tempore illum non dolor nesciunt. Neque, rerum. A vel non incidunt, quod doloremque dignissimos necessitatibus aliquid laboriosam architecto at cupiditate commodi expedita in, quae blanditiis. Deserunt labore sequi, repellat laboriosam est, doloremque culpa reiciendis tempore excepturi. Enim nostrum fugit itaque vel corporis ullam sed tenetur ipsa qui rem quam error sint, libero. Laboriosam rem, ratione. Autem blanditiis

- - -

laborum neque repudiandae quam, cumque, voluptate veritatis itaque, placeat veniam ad nisi. Expedita, laborum reprehenderit ratione soluta velit natus, odit mollitia. Corporis rerum minima fugiat in nostrum. Assumenda natus cupiditate hic quidem ex, quas, amet ipsum esse dolore facilis beatae maxime qui inventore, iste? Maiores dignissimos dolore culpa debitis voluptatem harum, excepturi enim reiciendis, tempora ab ipsam illum aspernatur quasi qui porro saepe iure sunt eligendi tenetur quaerat ducimus quas sequi omnis aperiam suscipit! Molestiae obcaecati officiis quo, ratione eveniet, provident pariatur. Veniam quasi expedita distinctio, itaque molestiae sequi, dolorum nisi repellendus quia facilis iusto dignissimos nam? Tenetur fugit quos autem nihil, perspiciatis expedita enim tempore, alias ab maiores quis necessitatibus distinctio molestias eum, quidem. Delectus impedit quidem laborum, fugit vel neque quo, ipsam, quasi aspernatur quas odio nihil? Veniam amet reiciendis blanditiis quis reprehenderit repudiandae neque, ab ducimus, odit excepturi voluptate saepe ipsam. Voluptatem eum error voluptas porro officiis, amet! Molestias, fugit, ut! Tempore non magnam, amet, facere ducimus accusantium eos veritatis neque.

- - - -

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio maiores adipisci quibusdam repudiandae dolor vero placeat esse sit! Quibusdam saepe aperiam explicabo placeat optio, consequuntur nihil voluptatibus expedita quia vero perferendis, deserunt et incidunt eveniet temporibus doloremque possimus facilis. Possimus labore, officia dolore! Eaque ratione saepe, alias harum laboriosam deserunt laudantium blanditiis eum explicabo placeat reiciendis labore iste sint. Consectetur expedita dignissimos, non quos distinctio, eos rerum facilis eligendi. Asperiores laudantium, rerum ratione consequatur, culpa consectetur possimus atque ab tempore illum non dolor nesciunt. Neque, rerum. A vel non incidunt, quod doloremque dignissimos necessitatibus aliquid laboriosam architecto at cupiditate commodi expedita in, quae blanditiis. Deserunt labore sequi, repellat laboriosam est, doloremque culpa reiciendis tempore excepturi. Enim nostrum fugit itaque vel corporis ullam sed tenetur ipsa qui rem quam error sint, libero. Laboriosam rem, ratione. Autem blanditiis laborum neque repudiandae quam, cumque, voluptate veritatis itaque, placeat veniam ad nisi. Expedita, laborum reprehenderit ratione soluta velit natus, odit mollitia. Corporis rerum minima fugiat in nostrum. Assumenda natus cupiditate hic quidem ex, quas, amet ipsum esse dolore facilis beatae maxime qui inventore, iste? Maiores dignissimos dolore culpa debitis voluptatem harum, excepturi enim reiciendis, tempora ab ipsam illum aspernatur quasi qui porro saepe iure sunt eligendi tenetur quaerat ducimus quas sequi omnis aperiam suscipit! Molestiae obcaecati officiis quo, ratione eveniet, provident pariatur. Veniam quasi expedita distinctio, itaque molestiae sequi, dolorum nisi repellendus quia facilis iusto dignissimos nam? Tenetur fugit quos autem nihil, perspiciatis expedita enim tempore, alias ab maiores quis necessitatibus distinctio molestias eum, quidem. Delectus impedit quidem laborum, fugit vel neque quo, ipsam, quasi aspernatur quas odio nihil? Veniam amet reiciendis blanditiis quis reprehenderit repudiandae neque, ab ducimus, odit excepturi voluptate saepe ipsam. Voluptatem eum error voluptas porro officiis, amet! Molestias, fugit, ut! Tempore non magnam, amet, facere ducimus accusantium eos veritatis neque.

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio maiores adipisci quibusdam repudiandae dolor vero placeat esse sit! Quibusdam saepe aperiam explicabo placeat optio, consequuntur nihil voluptatibus expedita quia vero perferendis, deserunt et incidunt eveniet temporibus doloremque possimus facilis. Possimus labore, officia dolore! Eaque ratione saepe, alias harum laboriosam deserunt laudantium blanditiis eum explicabo placeat reiciendis labore iste sint. Consectetur expedita dignissimos, non quos distinctio, eos rerum facilis eligendi. Asperiores laudantium, rerum ratione consequatur, culpa consectetur possimus atque ab tempore illum non dolor nesciunt. Neque, rerum. A vel non incidunt, quod doloremque dignissimos necessitatibus aliquid laboriosam architecto at cupiditate commodi expedita in, quae blanditiis. Deserunt labore sequi, repellat laboriosam est, doloremque culpa reiciendis tempore excepturi. Enim nostrum fugit itaque vel corporis ullam sed tenetur ipsa qui rem quam error sint, libero. Laboriosam rem, ratione. Autem blanditiis laborum neque repudiandae quam, cumque, voluptate veritatis itaque, placeat veniam ad nisi. Expedita, laborum reprehenderit ratione soluta velit natus, odit mollitia. Corporis rerum minima fugiat in nostrum. Assumenda natus cupiditate hic quidem ex, quas, amet ipsum esse dolore facilis beatae maxime qui inventore, iste? Maiores dignissimos dolore culpa debitis voluptatem harum, excepturi enim reiciendis, tempora ab ipsam illum aspernatur quasi qui porro saepe iure sunt eligendi tenetur quaerat ducimus quas sequi omnis aperiam suscipit! Molestiae obcaecati officiis quo, ratione eveniet, provident pariatur. Veniam quasi expedita distinctio, itaque molestiae sequi, dolorum nisi repellendus quia facilis iusto dignissimos nam? Tenetur fugit quos autem nihil, perspiciatis expedita enim tempore, alias ab maiores quis necessitatibus distinctio molestias eum, quidem. Delectus impedit quidem laborum, fugit vel neque quo, ipsam, quasi aspernatur quas odio nihil? Veniam amet reiciendis blanditiis quis reprehenderit repudiandae neque, ab ducimus, odit excepturi voluptate saepe ipsam. Voluptatem eum error voluptas porro officiis, amet! Molestias, fugit, ut! Tempore non magnam, amet, facere ducimus accusantium eos veritatis neque.

- - - - -
- - - - - - - diff --git a/13 - Slide in on Scroll/index-START.html b/13 - Slide in on Scroll/index.html similarity index 95% rename from 13 - Slide in on Scroll/index-START.html rename to 13 - Slide in on Scroll/index.html index 12591bad30..bda3cde1e4 100644 --- a/13 - Slide in on Scroll/index-START.html +++ b/13 - Slide in on Scroll/index.html @@ -58,25 +58,26 @@

Slide in on Scroll

}; } - const sliderImages = document.querySelectorAll('.slide-in'); - - function checkSlide(e) { - sliderImages.forEach(sliderImage => { - // half way through the image - const slideInAt = (window.scrollY + window.innerHeight) - sliderImage.height / 2; - // bottom of the image - const imageBottom = sliderImage.offsetTop + sliderImage.height; - const isHalfShown = slideInAt > sliderImage.offsetTop; - const isNotScrolledPast = window.scrollY < imageBottom; + const sliderImages = document.querySelectorAll('.slide-in') + + function checkSlide(e){ + sliderImages.forEach(img => { + //halfway thru img + const slideInAt = (window.scrollY + window.innerHeight) - (img.height/2) + //bottom of img + const imgBottom = img.offsetTop + img.height + const isHalfShown = slideInAt > img.offsetTop + const isNotScrolledPast = window.scrollY < imgBottom + if (isHalfShown && isNotScrolledPast) { - sliderImage.classList.add('active'); + img.classList.add('active') } else { - sliderImage.classList.remove('active'); + img.classList.remove('active') } - }); + }) } - window.addEventListener('scroll', debounce(checkSlide)); + window.addEventListener('scroll', debounce(checkSlide)) From 2dc55e4e37b25a958bc5c3a9dafa283cc15ef956 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Wed, 21 Dec 2016 11:32:23 -0800 Subject: [PATCH 13/16] completes 15 --- 09 - Dev Tools Domination/index-START.html | 1 + 15 - LocalStorage/index-FINISHED.html | 77 ---------------------- 15 - LocalStorage/index-START.html | 41 +++++++++++- 3 files changed, 41 insertions(+), 78 deletions(-) delete mode 100644 15 - LocalStorage/index-FINISHED.html diff --git a/09 - Dev Tools Domination/index-START.html b/09 - Dev Tools Domination/index-START.html index 196fffd719..59e3acf58e 100644 --- a/09 - Dev Tools Domination/index-START.html +++ b/09 - Dev Tools Domination/index-START.html @@ -18,6 +18,7 @@ } // Regular + // Interpolated diff --git a/15 - LocalStorage/index-FINISHED.html b/15 - LocalStorage/index-FINISHED.html deleted file mode 100644 index 2c492b1088..0000000000 --- a/15 - LocalStorage/index-FINISHED.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - LocalStorage - - - - - - - -
-

LOCAL TAPAS

-

-
    -
  • Loading Tapas...
  • -
-
- - -
-
- - - - - - - diff --git a/15 - LocalStorage/index-START.html b/15 - LocalStorage/index-START.html index d444f1d68b..6f7f1bfd2f 100644 --- a/15 - LocalStorage/index-START.html +++ b/15 - LocalStorage/index-START.html @@ -28,7 +28,46 @@

LOCAL TAPAS

From 4be06e69c4dd788090283515a9cc84c8190440d7 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Tue, 27 Dec 2016 15:42:17 -0800 Subject: [PATCH 14/16] completes 16 --- 16 - Mouse Move Shadow/index-finished.html | 63 ---------------------- 16 - Mouse Move Shadow/index-start.html | 36 ------------- 16 - Mouse Move Shadow/index.html | 62 +++++++++++++++++++++ 3 files changed, 62 insertions(+), 99 deletions(-) delete mode 100644 16 - Mouse Move Shadow/index-finished.html delete mode 100644 16 - Mouse Move Shadow/index-start.html create mode 100644 16 - Mouse Move Shadow/index.html diff --git a/16 - Mouse Move Shadow/index-finished.html b/16 - Mouse Move Shadow/index-finished.html deleted file mode 100644 index 4328eaf6ab..0000000000 --- a/16 - Mouse Move Shadow/index-finished.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - Mouse Shadow - - - -
-

🔥WOAH!

-
- - - - - - diff --git a/16 - Mouse Move Shadow/index-start.html b/16 - Mouse Move Shadow/index-start.html deleted file mode 100644 index 58a9bba861..0000000000 --- a/16 - Mouse Move Shadow/index-start.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - Mouse Shadow - - - -
-

🔥WOAH!

-
- - - - - - diff --git a/16 - Mouse Move Shadow/index.html b/16 - Mouse Move Shadow/index.html new file mode 100644 index 0000000000..6e95349618 --- /dev/null +++ b/16 - Mouse Move Shadow/index.html @@ -0,0 +1,62 @@ + + + + + Mouse Shadow + + + +
+

🔥WOAH!

+
+ + + + + + From 528bd4d52fa31a65657116755f749317c1552883 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Tue, 27 Dec 2016 15:57:44 -0800 Subject: [PATCH 15/16] completes 18 --- .../index-FINISHED.html | 207 ------------------ .../{index-START.html => index.html} | 18 ++ 2 files changed, 18 insertions(+), 207 deletions(-) delete mode 100644 18 - Adding Up Times with Reduce/index-FINISHED.html rename 18 - Adding Up Times with Reduce/{index-START.html => index.html} (85%) diff --git a/18 - Adding Up Times with Reduce/index-FINISHED.html b/18 - Adding Up Times with Reduce/index-FINISHED.html deleted file mode 100644 index 9dcbb3d396..0000000000 --- a/18 - Adding Up Times with Reduce/index-FINISHED.html +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Videos - - -
    -
  • - Video 1 -
  • -
  • - Video 2 -
  • -
  • - Video 3 -
  • -
  • - Video 4 -
  • -
  • - Video 5 -
  • -
  • - Video 6 -
  • -
  • - Video 7 -
  • -
  • - Video 8 -
  • -
  • - Video 9 -
  • -
  • - Video 10 -
  • -
  • - Video 11 -
  • -
  • - Video 12 -
  • -
  • - Video 13 -
  • -
  • - Video 14 -
  • -
  • - Video 15 -
  • -
  • - Video 16 -
  • -
  • - Video 17 -
  • -
  • - Video 18 -
  • -
  • - Video 19 -
  • -
  • - Video 20 -
  • -
  • - Video 21 -
  • -
  • - Video 22 -
  • -
  • - Video 23 -
  • -
  • - Video 24 -
  • -
  • - Video 25 -
  • -
  • - Video 26 -
  • -
  • - Video 27 -
  • -
  • - Video 28 -
  • -
  • - Video 29 -
  • -
  • - Video 30 -
  • -
  • - Video 31 -
  • -
  • - Video 32 -
  • -
  • - Video 33 -
  • -
  • - Video 34 -
  • -
  • - Video 35 -
  • -
  • - Video 36 -
  • -
  • - Video 37 -
  • -
  • - Video 38 -
  • -
  • - Video 39 -
  • -
  • - Video 40 -
  • -
  • - Video 41 -
  • -
  • - Video 42 -
  • -
  • - Video 43 -
  • -
  • - Video 44 -
  • -
  • - Video 45 -
  • -
  • - Video 46 -
  • -
  • - Video 47 -
  • -
  • - Video 48 -
  • -
  • - Video 49 -
  • -
  • - Video 50 -
  • -
  • - Video 51 -
  • -
  • - Video 52 -
  • -
  • - Video 53 -
  • -
  • - Video 54 -
  • -
  • - Video 55 -
  • -
  • - Video 56 -
  • -
  • - Video 57 -
  • -
  • - Video 58 -
  • - - - - diff --git a/18 - Adding Up Times with Reduce/index-START.html b/18 - Adding Up Times with Reduce/index.html similarity index 85% rename from 18 - Adding Up Times with Reduce/index-START.html rename to 18 - Adding Up Times with Reduce/index.html index 3eaee0f3ef..20ed1d6d7f 100644 --- a/18 - Adding Up Times with Reduce/index-START.html +++ b/18 - Adding Up Times with Reduce/index.html @@ -182,6 +182,24 @@ From 0e81298e1fa5e7f060be1888bfee72216fd511c3 Mon Sep 17 00:00:00 2001 From: Jason Barnett Date: Thu, 29 Dec 2016 14:12:05 -0600 Subject: [PATCH 16/16] completes 19 webcam fun --- 19 - Webcam Fun/index.html | 4 +- 19 - Webcam Fun/scripts.js | 89 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/19 - Webcam Fun/index.html b/19 - Webcam Fun/index.html index d4ffc4dc2a..cb2d1b18a4 100755 --- a/19 - Webcam Fun/index.html +++ b/19 - Webcam Fun/index.html @@ -10,7 +10,7 @@
    - +
    diff --git a/19 - Webcam Fun/scripts.js b/19 - Webcam Fun/scripts.js index 00355f5a9c..f228240794 100644 --- a/19 - Webcam Fun/scripts.js +++ b/19 - Webcam Fun/scripts.js @@ -3,3 +3,92 @@ const canvas = document.querySelector('.photo'); const ctx = canvas.getContext('2d'); const strip = document.querySelector('.strip'); const snap = document.querySelector('.snap'); + +function getVideo() { + navigator.mediaDevices.getUserMedia({video: true, audio: false}) + .then(localMediaStream => { + video.src = window.URL.createObjectURL(localMediaStream) + video.play() + }) + .catch(err => { + console.error('WTF! Let me acces your cam!') + }) +} + +function paintToCanvas() { + const width = video.videoWidth + const height = video.videoHeight + canvas.width = width + canvas.height = height + + return setInterval(() => { + ctx.drawImage(video, 0, 0, width, height) + let pixels = ctx.getImageData(0, 0, width, height) + // pixels = redEffect(pixels) + // pixels = rgbSplit(pixels) + pixels = greenScreen(pixels) + // ctx.globalAlpha = 0.2 + ctx.putImageData(pixels, 0, 0) + }, 16) +} + +function takePhoto() { + snap.currentTime = 0 + snap.play() + + const data = canvas.toDataURL('image/jpeg') + const link = document.createElement('a') + link.href = data + link.setAttribute('download', 'handsome') + link.innerHTML = `Handsome Man` + strip.insertBefore(link, strip.firstChild) +} + +function redEffect(pixels) { + for (let i = 0; i < pixels.data.length; i += 4){ + pixels.data[i + 0] = pixels.data[i + 0] + 100 //red + pixels.data[i + 1] = pixels.data[i + 1] - 50 //green + pixels.data[i + 2] = pixels.data[i + 2] * 0.5 //blue + } + return pixels +} + +function rgbSplit(pixels) { + for (let i = 0; i < pixels.data.length; i += 4){ + pixels.data[i - 150] = pixels.data[i + 0] + 100 //red + pixels.data[i + 500] = pixels.data[i + 1] - 50 //green + pixels.data[i - 550] = pixels.data[i + 2] * 0.5 //blue + } + return pixels +} + +function greenScreen(pixels) { + const levels = {}; + + document.querySelectorAll('.rgb input').forEach((input) => { + levels[input.name] = input.value; + }); + + for (i = 0; i < pixels.data.length; i = i + 4) { + red = pixels.data[i + 0]; + green = pixels.data[i + 1]; + blue = pixels.data[i + 2]; + alpha = pixels.data[i + 3]; + + if (red >= levels.rmin + && green >= levels.gmin + && blue >= levels.bmin + && red <= levels.rmax + && green <= levels.gmax + && blue <= levels.bmax) { + // take it out! + pixels.data[i + 3] = 0; + } + } + + return pixels; +} + +getVideo() + +video.addEventListener('canplay', paintToCanvas) \ No newline at end of file