tiny-canvas
TypeScript icon, indicating that this package has built-in type declarations

0.0.17 • Public • Published

tiny-canavs

tiny-canvas is a simple HTML canvas library for TypeScript/JavaScript.

Installation

yarn add tiny-canvas
# or
npm install tiny-canvas

Usage

Simple usage(Draw circle at cursor position).

import {
  TinyGame,
  CanvasRenderer,
  AnimationFrameRequestTicker,
  CanvasInputManager
} from 'tiny-canvas'

// Game class that extends TinyGame class
export class Game extends TinyGame {
  constructor(canvas: HTMLCanvasElement) {
    // TinyGame constructor (Renderer, InputManager, Ticker)
    super(
      new CanvasRenderer(canvas),
      new CanvasInputManager(canvas),
      new AnimationFrameRequestTicker()
    )
  }

  /**
   * Call on frame.
   */
  onFrame() {
    // Fill background.
    this.fillRect(this.leftTop, this.rightBottom, 'black')

    // Draw circle at cursor position.
    this.fillCircle(this.cursor, 32, 'white')
  }
}

Build

Build yarn build Watch build yarn dev

Readme

Keywords

none

Package Sidebar

Install

npm i tiny-canvas

Weekly Downloads

0

Version

0.0.17

License

MIT

Unpacked Size

158 kB

Total Files

130

Last publish

Collaborators

  • hota1024