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

@yzfe/lib-poster-build

v0.0.2

Published

使用海报编辑器生成图片

Downloads

5

Readme

lib-poster-build

使用海报编辑器生成图片

注:这是内部项目,且使用服务端渲染,不排除后续不对外提供服务。

安装

yarn add @yzfe/lib-poster-build

使用

import buildBase64, {
    Poster,
    Node,
    measureText,
    getTextHeight,
    setLinearGradientWWithAngle
} from '@yzfe/lib-poster-build'

// 计算文本信息,自定义字体要确保先加载
const textInfo = measureText('文本', 24, `"PingFang SC"`)
console.log(textInfo.width)

// 计算自动换行的文本高度,需要设置最大宽度, 自定义字体要确保先加载
const height = getTextHeight({
    text: '超长文本',
    maxWidth: 200,
    fontSize: 24,
    lineHeight: 1.5,
    fontName: 'SourceHanSerifCNBold'
})
console.log(height)

// 设置线性渐变,不需要设置 startPoint, endPoint, 自动根据 angle 计算
const node: Node = {
    type: 'text',
    config: {
        text: '文本'
        width: 100,
        height: 100
    }
}
setLinearGradientWWithAngle(node, {
    angle: 180,
    fillPriority: 'linear-gradient',
    fillLinearGradientColorStops: [0, '#ff8700', 1, '#ff3a6f']
})

const json = {
    "width": 750,
    "height": 1334,
    "uuid": "kovanEditor-0",
    "nodes": [
        {
            "type": "rect",
            "config": {
                "shadowBlur": 20,
                "shadowColor": "#c4c4c4",
                "isBackground": true,
                "fill": "#ffffff",
                "width": 750,
                "height": 1334
            }
        },
        {
            "type": "text",
            "config": {
                "fontFamily": "SourceHanSerifCNBold",
                "fill": "#6A3815",
                "fontSize": 36,
                "ellipsis": true,
                "text": "这是商品名称这是商品名称这是商品",
                "x": 79.66709212776482,
                "y": 577.8783783783784,
                "height": 43
            }
        },
        {
            "type": "image",
            "config": {
                "x": 78.47790293857588,
                "y": 243.87837837837844,
                "imageClip": "left-top",
                "image": "https://lite-static.meimeifa.com/FqF--BfRKTtEtsd98uGBb5Lg-Mrs"
            }
        },
    ]
} as Poster

buildBase64(json).then(url => console.log(url))