# @antv/g-mobile-canvas

> A renderer implemented with Canvas2D API in mobile environment

Latest version **1.1.1** (published 2025-12-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @antv/g-mobile-canvas
pnpm add @antv/g-mobile-canvas
yarn add @antv/g-mobile-canvas
bun add @antv/g-mobile-canvas
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2025-12-24 |
| First published | 2022-04-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 8 |
| Unpacked size | 481.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1215 |
| Author | https://github.com/orgs/antvis/people |
| Maintainers | lvisei, freestyle21, soundquiet, elaine.q.10, sturuby, sakuya223, serializedowen, xdzhao, yangzhanmei, wjgogogo, leungwensen, dori, iaaron, yard, simaq, dxq613, intchous, susan_ann, jinke.li, lzxue, army8735, atool, baizn, dengfuping, neoddish, jeffy2012, zqlu, afc163, pomelo-nwu, kopiluwaky, ccnuzindex, panyuqi, bubkoo, zengyue, kasmine, boyu.zlj, l1ud0ngq1, newbyvector, winniexing, chenluli, kn9117, xdddst, semious2020, esora, nadia_liu, bbsqq, mxz96102, openwayne, pearmini, pddpd, yiqianyao, zhanba, cxxxxxn, laixingui.lxg, susiwen8, yanxiong, zeyuwang, rainy25ghz, zhangjunjie-loki, flash1, yisi.wang, dreammy23, biupiubiupiu, basketduck, xuying1027, banxuan, bqxbqxbqx, alex_zjt, duxinyue023, wang1212, leondt1, gaofuhong |
| Keywords | antv, g |

## Links

- npm: https://www.npmjs.com/package/@antv/g-mobile-canvas
- Repository: https://github.com/antvis/g
- Homepage: https://github.com/antvis/g#readme
- Issues: https://github.com/antvis/g/issues
- npm.io page: https://npm.io/package/@antv/g-mobile-canvas

## Dependencies (8)

- [tslib](https://npm.io/package/tslib.md) ^2.5.3
- [@antv/util](https://npm.io/package/@antv/util.md) ^3.3.5
- [@antv/g-lite](https://npm.io/package/@antv/g-lite.md) 2.7.0
- [eventemitter3](https://npm.io/package/eventemitter3.md) ^5.0.1
- [@antv/g-canvas](https://npm.io/package/@antv/g-canvas.md) 2.2.0
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.25.6
- [@antv/g-plugin-gesture](https://npm.io/package/@antv/g-plugin-gesture.md) 2.1.1
- [@antv/g-plugin-dragndrop](https://npm.io/package/@antv/g-plugin-dragndrop.md) 2.1.1

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2025-12-24
- 1.0.46-beta.0 (beta) — 2025-12-15
- 1.0.13-alpha.0 (alpha) — 2024-10-21
- 1.0.12 (next) — 2024-09-29
- 1.1.0 — 2025-12-22
- 1.0.49 — 2025-12-12
- 1.0.48 — 2025-12-10
- 1.0.47 — 2025-10-13
- 1.0.46 — 2025-10-13
- 1.0.45 — 2025-07-30
- 1.0.44 — 2025-07-18
- 1.0.42 — 2025-06-27
- 1.0.41 — 2025-05-30
- 1.0.40 — 2025-05-09
- 1.0.39 — 2025-04-14
- … 208 more at https://npm.io/package/@antv/g-mobile-canvas/versions

## README

# g-mobile-canvas

定义了基于 Canvas2D 的上下文，内置以下插件：

- `ContextRegisterPlugin` 提供小程序环境下的上下文服务
- [canvas-renderer](https://g-next.antv.vision/zh/docs/plugins/canvas-renderer) 使用 Canvas2D API 上下文渲染各种图形
- [canvas-picker](https://g-next.antv.vision/zh/docs/plugins/canvas-picker) 基于 Canvas2D API 实现的拾取
- mobile-interaction 监听移动端环境事件，触发标准 pointer 系列事件

## 使用方式

```js
import { Canvas } from '@antv/g';
import { Renderer， createMobileCanvasElement } from '@antv/g-mobile-canvas';

const renderer = new Renderer();
// use existed context
const canvasElement = createMobileCanvasElement(context);

const canvas = new Canvas({
    canvas: canvasElement,
    renderer,
    //（可选）传入原本 DOM 环境下需要通过 window 获取的属性和方法，例如 dpr、rAF 等
    // @see https://g-next.antv.vision/zh/docs/api/canvas#devicepixelratio
    devicePixelRatio: 2,
    requestAnimationFrame,
    cancelAnimationFrame,
});

// 正常创建图形并添加到画布
```

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