diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-10-03 22:22:38 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-10-03 22:22:38 +0900 |
| commit | 68053e5ecb355ddf808e7f49692c13f4e60edbfd (patch) | |
| tree | 915bb26f0130b80e114aa9a6f645fdba5a2c10db /public/bluebey-studio/src/faceArt.js | |
| parent | babd8555b9a3c59921748fa11430bfca09f3d2db (diff) | |
public/bluebey-studio: ダリひげを左右半分の画像にして間隔を調整可能に
hige-2-right(ぶるべーから見て右側のダリ髭)を取り込み、左右それぞれに描いて「左右の間隔」で開きを調整できるようにした。ファイル名が -right.png のものは片側(ミラーして2枚描く)として扱う。
全幅だった kaiser.png は kaiser-right.png に置き換えた。
Diffstat (limited to 'public/bluebey-studio/src/faceArt.js')
| -rw-r--r-- | public/bluebey-studio/src/faceArt.js | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/public/bluebey-studio/src/faceArt.js b/public/bluebey-studio/src/faceArt.js index 2e1572a..38df333 100644 --- a/public/bluebey-studio/src/faceArt.js +++ b/public/bluebey-studio/src/faceArt.js @@ -888,13 +888,29 @@ function drawBeard(ctx, spec, lineOnly = false, textures = null) { // A supplied drawing for this kind (assets/beards/<shape>.png) replaces the // built-in strokes. The drawings are trimmed to their ink, so `w` is the // beard's real width; it is centred on the nose and scaled by `size`. - const texture = textures?.[shape]; - if (texture && texture.width) { + const entry = textures?.[shape]; + if (entry?.image) { + const { image, half } = entry; // Slightly wider than the built-in base: a moustache drawn to the same width // as a beard's stroke sat mostly behind the nose. const drawW = w * 1.4; - const dh = (drawW * (texture.height || 1)) / (texture.width || 1); - ctx.drawImage(texture, cx - drawW / 2, cy - dh / 2, drawW, dh); + if (half) { + // One side, mirrored to make the pair. The drawing is the model's own right + // side, which sits in the artwork's left half; `spacing` opens the middle. + const halfW = drawW / 2; + const dh = (halfW * (image.height || 1)) / (image.width || 1); + const gap = clamp(spec.spacing ?? 0, 0, 800); + const y = cy - dh / 2; + ctx.drawImage(image, cx - gap - halfW, y, halfW, dh); + ctx.save(); + ctx.translate(cx + gap, cy); + ctx.scale(-1, 1); + ctx.drawImage(image, 0, -dh / 2, halfW, dh); + ctx.restore(); + return; + } + const dh = (drawW * (image.height || 1)) / (image.width || 1); + ctx.drawImage(image, cx - drawW / 2, cy - dh / 2, drawW, dh); return; } |
