Add runtime text shadow support

This commit is contained in:
gem
2026-06-09 11:49:24 +08:00
parent 8d2c97269a
commit 5e6a4877f4
12 changed files with 167 additions and 0 deletions

View File

@@ -138,6 +138,31 @@ void main() {
);
});
test('applies text shadow style', () {
final component = RuntimeComponent(
node: const RuntimeNode(
id: 'text',
type: RuntimeNodeType.text,
text: 'Shadowed',
alpha: 0.5,
textShadowColor: Color(0x80000000),
textShadowOffsetX: 2,
textShadowOffsetY: 3,
textShadowBlur: 4,
),
resources: GameResourceManager(),
onNodeTap: (_, __) {},
);
final text = component.children.whereType<TextComponent>().single;
final style = (text.textRenderer as TextPaint).style;
final shadow = style.shadows!.single;
expect(shadow.color.a, closeTo(0.25, 0.003));
expect(shadow.offset.dx, 2);
expect(shadow.offset.dy, 3);
expect(shadow.blurRadius, 4);
});
test('multi-line non-button text is top aligned', () {
final component = RuntimeComponent(
node: const RuntimeNode(