Skip to content
hhh edited this page Feb 15, 2020 · 10 revisions

Documentation of canvasom

TOC

Usage

Via npm

To use canvasom as a dependency, execute the following command in your project folder

npm install canvasom

and import the APIs like this:

import { Root } from "canvasom";

const root = new Root();

Via CDN

Or, you can just include one of the following script tag in your HTML file

<!-- via jsdelivr -->
<script type="text/javascript" crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/canvasom@latest/dist/canvasom.umd.min.js"></script>
<!-- via unpkg -->
<script type="text/javascript" crossorigin="anonymous" src="https://unpkg.com/canvasom@latest/dist/canvasom.umd.min.js"></script>

and access the APIs via the COM global like this:

const root = new COM.Root();

Note: remember to replace latest in the script tag with the exact version you are using to avoid breaking your code.

Environment Requirements

canvasom depends on some features like Map and requestAnimationFrame. So, if you want to use canvasom in some older environments that don't support them, remember to include a polyfill lib to fix them.

For instance, include hpolyfill by putting one of the following script tags in your HTML: (It should be put before other script tags.)

<!-- via jsdelivr: -->
<script type="text/javascript" crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/hpolyfill@latest/dist/index.js"></script>
<!-- or via unpkg: -->
<script type="text/javascript" crossorigin="anonymous" src="https://unpkg.com/hpolyfill@latest/dist/index.js"></script>

Getting Started

Documentation of canvasom

Clone this wiki locally