Skip to content

Commit 001e48a

Browse files
committed
feat: To add TypeScript support
feat: To add TypeScript support
1 parent f44b1c8 commit 001e48a

File tree

102 files changed

+10668
-3241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+10668
-3241
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ build/docs/
4040
.DS_Store
4141
source/build/
4242
static/
43+
yarn.lock

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,40 @@ import Proton from "proton-engine";
6565
#### OR include in html
6666

6767
```html
68-
<script type="text/javascript" src="js/proton.min.js"></script>
68+
<script type="text/javascript" src="js/proton.web.min.js"></script>
6969
```
7070

7171
## Usage
7272

7373
Proton is very simple to use, a dozen lines of code can create a particle animation.
7474

7575
```javascript
76+
import Proton, {
77+
Emitter,
78+
Rate,
79+
Span,
80+
Radius,
81+
Life,
82+
Velocity,
83+
Color,
84+
Alpha,
85+
CanvasRenderer,
86+
} from "proton-engine";
87+
7688
const proton = new Proton();
77-
const emitter = new Proton.Emitter();
89+
const emitter = new Emitter();
7890

7991
//set Rate
80-
emitter.rate = new Proton.Rate(Proton.getSpan(10, 20), 0.1);
92+
emitter.rate = new Rate(new Span(10, 20), 0.1);
8193

8294
//add Initialize
83-
emitter.addInitialize(new Proton.Radius(1, 12));
84-
emitter.addInitialize(new Proton.Life(2, 4));
85-
emitter.addInitialize(new Proton.Velocity(3, Proton.getSpan(0, 360), "polar"));
95+
emitter.addInitialize(new Radius(1, 12));
96+
emitter.addInitialize(new Life(2, 4));
97+
emitter.addInitialize(new Velocity(3, new Span(0, 360), "polar"));
8698

8799
//add Behaviour
88-
emitter.addBehaviour(new Proton.Color("ff0000", "random"));
89-
emitter.addBehaviour(new Proton.Alpha(1, 0));
100+
emitter.addBehaviour(new Color("ff0000", "random"));
101+
emitter.addBehaviour(new Alpha(1, 0));
90102

91103
//set emitter position
92104
emitter.p.x = canvas.width / 2;
@@ -97,7 +109,7 @@ emitter.emit(5);
97109
proton.addEmitter(emitter);
98110

99111
// add canvas renderer
100-
const renderer = new Proton.CanvasRenderer(canvas);
112+
const renderer = new CanvasRenderer(canvas);
101113
proton.addRenderer(renderer);
102114
```
103115

0 commit comments

Comments
 (0)