diff options
Diffstat (limited to 'public/bluebey-studio/src/faceArt.js')
| -rw-r--r-- | public/bluebey-studio/src/faceArt.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/public/bluebey-studio/src/faceArt.js b/public/bluebey-studio/src/faceArt.js index 9ed6c83..3eb106f 100644 --- a/public/bluebey-studio/src/faceArt.js +++ b/public/bluebey-studio/src/faceArt.js @@ -1399,12 +1399,27 @@ export function drawEyes(ctx, p) { ctx.restore(); }; + // Where the pupil is looking. Every eye shape shares it: a shut eye's line, a + // 3 or an arch shift with the gaze too, not just the round eyeball. + const eyeTravel = isHeart ? heartTravel * lookMax : travel * lookMax; + let dx = clamp(spec.lookX ?? 0, -1, 1) * eyeTravel; + let dy = -clamp(spec.lookY ?? 0, -1, 1) * eyeTravel; + const dist = Math.hypot(dx, dy); + if (dist > eyeTravel && dist > 0) { + dx = (dx / dist) * eyeTravel; + dy = (dy / dist) * eyeTravel; + } + if (open <= 0.02 || open <= lowerLid + 0.02) { // A shut eye can still be given a white backing (the "白目" switch), which // reads as a line drawn across an eyeball rather than a bare line. This also // catches a lower lid raised past the upper one, which reads as shut too. if (!line && showWhite) fillCircle(ctx, eye.cx, eye.cy, eye.r, white); + // 目線 moves the drawn shape as well, so a shut eye can glance sideways. + ctx.save(); + ctx.translate(dx, dy); drawShutEye(ctx, eye, spec, lineStyle, shapeScale, shapeHalfLimit); + ctx.restore(); // The glasses sit over the shut-eye artwork too, but under the tear below. drawGlasses(ctx, eye, line, style, limits); drawTear(); @@ -1418,15 +1433,6 @@ export function drawEyes(ctx, p) { // iris. While the lid is partly closed the clip is still needed. if (!isHeart || open < 0.999) clipEye(ctx, eye, open, isHeart ? 0 : lowerLid, lidFlat, lidTilt * eye.towardNose); - const eyeTravel = isHeart ? heartTravel * lookMax : travel * lookMax; - let dx = clamp(spec.lookX ?? 0, -1, 1) * eyeTravel; - let dy = -clamp(spec.lookY ?? 0, -1, 1) * eyeTravel; - const dist = Math.hypot(dx, dy); - if (dist > eyeTravel && dist > 0) { - dx = (dx / dist) * eyeTravel; - dy = (dy / dist) * eyeTravel; - } - // The white of the eye (see `showWhite` above). if (!line && showWhite) fillCircle(ctx, eye.cx, eye.cy, eye.r, white); const irisX = eye.cx + dx; |
