/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
tests/visual/scenes/text-split/text-bounds-split.scene.ts
65 строк
2 KB
Zyie
chore: reorganizes visual scene tests into logical subdirectories (#11872)
04 фев 2026, 16:38
Не верифицирован
04 фев 2026, 16:38
13d3c27
Код
Авторство
О чём код?
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 with the correct bounds using split text', options: { width: 128, height: 64, }, pixelMatch: 258, create: async (scene: Container) => { await Assets.load('fonts/msdf/pinyon/PinyonScript-Regular.ttf'); const text = new Text({ text: 'aff fi if fl', style: { fontFamily: 'PinyonScript Regular', fontSize: 24, fill: 'red', padding: 25, letterSpacing: 2, }, anchor: { x: 0.5, y: 0.5 }, }); const splitResult = SplitText.from(text); scene.addChild(splitResult); splitResult.position.x = 10 + (splitResult.width / 2); splitResult.position.y = (splitResult.height / 2); const tb = splitResult.getBounds(); const textRect = new Graphics(); textRect.rect(tb.x, tb.y, tb.width, tb.height); textRect.stroke({ width: 2, color: 0xfeeb77 }); scene.addChild(textRect); const text2 = new Text({ text: 'aff fi if fl', style: { fontSize: 24, fill: 'red', fontStyle: 'italic', }, }); const splitResult2 = SplitText.from(text2); scene.addChild(splitResult2); splitResult2.position.x = 10; splitResult2.position.y = tb.height + 5; const tb2 = splitResult2.getBounds(); const textRect2 = new Graphics(); textRect2.rect(tb2.x, tb2.y, tb2.width, tb2.height); textRect2.stroke({ width: 2, color: 0xfeeb77 }); scene.addChild(textRect2); }, };