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

@heibaiepei/node-poster

v1.0.3

Published

1. 基于node-canvas 开发的服务器端绘制海报插件,通过传递数据的方式来生成图片

Downloads

19

Readme

描述

  1. 基于node-canvas 开发的服务器端绘制海报插件,通过传递数据的方式来生成图片

开发目的

  1. 尝试了用html5 canvas api 绘制海报在多端兼容上绘制复杂一点的图片,存在toDataURL导出来的图片模糊,图片画上去偶尔空白,应用闪退,等问题
  2. 后续扩展需要考虑兼容性问题,很麻烦
  3. 总结以上开发了这个插件

解决的问题

  1. 服务器端生成不用考虑兼容
  2. 生成的速度更快更稳定
  3. 根据常用海报抽象定义了绘画基本图形的api满足了基本的使用
  4. 根据图形定义抽象api方便扩展

示例图片

Image text

目录结构


    |-- index.js  //入口文件    
    |-- package-lock.json  //版本锁文件
    |-- package.json  //版本文件
    |-- README.md  //描述文件
    |-- test      //测试目录
    |   |-- app.js  //测试服务器 | 使用示例文件
    |   |-- config1.js   //测试数据配置文件
    |   |-- config4.js   //测试数据配置文件
    |-- types    //类型定义目录
    |   |-- index.d.ts   //类型定义文件
    |-- cores   //核心代码目录
        |-- drawBlock.js  //绘制矩形api文件
        |-- drawImage.js  //绘制图片api文件
        |-- drawLine.js   //绘制线条api文件
        |-- drawText.js   //绘制文本api文件
        |-- tool.js       //辅助公用函数文件

使用方法

  1. 使用案例在 test/app.js 里

本地调试流程

  1. npm run test //它会启动test/spp.js 服务,
  2. 用网页访问刚才的服务器地址,它会通过导入文件获取config1.js里的数据然后生成海报返回给浏览器