# @netless/canvas-polyfill

> a polyfill for canvas getTransform, ellipse, resetTransform API

Latest version **0.0.4** (published 2020-09-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @netless/canvas-polyfill
pnpm add @netless/canvas-polyfill
yarn add @netless/canvas-polyfill
bun add @netless/canvas-polyfill
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2020-09-24 |
| First published | 2020-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | leavesster |
| Maintainers | herewhite, yleaf, netless-rick |
| Keywords | canvas, polyfill, getTransform |

## Links

- npm: https://www.npmjs.com/package/@netless/canvas-polyfill
- Repository: https://github.com/netless-io/canvas-polyfill
- Homepage: https://github.com/netless-io/canvas-polyfill#readme
- Issues: https://github.com/netless-io/canvas-polyfill/issues
- npm.io page: https://npm.io/package/@netless/canvas-polyfill

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2020-09-24
- 0.0.3 — 2020-06-29
- 0.0.2 — 2020-06-29
- 0.0.1 — 2020-06-29

## README

# @netless/canvas-polyfill

`@netless/canvas-polyfill` is a polyfill for `resetTransform`,`ellipse`,`getTransform`. It is inspired by [canvas-5-polyfill](https://github.com/google/canvas-5-polyfill), [canvas-currentTransform](https://github.com/goessner/canvas-currentTransform/blob/master/currentTransform.js).

This polyfill can work in Android 19 WebView and iOS 10 WKWebView.

## different from these

[canvas-5-polyfill](https://github.com/google/canvas-5-polyfill) implement polyfill for `Path2D` objects and `ellipse()` on `CanvasRenderingContext2D` which doesn't implement `getTransform`. `@netless/canvas-polyfill` doesn't implement `Path2D`, but implement `getTransform`.

[canvas-currentTransform](https://github.com/goessner/canvas-currentTransform/blob/master/currentTransform.js) 's `setTransform` has some problem. `@netless/canvas-polyfill` just fix it and `canvas-currentTransform` not implement `getTransform`. But the `currentTransform` 's `getter` is same as `getTransform`.

## Installation

```shell
yarn install @netless/canvas-polyfill
# or
npm install @netless/canvas-polyfill
```

Use:

```javascript
import "@netless/canvas-polyfill";
```

## Publish

```shell
npm publish --access public
```

## the implement for getTransform

The matrix calculation is just copy from [canvas-currentTransform](https://github.com/goessner/canvas-currentTransform/blob/master/currentTransform.js) for `currentTransform`.  I just fix `setTransform` method which has two forms of parameters:

```ts
interface CanvasTransform {
    setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
    setTransform(transform?: DOMMatrix2DInit): void;
}
```

---
_Source: https://npm.io/package/@netless/canvas-polyfill · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
