{"id":16832661,"url":"https://github.com/zswang/jpaths","last_synced_at":"2026-02-24T07:06:28.716Z","repository":{"id":18539308,"uuid":"21740202","full_name":"zswang/jpaths","owner":"zswang","description":"一个简单绘图库，兼容 svg 和 vml，路径只支持其交集。","archived":false,"fork":false,"pushed_at":"2018-10-10T03:37:53.000Z","size":48,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-28T21:52:27.886Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zswang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-11T14:57:57.000Z","updated_at":"2018-10-09T14:21:28.000Z","dependencies_parsed_at":"2022-08-05T11:15:10.085Z","dependency_job_id":null,"html_url":"https://github.com/zswang/jpaths","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/zswang/jpaths","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zswang%2Fjpaths","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zswang%2Fjpaths/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zswang%2Fjpaths/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zswang%2Fjpaths/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zswang","download_url":"https://codeload.github.com/zswang/jpaths/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zswang%2Fjpaths/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281520722,"owners_count":26515681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T11:49:57.582Z","updated_at":"2025-10-28T21:52:28.508Z","avatar_url":"https://github.com/zswang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"jpaths(#€)\n======\n\n[![Build Status](https://img.shields.io/travis/zswang/jpaths/master.svg)](https://travis-ci.org/zswang/jpaths)\n[![NPM version](https://img.shields.io/npm/v/jpaths.svg)](http://badge.fury.io/js/jpaths)\n\n## 概述\n\njpaths 是一个简单绘图类库，兼容 svg、canvas 和 vml。\n\njpaths 可以说是一个只支持 path 元素简版的 [Raphaël](http://raphaeljs.com/)\n\n如果项目只需要绘制路径，可以选择 jpaths。\n\n## 支持的格式\n\n* M - moveto\n* L - lineto\n* C - curveto\n* Z - closepath\n\n## 使用方法\n\n### 安装\n \n* **npm** `$npm install jpaths`\n* **bower** `$bower install jpaths`\n\n## API\n\n### 创建 `jpaths` 实例\n\n```javascript\n/**\n* 创建矢量路径类\n* @param {Object} options 配置\n *  @field {String|Element} parent 容器，如果是字符串，则当 id 检索对应元素\n *  @field {String} fill 填充色\n *  @field {Number} fillOpacity 填充透明度\n *  @field {String} stroke 描边色\n *  @field {Number} strokeOpacity 描边透明度\n *  @field {Number} strokeWidth 描边宽度\n *  @field {String} path 路径\n */\njpaths.create = function(options) { ... }\n```\n\n### 释放 `jpaths` 实例\n\n```javascript\n/**\n * 释放资源\n */\nPath.prototype.free = function() { ... }\n```\n\n### 操作 `jpaths` 属性\n\n```javascript\n/**\n * 设置属性\n * @param {String} name 属性名\n * @param {String} value 属性值\n */\nPath.prototype.attr = function(name, value) { ... }\n\n/**\n * 批量设置属性\n * @param {Object} values 属性列表\n */\nPath.prototype.attr = function(name, value) { ... }\n\n/**\n * 获取属性\n * @param {String} name 属性名\n */\nPath.prototype.attr = function(name) { ... }\n```\n## 示例\n\n```javascript\nvoid function() {\n  var pathBase = jpaths.create({\n    parent: 'canvas'\n  });\n\n  JSONEditor.defaults.options.theme = 'bootstrap2';\n  var editor = new JSONEditor(\n    document.getElementById('editor_holder'),\n    {\n      schema: {\n        type: 'object',\n        properties: {\n          path: {\n            title: '路径',\n            type: 'string',\n            format: 'text',\n            default: 'M10,10 L210,10 L210,210 L10,210 Z'\n          },\n          stroke: {\n            title: '边线颜色',\n            type: 'string',\n            default: '#ff0000',\n            format: 'color'\n          },\n          'stroke-opacity': {\n            title: '边线透明度',\n            type: 'integer',\n            default: 1,\n            minimum: 0,\n            maximum: 1\n          },\n          'stroke-width': {\n            title: '边线宽度',\n            type: 'integer',\n            default: 1,\n          },\n          fill: {\n            title: '填充颜色',\n            type: 'string',\n            default: '#00ff00',\n            format: 'color'\n          },\n          'fill-opacity': {\n            title: '填充透明',\n            type: 'number',\n            default: 1,\n            minimum: 0,\n            maximum: 1\n          }\n        }\n      }\n    }\n  );\n\n  editor.on(\"change\",  function() {\n    pathBase.attr(editor.getValue());\n  });\n}();\n```\n![参考效果](https://cloud.githubusercontent.com/assets/536587/3569229/cb8c5094-0b3b-11e4-93f9-c11f9ad29a97.png)\n\n## 参考文档\n\n* [SVG 1.1 Path data](http://www.w3.org/TR/SVG/paths.html#PathData)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzswang%2Fjpaths","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzswang%2Fjpaths","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzswang%2Fjpaths/lists"}