Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shakiba committed Apr 30, 2024
1 parent 0d3ed40 commit 696a12e
Show file tree
Hide file tree
Showing 46 changed files with 13,317 additions and 750 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ yarn-error.log*

# testing
/coverage
/.nyc_output

# production
build

# next.js
.next/
# out/

# vercel
.vercel

# ide
.idea/
Expand Down
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
- rewrite with typescript
- change package type to module
- all classes are exported under Stage namespace
- Stage is not callable
- Stage is not callable, and is not a class anymore
- removed Stage.app(callback)
- added Stage.mount() to create a new app
- added await Stage.atlas({ }) to preload images
- added Component class as the base class
- removed Stage.internal namespace
- removed cordova/fastcontext loader and build
- removed script loader `preload(url)`
Expand All @@ -15,8 +16,8 @@
- removed \_create, \_extend
- renamed Image/image to Sprite/sprite, and sprite.image() to sprite.texture()
- renamed Str/string to Monotype/monotype
- renamed node.sequence() to node.align()
- renamed create()/layer()/box() to layout()/maximize()/minimize()
- renamed create()/layer()/box() to component()/maximize()/minimize()
- renamed component.sequence() to component.align()
- replaced Stage.Math with Stage.math with different function names
- removed Matrix.reverse (use inverse)
- renamed Mouse to Pointer and made it internal
Expand Down
91 changes: 6 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,18 @@
[![Stage](https://s3.amazonaws.com/piqnt.com/stage.js/stage.png)](http://piqnt.com/stage.js/)

Stage.js is a 2D rendering and layout library for HTML5 Canvas. It is lightweight, fast and optimized for web and mobile game development.
Stage.js is a lightweight and fast 2D rendering and layout library for web and mobile game development.

Stage.js provides an API similar to DOM to create and animate optimized graphics on HTM5 2D Canvas.
Stage.js provides an intuitive API to create interactive graphics on HTM5 2D Canvas.

### Features

- Optimized rendering loop
- Texture atlas, sprites, and image preloading
- Pointer events processing, and routing events to target elements
- Positioning and layout
- Pointer events processing, and routing events to target components

[**Live Examples and Demos**](http://piqnt.com/stage.js/)
---

### Example
[**Documentations**](http://piqnt.com/stage.js/docs/)

```js
// Define and preload a texture
await Stage.atlas({
image: "sample.png",
textures: {
box: { x: 0, y: 0, width: 30, height: 30 },
},
});

// Create and mount a new app
const app = Stage.mount();

// Set view box
app.viewbox(300, 200);

// Create an sprite and append it to app
const box = Stage.sprite("box").appendTo(app);

// Align box to center
box.pin("align", 0.5);

// On click...
box.on("click", function (point) {
// ...tween scale values of this node
this.tween()
.ease("bounce")
.pin({
scaleX: Math.random() + 0.5,
scaleY: Math.random() + 0.5,
});
});
```

## Install

#### Browser

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script>
const app = Stage.mount();
</script>
```

#### NPM

```
npm install --save stage-js
```

```js
const Stage = require("stage-js");
```

```js
import Stage from "stage-js";
```

## v1.0 [Work in Progress] Migration

There are some backward incompatible changes in v1.0, most notably:

- The code is rewritten in TypeScript, and the package type is changed to "module"
- `Stage` now is a namespace, it is not a class or callable function anymore
- The API for starting an application and preloading textures is changed

Please see the [upgrade](./docs/Migration.md) doc for more information.

## Development

To try examples with a live build run the following command and check the output for the URL to open in your browser:

```
npm run dev
```

## License

Copyright 2024 Ali Shakiba
Available under the MIT License
[**Examples & Demos**](http://piqnt.com/stage.js/)
Loading

0 comments on commit 696a12e

Please sign in to comment.