-
Notifications
You must be signed in to change notification settings - Fork 7
Home
xlfsummer edited this page May 18, 2020
·
7 revisions
- 声明式地创建适用于 uniapp 的 canvas 海报
- 支持 text / rect / line / text-block / image 等对象绘制
- 支持基于文字宽度的多行文本换行,lineClamp 控制
- 基于 typescript 的友好代码提示
- 支持水平、垂直排列布局和绝对定位
- 会自动将支付宝的绘制尺寸放大两倍,解决其绘制模糊的问题
- 支持
transform及clip - 支持在原生微信小程序中使用,请参考微信小程序中使用npm包
- 目前针对微信、支付宝、百度端做了兼容处理,其它端还未调试,有需要可以在 issue 里反馈
npm install mp-painter --save
<template>
<canvas canvas-id="canvas"></canvas>
</template>import Painter from "mp-painter";
// onReady 中
let painter = new Painter(uni.createCanvasContext("canvas"));
await painter.draw({
type: "text", // 绘制文本元素
color: "#fcc", // 文本颜色为 #fcc
fontSize: 60, // 文字字号为 60rpx
content: "Hello World" // 绘制的文本内容
});