Skip to content

Commit 84298a1

Browse files
committed
get colorize effect to work right.
1 parent cd04e50 commit 84298a1

File tree

6 files changed

+134
-94
lines changed

6 files changed

+134
-94
lines changed

19--Webcam_Fun/css/booth.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
bottom:0;
88
right:0;
99
background:black url('../img/starrynight.jpg') center center no-repeat;
10+
background:black url('../img/tvstatic-diagonal.gif') center center no-repeat;
1011
background-size:cover;
1112
}
1213

@@ -38,7 +39,7 @@ canvas {
3839
z-index:3;
3940
background:white;
4041
box-shadow:0 0.5rem 1.5rem 0 rgba(0, 0, 0, 0.5);
41-
padding:5px;
42+
padding:0.125em;
4243
display:none;
4344
position:absolute;
4445
top:2rem;

19--Webcam_Fun/css/strip.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
height:100%;
55
margin:0;
66
padding:1rem 10px;
7-
/* background:transparent; */
87
background-color:rgba(0, 0, 0, 0.5);
8+
background-color:transparent;
99
position:absolute;
1010
overflow:auto;
1111
overflow-x:hidden;
@@ -28,7 +28,7 @@
2828
.strip a img {
2929
width:100%;
3030
background:white;
31-
padding:5px;
31+
padding:0.125em;
3232
box-shadow:0 0.25rem 1rem 0 rgba(0, 0, 0, 0.25);
3333
}
3434

19--Webcam_Fun/index-jds.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ <h1>webcam fun</h1>
2222
<fieldset class="ctrl_camera">
2323
<legend>web cam</legend>
2424
<button class="btn_on status success" onClick="startStream()">On</button>
25-
<button class="btn_off status error" onClick="stopStream()">Off</button>
25+
<button class="btn_off status error disabled" onClick="stopStream()" disabled>Off</button>
2626
<button class="btn_clear disabled" onClick="clearCanvas()" disabled>Clear</button>
2727
<!-- <button class="status info" onClick="flipCamera()">Flip</button> -->
2828
</fieldset>
@@ -44,19 +44,19 @@ <h1>webcam fun</h1>
4444
<option>Choose effect...</option>
4545
<option value="chroma">Chroma Key</option>
4646
<option value="split">Channel Split</option>
47-
<option value="rgb_channel">RGB Channel</option>
47+
<option value="colorize">Colorize</option>
4848
</select>
4949
</legend>
5050
<div class="alert">
5151
<p class="msg msg_cam" id="">turn web cam "ON" to use video effects</p>
5252
<p class="msg msg_fx" id="">choose a video effect above</p>
5353
</div>
54-
<table id="ctrl_fx--rgb">
54+
<table id="ctrl_fx--colorize">
5555
<tr>
5656
<td>
5757
<label>
5858
<span>rgb:</span>
59-
<select class="status info" id="rgb">
59+
<select class="status info" id="colorize">
6060
<option>Choose color...</option>
6161
<option value="random" selected>random</option>
6262
<option value="red">red</option>
@@ -67,7 +67,7 @@ <h1>webcam fun</h1>
6767
</td>
6868
</tr>
6969
<tr>
70-
<td><button class="btn_apply status success" onClick="startStream()">Apply</button></td>
70+
<td><button class="btn_apply status success">Apply</button></td>
7171
</tr>
7272
</table>
7373
<table id="ctrl_fx--split">
@@ -85,7 +85,7 @@ <h1>webcam fun</h1>
8585
</td>
8686
</tr>
8787
<tr>
88-
<td><button class="btn_apply status success" onClick="startStream()">Apply</button></td>
88+
<td><button class="btn_apply status success">Apply</button></td>
8989
</tr>
9090
</table>
9191
<table id="ctrl_fx--chroma">

19--Webcam_Fun/js/fx.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* fx.js */
2+
console.log('fx.js READY!');
23
function fFxChromaKey(data) {
34
// console.log('START fFxChromaKey');
45
const levels = {};
@@ -38,27 +39,12 @@ function fFxSplit(data,nums) {
3839
return data;
3940
}
4041

41-
function fFxRGB(data,color) {
42-
// console.log('START fFxRGB',color);
43-
if (typeof color === 'string') {
44-
console.log('string!');
45-
for (let i = 0; i < data.data.length; i+=4) {
46-
data.data[i+0] += (color==='red') ? 150 : -50; // r
47-
data.data[i+1] += (color==='green') ? 150 : -50; // g
48-
data.data[i+2] += (color==='blue') ? 150 : -50; // b
49-
}
50-
} else {
51-
console.error('not the right type!');
52-
}
53-
return data;
54-
}
55-
56-
function fFxRGBRandom(data,nums) {
42+
function fFxColorize(data,nums) {
5743
// console.log('START fFxRGB',nums);
5844
for (let i = 0; i < data.data.length; i+=4) {
59-
data.data[i+0] += nums[0]; // r
60-
data.data[i+1] += nums[1]; // g
61-
data.data[i+2] += nums[2]; // b
45+
data.data[i+0] += nums[0]; // r
46+
data.data[i+1] += nums[1]; // g
47+
data.data[i+2] += nums[2]; // b
6248
}
6349
return data;
6450
}

0 commit comments

Comments
 (0)