/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
tests/visual/scenes/text-split/text-fill-gradient-split.scene.ts
47 строк
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 { type Container, FillGradient, SplitText, Text, type TextureSpace } from '~/scene'; import type { TestScene } from '../../types'; export const scene: TestScene = { it: 'should render text fill with split text correctly', create: async (scene: Container) => { await Assets.load('fonts/outfit.woff2'); const createText = (type: TextureSpace, offsetX: number, offsetY: number, stroke = false) => { const fillGradient = new FillGradient({ end: { x: type === 'local' ? 1 : 60, y: type === 'local' ? 1 : 30 }, colorStops: [ { offset: 0, color: 0xff0000 }, { offset: 0.5, color: 0x00ff00 }, { offset: 1, color: 0x0000ff }, ], textureSpace: type, }); const text = new Text({ text: 'Im fill', style: { fontFamily: 'Outfit', fill: !stroke ? fillGradient : { color: 0xffffff, alpha: 0.5 }, stroke: stroke ? { fill: fillGradient, width: 5 } : undefined, }, y: offsetY, x: offsetX, }); const splitResult = SplitText.from(text); splitResult.position.set(offsetX, offsetY); scene.addChild(splitResult); }; createText('global', 5, 0); createText('local', 5, 32); createText('global', 5, 64, true); createText('local', 5, 96, true); }, };