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

@jusfoun-vis/canvas-common

v0.1.1

Published

HTML5 Canvas Common Library.

Downloads

4

Readme

HTML5 Canvas Common Library

Jusfoun Visualization Department.

九次方大数据可视化部。

Pattern/Style Definition 样式定义

Solid Color 纯色

const style1 = '#FFF';
const style2 = 'rgba(0, 0, 0, 0.5)';

Linear Gradient 线性渐变

const style = {
  type: 'linearGradient'
  // Indicate this pattern apply each line individually or global.
  // 指示此样式单独应用于每一行还是整体
  scope: 'global' or 'line'
  x0: 0,
  y0: 0,
  x1: 1,
  y1: 0,
  colorStops: [
    {
      offset: 0,
      color: '#FFF'
    },
    {
      offset: 1,
      color: '#000'
    }
  ]
};

Radial Gradient 放射状/径向渐变

const style = {
  type: 'radialGradient'
  // Indicate this pattern apply each line individually or global.
  // 指示此样式单独应用于每一行还是整体
  scope: 'global' or 'line'
  x0: 0,
  y0: 0,
  r0: 0,
  x1: 1,
  y1: 1,
  r1: 1,
  colorStops: [
    {
      offset: 0,
      color: '#FFF'
    },
    {
      offset: 1,
      color: '#000'
    }
  ]
};

Image Fill 图形填充

const style = {
  type: 'pattern',
  image,
  repetition,
};

Text 文字

renderTextLikeDocument(text, maxWidth, style)

Render text to image with restricted width and styles.

以指定的宽度和样式渲染文本为图形。

import {renderTextLikeDocument} from '@jusfoun-vis/canvas-common';

const style = {
  fontSize : 12,
  fontWeight : 'bold',
  fontFamily : 'Microsoft YaHei',
  // left (default), center, right
  textAlign : 'left',
  lineHeight : 12,
  // unified number or [top, right, bottom, left] or [top/bottom, right/left]
  padding : [0, 0],
  // '#RRGGBB' or 'rgb(R, G, B)' or 'rgba(R, G, B, A)'
  // Notice that 'fillStyle' will override this parameter
  // 注意fillStyle属性会覆盖此属性
  color : '#FFF', 
  // See the section 'Pattern/Style Definition' above.
  // 请查看上面的“样式定义”章节
  fillStyle : {
    type: 'linearGradient',
    scope: 'line',
    x0: 0,
    y0: 0,
    x1: 1,
    y1: 0,
    colorStops: [
      {
        offset: 0,
        color: '#FFF'
      },
      {
        offset: 1,
        color: '#000'
      }
    ]
  },
  strokeWidth : 1,
  // See the section 'Pattern/Style Definition' above.
  // 请查看上面的“样式定义”章节
  strokeStyle : '#CCC',
  shadowColor : '#000',
  shadowBlur : 5,
  shadowOffsetX : 5,
  shadowOffsetY : 5,
  // See the section 'Pattern/Style Definition' above. Support background drawing.
  // 请查看上面的“样式定义”章节,用于添加背景
  backgroundStyle : '#CCC'
};

const image = renderTextLikeDocument('Hello World', 100, style);