/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
tests/visual/scenes/text-split/text-alignment-split.scene.ts
54 строки
2 KB
Zyie
feat: Improves text rendering and layout handling (#11947)
09 мар 2026, 17:47
Не верифицирован
09 мар 2026, 17:47
c450e9a
Код
Авторство
О чём код?
import { Assets } from '~/assets'; import { Graphics, SplitText, Text } from '~/scene'; import type { TestScene } from '../../types'; import type { Container } from '~/scene'; export const scene: TestScene = { it: 'should render text alignment with split text correctly', options: { width: 800, }, create: async (scene: Container) => { await Assets.load('fonts/outfit.woff2'); const alignments = ['left', 'center', 'right', 'justify'] as const; const columnWidth = 200; const textWidth = 160; const padding = (columnWidth - textWidth) / 2; alignments.forEach((align, i) => { const x = (i * columnWidth) + padding; const graphics = new Graphics(); graphics.setStrokeStyle({ width: 1, color: 0xcccccc }); graphics.moveTo(x, 0); graphics.lineTo(x, 200); graphics.moveTo(x + textWidth, 0); graphics.lineTo(x + textWidth, 200); graphics.stroke(); scene.addChild(graphics); const text = new Text({ text: 'Hello world test alignment test alignment', style: { fontFamily: 'Outfit', fontSize: 24, fill: 'black', align, wordWrap: true, wordWrapWidth: textWidth, }, }); const splitResult = SplitText.from(text); splitResult.x = x; splitResult.y = 10; scene.addChild(splitResult); }); }, };