Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mp-painter

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mp-painter

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

  • 0.2.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

mp-painter

npm size build & deploy demo

  • 声明式地创建适用于 uniapp 和原生微信小程序的 canvas 海报
  • 目前对H5、微信、支付宝、百度端做了兼容处理,其它端还未调试过
  • 支持 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" //绘制的文本
});

示例&文档

  • 文档请查看 wiki
  • 示例请查看 在线 DEMODEMO 源码
    也可通过手机扫描下方二维码进入 DEMO
    DEMO站点二维码
  • 推荐通过查看在线 DEMO 站点与对应 DEMO 源码的方式理解和学习本插件

FAQs

Package last updated on 31 Dec 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc