npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mp-painter

v1.0.1

Published

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

Downloads

26

Readme

mp-painter

npm size build & deploy demo

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

代码提示:
代码提示演示

安装

npm install mp-painter --save

# 安装 beta 版
npm install mp-painter@next --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: "#f33",
    fontSize: 60, // = 60rpx
    content: "Hello World" //绘制的文本
});

示例&文档

  • 文档请查看 wiki

  • 示例请查看 在线 DEMODEMO 源码
    也可通过手机扫描下方二维码进入 DEMO
    DEMO站点二维码

  • 交互式体验:将下面的代码复制到 Playground , 运行并查看效果

{
    "type": "text",
    "color": "#f33",
    "fontSize": 60,
    "content": "Hello World"
}
  • 推荐通过查看在线 DEMO 站点与对应 DEMO 源码的方式理解和学习本插件