Workers P2: Regie 1 (Agenten, Snapshot ohne Animation, Posen, Leerlauf)

Dazu drawSideBubble in sprites.js: Ottos seitliche Blase braucht das Raster des Kontexts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-18 02:53:59 +00:00
1 parent 1aabbef3ab
commit e69c4355bd
5 files changed
+619 -1

No files matched your search

+32
View File
@@ -138,3 +138,35 @@ test('drawBubble: Text und Maße folgen dem Raster, leerer Text zeichnet nichts,
S.drawBubble(small.ctx, 20, 30, 'Hallo')
assert.ok(Math.max(...small.rects.map((q) => q.x + q.w)) <= 100)
})
test('drawSideBubble: links neben dem Körper, Spitze nach rechts; am linken Rand rechts daneben, Spitze nach links', () => {
const l = makeCtx()
S.drawSideBubble(l.ctx, 'Hallo', { leftX: 100, rightX: 130, y: 10 })
assert.deepEqual(l.texts.map((t) => t.text), ['Hallo'])
assert.ok(Math.max(...l.rects.map((r) => r.x + r.w)) <= 300, 'endet vor der linken Körperkante')
assert.ok(Math.max(...l.rects.map((r) => r.x + r.w)) >= 290, 'Spitze reicht bis an den Körper')
assert.equal(l.rects.length, 4)
const r = makeCtx()
S.drawSideBubble(r.ctx, 'Hallo', { leftX: 10, rightX: 40, y: 10 })
assert.ok(Math.min(...r.rects.map((q) => q.x)) >= 120, 'beginnt hinter der rechten Körperkante')
assert.ok(Math.min(...r.rects.map((q) => q.x)) <= 124, 'Spitze reicht bis an den Körper')
})
test('drawSideBubble: Oberkante bei y, Maße und Schrift folgen dem Raster, rechts in die Bildbreite geklemmt, leer zeichnet nichts', () => {
const a = makeCtx()
S.drawSideBubble(a.ctx, 'Hallo', { leftX: 100, rightX: 130, y: 10 })
const white = a.rects.find((q) => q.fill === S.PAL.w)
assert.deepEqual([white.y, white.h], [30, 22])
assert.match(a.texts[0].font, /12px/)
const b = makeCtx()
S.setGrid(b.ctx, { k: 6 })
S.drawSideBubble(b.ctx, 'Hallo', { leftX: 100, rightX: 130, y: 10 })
assert.match(b.texts[0].font, /24px/)
assert.deepEqual([b.rects.find((q) => q.fill === S.PAL.w).y, b.rects.find((q) => q.fill === S.PAL.w).h], [60, 44])
const small = makeCtx({ width: 120 })
S.drawSideBubble(small.ctx, 'Hallo', { leftX: 10, rightX: 40, y: 10 })
assert.ok(Math.max(...small.rects.map((q) => q.x + q.w)) <= 120)
const e = makeCtx()
S.drawSideBubble(e.ctx, '', { leftX: 100, rightX: 130, y: 10 })
S.drawSideBubble(e.ctx, undefined, { leftX: 100, rightX: 130, y: 10 })
assert.equal(e.rects.length, 0)
})