Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[modify] 目線の最小Y座標となりうる範囲から眉毛の座標を消す(眉毛は出ていたほうがそれっぽい気がした) #3

Merged
merged 1 commit into from Jun 27, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

[modify] 目線の最小Y座標となりうる範囲から眉毛の座標を消す(眉毛は出ていたほうがそれっぽい気がした)

  • Loading branch information...
shimabox committed Jun 27, 2019
commit 6b7d19cb7c686af1df135f108838578a3fe4aa27
@@ -56,8 +56,8 @@ <h1><a href="">PaulMauriat-generator</a></h1>
<i class="fas fa-user-secret privacy-icon"></i>
<select id="face-privacy" name="face-privacy">
<option value="0" selected>none</option>
<option value="1">mosaic</option>
<option value="2">eyeline</option>
<option value="1">eyeline</option>
<option value="2">mosaic</option>
</select>
</div>
</div>
@@ -384,16 +384,6 @@ document.addEventListener('DOMContentLoaded', () => {
let sw = faceW + (faceW * marginOfRightScale);
let sh = faceH + (faceH * marginOfBottomScale);

// 目領域の矩形座標を求める
const indexOfMinEyeX = [19, 20, 23];
const indexOfMinEyeY = [15, 16, 17, 18, 19, 20, 21, 22];
const indexOfMaxEyeX = [15, 16, 28];
const indexOfMaxEyeY = [23, 25, 26, 28, 30, 31, 65, 66, 69, 70];
const coordinatesOfEyes = calcRangeOfCoordinates(p, indexOfMinEyeX, indexOfMinEyeY, indexOfMaxEyeX, indexOfMaxEyeY);

const eyeW = coordinatesOfEyes.maxX - coordinatesOfEyes.minX;
const eyeH = coordinatesOfEyes.maxY - coordinatesOfEyes.minY;

const vcw = canvas.width;
const vch = canvas.height;

@@ -447,6 +437,16 @@ document.addEventListener('DOMContentLoaded', () => {
faceCanvas.width = w;
faceCanvas.height = h;

// 目領域の矩形座標を求める
const indexOfMinEyeX = [19, 20, 23];
const indexOfMinEyeY = [24, 29, 63, 64, 67, 68];
const indexOfMaxEyeX = [15, 16, 28];
const indexOfMaxEyeY = [23, 25, 26, 28, 30, 31, 65, 66, 69, 70];
const coordinatesOfEyes = calcRangeOfCoordinates(p, indexOfMinEyeX, indexOfMinEyeY, indexOfMaxEyeX, indexOfMaxEyeY);

const eyeW = coordinatesOfEyes.maxX - coordinatesOfEyes.minX;
const eyeH = coordinatesOfEyes.maxY - coordinatesOfEyes.minY;

// for privacy.
privacy(facePrivacyVal, canvas, coordinatesOfEyes, eyeW, eyeH);

@@ -512,16 +512,30 @@ document.addEventListener('DOMContentLoaded', () => {
const privacy = (facePrivacyVal, canvas, coordinates, w, h) => {
switch (facePrivacyVal) {
case "1":
mosaic(canvas, coordinates.minX - 10, coordinates.minY, w + 20, h + 5);
eyeLine(canvas, coordinates.minX - 10, coordinates.minY - 5, w + 20, h + 10);
break;
case "2":
eyeLine(canvas, coordinates.minX - 10, coordinates.minY, w + 20, h);
mosaic(canvas, coordinates.minX - 10, coordinates.minY - 5, w + 20, h + 10);
break;
default:
break;
}
}

const eyeLine = (canvas, sx, sy, cw, ch) => {
const ctx = canvas.getContext('2d');
const imageData = ctx.getImageData(sx, sy, cw, ch);
const data = imageData.data;

for(let i = 0; i < data.length; i += 4) {
data[i] = 0;
data[i + 1] = 0;
data[i + 2] = 0;
}

ctx.putImageData(imageData, sx, sy);
}

const mosaic = (canvas, sx, sy, cw, ch) => {
const size = 16;
const ctx = canvas.getContext('2d');
@@ -549,20 +563,6 @@ document.addEventListener('DOMContentLoaded', () => {
ctx.putImageData(imageData, sx, sy);
}

const eyeLine = (canvas, sx, sy, cw, ch) => {
const ctx = canvas.getContext('2d');
const imageData = ctx.getImageData(sx, sy, cw, ch);
const data = imageData.data;

for(let i = 0; i < data.length; i += 4) {
data[i] = 0;
data[i + 1] = 0;
data[i + 2] = 0;
}

ctx.putImageData(imageData, sx, sy);
}

const adjustFaceCanvasPosition = () => {
faceCanvas.style.top = calcPositionTop(imgCanvas, faceCanvas, facePositionIsTop()) + 'px';
faceCanvas.style.left = calcPositionLeft(imgCanvas, faceCanvas, facePositionIsRight()) + 'px';
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.