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

jpaths

v0.0.11

Published

JS and HTML alternate javascript template

Downloads

13

Readme

jpaths(#€)

Build Status NPM version

概述

jpaths 是一个简单绘图类库,兼容 svg、canvas 和 vml。

jpaths 可以说是一个只支持 path 元素简版的 Raphaël

如果项目只需要绘制路径,可以选择 jpaths。

支持的格式

  • M - moveto
  • L - lineto
  • C - curveto
  • Z - closepath

使用方法

安装

  • npm $npm install jpaths
  • bower $bower install jpaths

API

创建 jpaths 实例

/**
* 创建矢量路径类
* @param {Object} options 配置
 *  @field {String|Element} parent 容器,如果是字符串,则当 id 检索对应元素
 *  @field {String} fill 填充色
 *  @field {Number} fillOpacity 填充透明度
 *  @field {String} stroke 描边色
 *  @field {Number} strokeOpacity 描边透明度
 *  @field {Number} strokeWidth 描边宽度
 *  @field {String} path 路径
 */
jpaths.create = function(options) { ... }

释放 jpaths 实例

/**
 * 释放资源
 */
Path.prototype.free = function() { ... }

操作 jpaths 属性

/**
 * 设置属性
 * @param {String} name 属性名
 * @param {String} value 属性值
 */
Path.prototype.attr = function(name, value) { ... }

/**
 * 批量设置属性
 * @param {Object} values 属性列表
 */
Path.prototype.attr = function(name, value) { ... }

/**
 * 获取属性
 * @param {String} name 属性名
 */
Path.prototype.attr = function(name) { ... }

示例

void function() {
  var pathBase = jpaths.create({
    parent: 'canvas'
  });

  JSONEditor.defaults.options.theme = 'bootstrap2';
  var editor = new JSONEditor(
    document.getElementById('editor_holder'),
    {
      schema: {
        type: 'object',
        properties: {
          path: {
            title: '路径',
            type: 'string',
            format: 'text',
            default: 'M10,10 L210,10 L210,210 L10,210 Z'
          },
          stroke: {
            title: '边线颜色',
            type: 'string',
            default: '#ff0000',
            format: 'color'
          },
          'stroke-opacity': {
            title: '边线透明度',
            type: 'integer',
            default: 1,
            minimum: 0,
            maximum: 1
          },
          'stroke-width': {
            title: '边线宽度',
            type: 'integer',
            default: 1,
          },
          fill: {
            title: '填充颜色',
            type: 'string',
            default: '#00ff00',
            format: 'color'
          },
          'fill-opacity': {
            title: '填充透明',
            type: 'number',
            default: 1,
            minimum: 0,
            maximum: 1
          }
        }
      }
    }
  );

  editor.on("change",  function() {
    pathBase.attr(editor.getValue());
  });
}();

参考效果

参考文档