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

taro-weapp-poster

v1.4.4

Published

Taro poster builder

Downloads

51

Readme

taro-weapp-poster

taro-weapp-poster 是一款 taro 小程序海报生成器,采用 taro 内置 createCanvasContext 方法进行 canvas 绘制生成,支持绘制文字/图片

git 地址

https://github.com/Clycheng/taro-weapp-poster

使用说明

  • npm install taro-weapp-poster

  • 样图

import React, { useEffect, useState } from "react";

import { Image } from "@tarojs/components";
import { previewImage } from "@tarojs/taro";

import PosterModal from "taro-weapp-poster";
import { shareBase } from "../../const/index";

const Index = (props) => {
  const [url, setUrl] = useState("");

  return (
    <>
      <Image
        onClick={() =>
          previewImage({
            current: url,
            urls: [url],
          })
        }
        style={{ width: "100vw" }}
        mode="widthFix"
        src={url}
      ></Image>
      <PosterModal
        onRender={(res) => {
          setUrl(res?.tempFilePath ?? "");
        }}
        width="320px"
        height="568px"
        list={[
          {
            type: "text",
            text: "毛鼠",
            fontSize: "16",
            color: "#333",
            X: 90,
            Y: 45,
          },
          {
            type: "text",
            text: "欢迎使用taro-weapp-poster",
            fontSize: "15",
            color: "#333",
            X: 90,
            Y: 70,
          },
          {
            type: "text",
            text: "欢迎使用taro-weapp-poster",
            fontSize: "18",
            color: "#000000",
            X: 40,
            Y: 130,
          },
          {
            type: "text",
            text: "欢迎使用taro-weapp-poster",
            fontSize: "19",
            color: "#d63737",
            X: 40,
            Y: 170,
          },
          {
            type: "text",
            text: "欢迎使用taro-weapp-poster",
            fontSize: "19",
            color: "#6ce919",
            X: 40,
            Y: 200,
          },
          {
            type: "text",
            text: "欢迎使用taro-weapp-poster",
            fontSize: "18",
            color: "#000000",
            X: 40,
            Y: 130,
          },
          {
            type: "text",
            text: "欢迎使用taro-weapp-poster",
            fontSize: "19",
            color: "#d63737",
            X: 40,
            Y: 170,
          },
          {
            type: "text",
            text: "欢迎使用taro-weapp-poster",
            fontSize: "19",
            color: "#6ce919",
            X: 40,
            Y: 200,
          },

          {
            type: "shape",
            shapeType: 1, // 实心圆
            roundY: 100,
            roundX: 100,
            roundR: 100,

            color: "rgba(200,200,200,0.5)",
          },
          {
            type: "shape",
            shapeType: 0, // 矩形
            width: 280,
            height: 300,

            X: 20,
            Y: 100,
            color: "rgba(200,200,200,0.5)",
          },
          {
            type: "shape",
            shapeType: 2, // 圆角矩形
            width: 280,
            height: 300,
            roundR: 50,
            X: 0,
            Y: 200,
            color: "rgba(200,200,200,1)",
          },
          {
            type: "image",
            imgType: 1, // 图片类型,圆形1,矩形0
            urlType: 0, // 2:本地路径 或者网络路径:0 base64 1
            url:
              "https://www.npmjs.com/npm-avatar/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdmF0YXJVUkwiOiJodHRwczovL3MuZ3JhdmF0YXIuY29tL2F2YXRhci85NjgyOTMyZDAyMzFkZmRmOWNlNWE4YmRkMDczNmYxMz9zaXplPTEwMCZkZWZhdWx0PXJldHJvIn0.h3KyzPUeRTxRDRH_Hug7O3SUkfxPL5t_V9iUOqL0_c4",
            roundY: 50,
            roundX: 50,
            roundR: 25,
          },
          {
            type: "image",
            imgType: 0, // 图片类型,圆形1,矩形0
            urlType: 1, // 2:本地路径 或者网络路径:0 base64 1
            url: shareBase,
            width: 100,
            height: 100,
            X: 180,
            Y: 400,
          },
        ]}
      ></PosterModal>
    </>
  );
};
export default Index;

参数

| 参数名 | 是否必传 | 类型 | 默认值 | 说明 | | :--------: | :------: | :------: | :---------------------: | :-----------------------: | | width | 是 | string | 548px | 海报宽度 | | height | 是 | string | 750px | 海报高度 | | opacity | 否 | number | 1 | 海报透明度 | | background | 否 | string | white | 海报背景色 | | list | 否 | array | [] | 海报内容,详见 list | | onRender | 否 | function | (res)=>console.log(res) | 回调 res 返回海报本地路径 |

list

  • 文字绘制

| 参数名 | 是否必传 | 类型 | 默认值 | 说明 | | :------: | :------: | :----: | :----: | :----------------------------: | | type | 否 | string | text | 元素类型 | | text | 否 | string | 文字 | 文字,type 为 text 时生效 | | color | 否 | string | 1 | 文字颜色,type 为 text 时生效 | | fontSize | 否 | number | 12 | 文字大小, type 为 text 时生效 | | X | 否 | array | [] | 坐标 X | | Y | 否 | array | [] | 坐标 Y |

  • 图像绘制(矩形图像)

| 参数名 | 是否必传 | 类型 | 默认值 | 说明 | | :-----: | :------: | :----: | :----: | :-------------------------------------------: | | type | 否 | string | image | 元素类型 | | imgType | 否 | number | 0 | 图片类型:0-矩形 1-圆形 | | urlType | 否 | number | 0 | 图片路径类型:0-网络路径,1-base64 2-本地路径 | | url | 否 | string | | 图片路径 | | width | 否 | number | | 图像宽度 | | height | 否 | number | | 图像高度 | | X | 否 | number | | 坐标 X | | Y | 否 | number | | 坐标 Y |

  • 图像绘制(圆形图像)

| 参数名 | 是否必传 | 类型 | 默认值 | 说明 | | :-----: | :------: | :----: | :----: | :-------------------------------------------: | | type | 否 | string | image | 元素类型 | | imgType | 否 | number | 1 | 图片类型:0-矩形 1-圆形 | | urlType | 否 | number | 0 | 图片路径类型:0-网络路径,1-base64 2-本地路径 | | url | 否 | string | | 图片路径 | | roundX | 否 | number | | 圆心 X 轴坐标 | | roundY | 否 | number | | 圆心 Y 轴左边 | | roundR | 否 | number | | 圆半径 |

  • 矩形绘制(实心)

| 参数名 | 是否必传 | 类型 | 默认值 | 说明 | | :----: | :------: | :----: | :----: | :------: | | type | 否 | string | shape | 元素类型 | | shapeType | 否 | string | 0实心矩形|1实心圆 | 元素类型 | | width | 否 | number | | 宽度 | | height | 否 | number | | 高度 | | color | 否 | string | | 矩形颜色 | | X | 否 | number | | X 轴坐标 | | Y | 否 | number | | Y 轴坐标 |

  • 圆角矩形绘制(实心)

| 参数名 | 是否必传 | 类型 | 默认值 | 说明 | | :----: | :------: | :----: | :----: | :------: | | type | 否 | string | shape | 元素类型 | | shapeType | 否 | string | 0实心矩形/1实心圆 /2圆角矩形| 元素类型 | | width | 否 | number | | 宽度 | | height | 否 | number | | 高度 | | roundR | 否 | number | | 圆半径 | | color | 否 | string | | 矩形颜色 | | X | 否 | number | | X 轴坐标 | | Y | 否 | number | | Y 轴坐标 |

  • 实心圆绘制

| 参数名 | 是否必传 | 类型 | 默认值 | 说明 | | :----: | :------: | :----: | :----: | :------: | | type | 否 | string | shape | 元素类型 | | shapeType | 否 | string | 0实心矩形/1实心圆 | 元素类型 | | roundY | 否 | number | | 圆心Y轴 | | roundX | 否 | number | | 圆心X轴 | | roundR | 否 | number | | 圆半径 | | color | 否 | string | | 颜色 |

版本说明

  • 支持圆形图像绘制

  • 支持 base64 图像地址

  • 修改 urlType 参数 (old:1-本地路径,2-网络路径,3-base64(暂不支持))

  • 支持矩形绘制

  • 支持实心圆绘制(添加shapeType字段)

  • 添加圆角矩形绘制

关于作者

(使用过程如有疑问或改善意见,由衷欢迎咨询)

微信: cxl1249587790 (备注来源)

email: [email protected]