/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
tests/utils/getTexture.ts
26 строк
745 B
Mat Groves
- destroy tiling sprite
08 июн 2023, 20:00
08 июн 2023, 20:00
197de66
Код
Авторство
О чём код?
import { ImageSource } from '../../src/rendering/renderers/shared/texture/sources/ImageSource'; import { Texture } from '../../src/rendering/renderers/shared/texture/Texture'; export function getTexture({ width = 20, height = 20 } = {}) { const canvas = document.createElement('canvas'); canvas.width = width; canvas.height = height; const context = canvas.getContext('2d') as CanvasRenderingContext2D; // fill canvas with white context.fillStyle = '#FFFFFF'; context.fillRect(0, 0, canvas.width, canvas.height); const defaultTexture = new Texture({ source: new ImageSource({ resource: canvas }) }); defaultTexture.label = 'defaultTexture'; return defaultTexture; }