Socket
Socket
Sign inDemoInstall

mp-painter

Package Overview
Dependencies
0
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mp-painter

A declarative canvas lib using with mini-program, espacially with uniapp.


Version published
Weekly downloads
12
increased by9.09%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

mp-painter

npm size build & deploy demo

  • 声明式地创建适用于 uniapp 和原生微信小程序的 canvas 海报
  • 目前对微信、支付宝、百度端做了兼容处理,其它端还未调试过
  • 支持 text / rect / line / text-block / image 等对象绘制
  • 支持基于文字宽度的多行文本换行,lineClamp 控制
  • 基于 typescript 的友好代码提示
  • 支持水平、垂直排列布局和绝对定位
  • 会自动将支付宝的绘制尺寸放大两倍,解决其绘制模糊的问题
  • 支持原生微信小程序使用,见 wiki

安装

npm install mp-painter --save

Hello World

<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",
    fontSize: 60, // = 60rpx
    content: "Hello World" //绘制的文本
});

FAQs

Last updated on 05 Jul 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc