SpriteJS
A cross platform high-performance graphics system.
README
spritejs.com
Spritejs is a cross platform high-performance graphics system, which can render graphics on web, node, desktop applications and mini-programs.
Manipulate the sprites in canvas as you do with the DOM elements.
Features
- Manipulate the sprites element as you do with the DOM elements.
- Rendering by WebGL2 context.
- Multiple layers.
- DOM Events.
- Object Oriented Programmed Development with ES6+.
- OffscreenCanvas and Web Worker.
- Work with d3.
- Vue.
Quick Start
SpriteJS - spritejs.com
- ``` html
- <script src="https://unpkg.com/spritejs@3/dist/spritejs.min.js"></script>
- <div id="container" style="width:400px;height:400px"></div>
- <script>
- const imgUrl = 'https://s5.ssl.qhres2.com/static/ec9f373a383d7664.svg'
- const {Scene, Sprite} = spritejs;
- const container = document.getElementById('container');
- const paper = new Scene({
- container,
- width: 400,
- height: 400,
- })
- const sprite = new Sprite(imgUrl)
- sprite.attr({
- bgcolor: '#fff',
- pos: [0, 0],
- size: [400, 400],
- borderRadius: '200'
- })
- paper.layer().appendChild(sprite)
- </script>
- ```
Learn more at spritejs.com
Usage
In browser:
- ``` html
- <script src="https://unpkg.com/spritejs@3/dist/spritejs.min.js"></script>
- ```
With Node.js:
- ``` sh
- npm install spritejs --save
- ```
- ``` js
- import * as spritejs from 'spritejs';
- ```
3D
- ``` html
- <script src="https://unpkg.com/spritejs@3/dist/spritejs.es.min.js"></script>
- <script src="https://unpkg.com/sprite-extend-3d/dist/sprite-extend-3d.js"></script>
- ```
Or from NPM
- ``` js
- import {Scene} from 'spritejs';
- import {Cube, shaders} from 'sprite-extend-3d';
- ```
Examples
Basic
- Overview
- Sprites
- Labels
- Button
- Events
- Filters
With D3
Compatible with d3.js.
- Map
3D Extension
- 3D Cube
- Camera
- Cube Map
- Geometry
- Groups
- Skydom
- Video
- Shadow
- GPGPU
A visulization library based on spritejs.
- Lines
<!-- ### With Proton
Proton is a lightweight and powerful javascript particle engine.
- Big Fire
With Matter-js
Matter.js) is a JavaScript 2D rigid body physics engine.
-->
Ecosystem & Extensions
**Project** | **Description** |
---|---|
------------------------------- | ----------------------------------- |
[sprite-vue](https://github.com/spritejs/sprite-vue)| | |
[sprite-react](https://github.com/spritejs/sprite-react)| | |
[q-charts](https://github.com/spritejs/q-charts) | A |
[cat-charts-vue](https://github.com/spritejs/cat-charts-vue)| |
Architecture
Build
Build with NPM
- ``` sh
- npm run build
- ```
Build Doc
- ``` sh
- npm run build-doc
- ```
Tests
- ``` sh
- npm test
- ```
V2
Compatibility
Compatible for most modern browsers.
You should import babel-polyfill for early browers(i.e. iOS 8).
Contributors
Thanks goes to these wonderful people (emoji key):
| | | | | | | |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [betseyliu](https://github.com/betseyliu)
[💻](https://github.com/spritejs/spritejs/commits?author=betseyliu "Code") [📖](https://github.com/spritejs/spritejs/commits?author=betseyliu "Documentation") | [
Shero0311](https://github.com/Shero0311)
[📖](https://github.com/spritejs/spritejs/commits?author=Shero0311 "Documentation") | [
有马](https://github.com/makeco)
[📖](https://github.com/spritejs/spritejs/commits?author=makeco "Documentation") [💻](https://github.com/spritejs/spritejs/commit/e2ef39bafd81ee09494f5ebbaf0f8319dbd85122 "Code")| [
文蔺](https://github.com/AngusFu)
[💻](https://github.com/spritejs/spritejs/commits?author=AngusFu "Code") [🐛](https://github.com/spritejs/spritejs/issues/30 "Bug reports") | [
蔡斯杰](https://github.com/SijieCai)
[💻](https://github.com/spritejs/sprite-core/commits?author=SijieCai "Code") [📖](https://github.com/spritejs/spritejs/commits?author=SijieCai "Documentation") | [
Shaofei Cheng](https://github.com/wintercn)
[💻](https://github.com/spritejs/sprite-core/commits?author=wintercn "Code") [📖](https://github.com/spritejs/spritejs/commits?author=wintercn "Documentation") | [
摇太阳](https://github.com/yaotaiyang)
[📖](https://github.com/spritejs/spritejs/commits?author=yaotaiyang "Documentation") | [
公子](https://github.com/lizheming)
[💻](https://github.com/spritejs/sprite-core/commits?author=lizheming "Code") | [
justemit](https://github.com/justemit)
[💻](https://github.com/spritejs/sprite-extend-shapes/commits?author=justemit "Code") [📖](https://github.com/spritejs/sprite-extend-shapes/commits?author=justemit "Documentation") [🐛](https://github.com/spritejs/sprite-core/issues/34 "Bug reports") | [
Welefen Lee](https://github.com/welefen)
[💻](https://github.com/spritejs/sprite-flex-layout "Code") | [
YUPENG12138](https://github.com/YUPENG12138)
[📖](https://github.com/spritejs/spritejs/issues/52 "Documentation")| [
xinde](https://github.com/xinde)
[🐛](https://github.com/spritejs/spritejs/issues/59 "Bug reports")| [
ggvswild](https://github.com/ggvswild)
[🐛](https://github.com/spritejs/spritejs/issues/70 "Bug reports")| [
liulinboyi](https://github.com/liulinboyi)
[💻](https://github.com/spritejs/spritejs/commits?author=liulinboyi "Code")|| [
Lulzx](https://github.com/Lulzx)
[💻](https://github.com/spritejs/sprite-core/commits?author=Lulzx "Code") | [
asidar](https://github.com/asidar)
[💻](https://github.com/spritejs/sprite-extend-shapes/commits?author=asidar "Code") | [
alphatr](https://github.com/alphatr)
[💻](https://github.com/spritejs/sprite-extend-shapes/commits?author=alphatr "Code") | [
W-Qing](https://github.com/W-Qing)
[📖](https://github.com/spritejs/spritejs/commits?author=W-Qing "Documentation") |
Credits and Acknowledgements
- svg-path-contours Approximates an SVG path into a discrete list of 2D contours (polylines).
- extrude-polyline Extrudes a 2D polyline with a given line thickness and the desired join/cap types.
- triangulate-contours Triangulates a series of contours using Tess2.js.
- OGL OGL is a small, effective WebGL library aimed at developers who like minimal layers of abstraction, and are comfortable creating their own shaders.