Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prozi/pixi-shim
PIXI.js Back-End "shim". For mocking Canvas in Node.js with ❤️
https://github.com/prozi/pixi-shim
canvas pixi pixi-shim pixijs singleton
Last synced: 17 days ago
JSON representation
PIXI.js Back-End "shim". For mocking Canvas in Node.js with ❤️
- Host: GitHub
- URL: https://github.com/prozi/pixi-shim
- Owner: Prozi
- Created: 2018-01-09T22:59:05.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T20:08:40.000Z (6 months ago)
- Last Synced: 2024-05-22T01:16:47.901Z (6 months ago)
- Topics: canvas, pixi, pixi-shim, pixijs, singleton
- Language: JavaScript
- Homepage: https://pietal.dev
- Size: 714 KB
- Stars: 44
- Watchers: 4
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
PIXI-SHIM
PIXI.js Back-End "shim". For mocking Canvas in Node.js with ??????## Purpouse
1. Designed for node - it makes you run universal javascript code that is designed with pixi.js on node.js environment
2. It is very lazy - meaning it won't load anything twice and won't attempt to load it if it's not required
3. It wont even load itself twice - while including multiple instances of pixi.js can cause `Cannot redefine property isJson` Error
## Lazy loading
with lazy polyfill of
- DOM
- Window
- Canvas
- PIXI
- other polyfills (requestAnimationFrame, etc.)## Usage
```js
require("pixi-shim");
```## Usage if your game/app is feature-heavy:
and it still doesn't work, you might need to
```bash
$ yarn add pixi.js-legacy
```and then do
```js
require("pixi-shim");
require("pixi.js-legacy");
```## Installation
```bash
$ yarn add pixi-shim
```## DEBUG
environment flag DEBUG enables DEBUG with progress on which polyfill have been loaded
```bash
$ DEBUG=pixi-shim node -r pixi-shim yourscript.js
```## Canvas.toDataURL()
a bit hackish but works, see:
- https://github.com/Prozi/pixi-shim/blob/master/pixi.spec.js
- https://github.com/Prozi/pixi-shim/blob/master/to-data-url.js## Tests
```
Total test suites: 2
Passed test suites: 2
Done in 4.35s.
ites: 0Total tests: 10
Passed tests: 10
Failed tests: 0Test Suite - /home/pietal/projects/pixi-shim/index.spec.js
passed - GIVEN pixi-shim THEN requiring it doesnt throw error
passed - GIVEN pixi-shim THEN new PIXI.Application doesnt throw error
passed - GIVEN pixi-shim THEN new PIXI.Sprite from base64 image does *not* work
passed - GIVEN pixi-shim THEN toDataURL does *not* yet work
passed - GIVEN pixi-shim THEN normal PIXI gameLoop worksTest Suite - /home/pietal/projects/pixi-shim/pixi.spec.js
passed - GIVEN pixi-shim/pixi THEN requiring it doesnt throw error
passed - GIVEN pixi-shim/pixi THEN new PIXI.Application doesnt throw error
passed - GIVEN pixi-shim/pixi THEN new PIXI.Sprite from base64 image *should* work
passed - GIVEN pixi-shim/pixi THEN toDataURL *should* work with pixi.js
passed - GIVEN pixi-shim/pixi THEN normal PIXI gameLoop works
```https://app.circleci.com/pipelines/github/Prozi/pixi-shim
## License
MIT
## You can buy me a coffee
https://paypal.me/jacekpietal