Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/g-plugin-canvas-path-generator

Package Overview
Dependencies
Maintainers
61
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-plugin-canvas-path-generator - npm Package Compare versions

Comparing version 1.1.11 to 1.1.12

2

dist/index.d.ts

@@ -1,2 +0,2 @@

import { AbstractRendererPlugin } from '@antv/g';
import { AbstractRendererPlugin } from '@antv/g-lite';
export declare class Plugin extends AbstractRendererPlugin {

@@ -3,0 +3,0 @@ name: string;

@@ -1,2 +0,3 @@

import { Syringe, DisplayObject, clamp, Module, Shape, AbstractRendererPlugin } from '@antv/g';
import { Syringe, DisplayObject, Module, Shape, AbstractRendererPlugin } from '@antv/g-lite';
import { __spreadArrays } from 'tslib';

@@ -259,2 +260,128 @@ function _inheritsLoose(subClass, superClass) {

var toString = {}.toString;
var isType = function (value, type) { return toString.call(value) === '[object ' + type + ']'; };
/**
* 是否为函数
* @param {*} fn 对象
* @return {Boolean} 是否函数
*/
var isFunction = (function (value) {
return isType(value, 'Function');
});
var isArray = (function (value) {
return Array.isArray ?
Array.isArray(value) :
isType(value, 'Array');
});
var isObject = (function (value) {
/**
* isObject({}) => true
* isObject([1, 2, 3]) => true
* isObject(Function) => true
* isObject(null) => false
*/
var type = typeof value;
return value !== null && type === 'object' || type === 'function';
});
function each(elements, func) {
if (!elements) {
return;
}
var rst;
if (isArray(elements)) {
for (var i = 0, len = elements.length; i < len; i++) {
rst = func(elements[i], i);
if (rst === false) {
break;
}
}
}
else if (isObject(elements)) {
for (var k in elements) {
if (elements.hasOwnProperty(k)) {
rst = func(elements[k], k);
if (rst === false) {
break;
}
}
}
}
}
var isString = (function (str) {
return isType(str, 'String');
});
var clamp = function (a, min, max) {
if (a < min) {
return min;
}
else if (a > max) {
return max;
}
return a;
};
// @ts-ignore
var values = Object.values ? function (obj) { return Object.values(obj); } : function (obj) {
var result = [];
each(obj, function (value, key) {
if (!(isFunction(obj) && key === 'prototype')) {
result.push(value);
}
});
return result;
};
/**
* _.memoize(calColor);
* _.memoize(calColor, (...args) => args[0]);
* @param f
* @param resolver
*/
var memoize = (function (f, resolver) {
if (!isFunction(f)) {
throw new TypeError('Expected a function');
}
var memoized = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
var key = resolver ? resolver.apply(this, args) : args[0];
var cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = f.apply(this, args);
// 缓存起来
cache.set(key, result);
return result;
};
memoized.cache = new Map();
return memoized;
});
var ctx;
/**
* 计算文本的宽度
*/
memoize(function (text, font) {
if (font === void 0) { font = {}; }
var fontSize = font.fontSize, fontFamily = font.fontFamily, fontWeight = font.fontWeight, fontStyle = font.fontStyle, fontVariant = font.fontVariant;
if (!ctx) {
ctx = document.createElement('canvas').getContext('2d');
}
ctx.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
return ctx.measureText(isString(text) ? text : '').width;
}, function (text, font) {
if (font === void 0) { font = {}; }
return __spreadArrays([text], values(font)).join('');
});
function generatePath$6(context, parsedStyle) {

@@ -261,0 +388,0 @@ var radius = parsedStyle.radius,

@@ -5,3 +5,4 @@ 'use strict';

var g = require('@antv/g');
var gLite = require('@antv/g-lite');
var tslib = require('tslib');

@@ -23,4 +24,4 @@ function _inheritsLoose(subClass, superClass) {

var PathGeneratorFactory = g.Syringe.defineToken('');
var PathGenerator = g.Syringe.defineToken('');
var PathGeneratorFactory = gLite.Syringe.defineToken('');
var PathGenerator = gLite.Syringe.defineToken('');

@@ -72,3 +73,3 @@ function generatePath(context, parsedStyle) {

if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
x = x2 - x1;

@@ -81,3 +82,3 @@ y = y2 - y1;

if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
x = x1 - x2;

@@ -121,3 +122,3 @@ y = y1 - y2;

if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),

@@ -134,3 +135,3 @@ p1 = _markerStart$parentNo[0],

if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),

@@ -194,3 +195,3 @@ _p = _markerEnd$parentNode[0],

if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
x = points[1][0] - points[0][0];

@@ -203,3 +204,3 @@ y = points[1][1] - points[0][1];

if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
x = points[length - 1][0] - points[0][0];

@@ -245,3 +246,3 @@ y = points[length - 1][1] - points[0][1];

if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
x = points[1][0] - points[0][0];

@@ -254,3 +255,3 @@ y = points[1][1] - points[0][1];

if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
x = points[length - 2][0] - points[length - 1][0];

@@ -273,2 +274,128 @@ y = points[length - 2][1] - points[length - 1][1];

var toString = {}.toString;
var isType = function (value, type) { return toString.call(value) === '[object ' + type + ']'; };
/**
* 是否为函数
* @param {*} fn 对象
* @return {Boolean} 是否函数
*/
var isFunction = (function (value) {
return isType(value, 'Function');
});
var isArray = (function (value) {
return Array.isArray ?
Array.isArray(value) :
isType(value, 'Array');
});
var isObject = (function (value) {
/**
* isObject({}) => true
* isObject([1, 2, 3]) => true
* isObject(Function) => true
* isObject(null) => false
*/
var type = typeof value;
return value !== null && type === 'object' || type === 'function';
});
function each(elements, func) {
if (!elements) {
return;
}
var rst;
if (isArray(elements)) {
for (var i = 0, len = elements.length; i < len; i++) {
rst = func(elements[i], i);
if (rst === false) {
break;
}
}
}
else if (isObject(elements)) {
for (var k in elements) {
if (elements.hasOwnProperty(k)) {
rst = func(elements[k], k);
if (rst === false) {
break;
}
}
}
}
}
var isString = (function (str) {
return isType(str, 'String');
});
var clamp = function (a, min, max) {
if (a < min) {
return min;
}
else if (a > max) {
return max;
}
return a;
};
// @ts-ignore
var values = Object.values ? function (obj) { return Object.values(obj); } : function (obj) {
var result = [];
each(obj, function (value, key) {
if (!(isFunction(obj) && key === 'prototype')) {
result.push(value);
}
});
return result;
};
/**
* _.memoize(calColor);
* _.memoize(calColor, (...args) => args[0]);
* @param f
* @param resolver
*/
var memoize = (function (f, resolver) {
if (!isFunction(f)) {
throw new TypeError('Expected a function');
}
var memoized = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
var key = resolver ? resolver.apply(this, args) : args[0];
var cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = f.apply(this, args);
// 缓存起来
cache.set(key, result);
return result;
};
memoized.cache = new Map();
return memoized;
});
var ctx;
/**
* 计算文本的宽度
*/
memoize(function (text, font) {
if (font === void 0) { font = {}; }
var fontSize = font.fontSize, fontFamily = font.fontFamily, fontWeight = font.fontWeight, fontStyle = font.fontStyle, fontVariant = font.fontVariant;
if (!ctx) {
ctx = document.createElement('canvas').getContext('2d');
}
ctx.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
return ctx.measureText(isString(text) ? text : '').width;
}, function (text, font) {
if (font === void 0) { font = {}; }
return tslib.__spreadArrays([text], values(font)).join('');
});
function generatePath$6(context, parsedStyle) {

@@ -293,3 +420,3 @@ var radius = parsedStyle.radius,

var _radius$map = radius.map(function (r) {
return g.clamp(r, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
return clamp(r, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
}),

@@ -328,3 +455,3 @@ tlr = _radius$map[0],

var containerModule = g.Module(function (register) {
var containerModule = gLite.Module(function (register) {
/**

@@ -336,3 +463,3 @@ * register shape renderers

token: PathGenerator,
named: g.Shape.CIRCLE
named: gLite.Shape.CIRCLE
},

@@ -344,3 +471,3 @@ useValue: generatePath

token: PathGenerator,
named: g.Shape.ELLIPSE
named: gLite.Shape.ELLIPSE
},

@@ -352,3 +479,3 @@ useValue: generatePath$1

token: PathGenerator,
named: g.Shape.RECT
named: gLite.Shape.RECT
},

@@ -360,3 +487,3 @@ useValue: generatePath$6

token: PathGenerator,
named: g.Shape.LINE
named: gLite.Shape.LINE
},

@@ -368,3 +495,3 @@ useValue: generatePath$2

token: PathGenerator,
named: g.Shape.POLYLINE
named: gLite.Shape.POLYLINE
},

@@ -376,3 +503,3 @@ useValue: generatePath$5

token: PathGenerator,
named: g.Shape.POLYGON
named: gLite.Shape.POLYGON
},

@@ -384,3 +511,3 @@ useValue: generatePath$4

token: PathGenerator,
named: g.Shape.PATH
named: gLite.Shape.PATH
},

@@ -428,3 +555,3 @@ useValue: generatePath$3

return Plugin;
}(g.AbstractRendererPlugin);
}(gLite.AbstractRendererPlugin);

@@ -431,0 +558,0 @@ exports.PathGenerator = PathGenerator;

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/g')) :
typeof define === 'function' && define.amd ? define(['exports', '@antv/g'], factory) :
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/g-lite')) :
typeof define === 'function' && define.amd ? define(['exports', '@antv/g-lite'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.CanvasPathGenerator = {}), global.window.G));
}(this, (function (exports, g) { 'use strict';
}(this, (function (exports, gLite) { 'use strict';

@@ -22,4 +22,4 @@ function _inheritsLoose(subClass, superClass) {

var PathGeneratorFactory = g.Syringe.defineToken('');
var PathGenerator = g.Syringe.defineToken('');
var PathGeneratorFactory = gLite.Syringe.defineToken('');
var PathGenerator = gLite.Syringe.defineToken('');

@@ -71,3 +71,3 @@ function generatePath(context, parsedStyle) {

if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
x = x2 - x1;

@@ -80,3 +80,3 @@ y = y2 - y1;

if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
x = x1 - x2;

@@ -120,3 +120,3 @@ y = y1 - y2;

if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),

@@ -133,3 +133,3 @@ p1 = _markerStart$parentNo[0],

if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),

@@ -193,3 +193,3 @@ _p = _markerEnd$parentNode[0],

if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
x = points[1][0] - points[0][0];

@@ -202,3 +202,3 @@ y = points[1][1] - points[0][1];

if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
x = points[length - 1][0] - points[0][0];

@@ -244,3 +244,3 @@ y = points[length - 1][1] - points[0][1];

if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
if (markerStart && markerStart instanceof gLite.DisplayObject && markerStartOffset) {
x = points[1][0] - points[0][0];

@@ -253,3 +253,3 @@ y = points[1][1] - points[0][1];

if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
if (markerEnd && markerEnd instanceof gLite.DisplayObject && markerEndOffset) {
x = points[length - 2][0] - points[length - 1][0];

@@ -272,2 +272,152 @@ y = points[length - 2][1] - points[length - 1][1];

var toString = {}.toString;
var isType = function (value, type) { return toString.call(value) === '[object ' + type + ']'; };
/**
* 是否为函数
* @param {*} fn 对象
* @return {Boolean} 是否函数
*/
var isFunction = (function (value) {
return isType(value, 'Function');
});
var isArray = (function (value) {
return Array.isArray ?
Array.isArray(value) :
isType(value, 'Array');
});
var isObject = (function (value) {
/**
* isObject({}) => true
* isObject([1, 2, 3]) => true
* isObject(Function) => true
* isObject(null) => false
*/
var type = typeof value;
return value !== null && type === 'object' || type === 'function';
});
function each(elements, func) {
if (!elements) {
return;
}
var rst;
if (isArray(elements)) {
for (var i = 0, len = elements.length; i < len; i++) {
rst = func(elements[i], i);
if (rst === false) {
break;
}
}
}
else if (isObject(elements)) {
for (var k in elements) {
if (elements.hasOwnProperty(k)) {
rst = func(elements[k], k);
if (rst === false) {
break;
}
}
}
}
}
var isString = (function (str) {
return isType(str, 'String');
});
var clamp = function (a, min, max) {
if (a < min) {
return min;
}
else if (a > max) {
return max;
}
return a;
};
// @ts-ignore
var values = Object.values ? function (obj) { return Object.values(obj); } : function (obj) {
var result = [];
each(obj, function (value, key) {
if (!(isFunction(obj) && key === 'prototype')) {
result.push(value);
}
});
return result;
};
/**
* _.memoize(calColor);
* _.memoize(calColor, (...args) => args[0]);
* @param f
* @param resolver
*/
var memoize = (function (f, resolver) {
if (!isFunction(f)) {
throw new TypeError('Expected a function');
}
var memoized = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
var key = resolver ? resolver.apply(this, args) : args[0];
var cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = f.apply(this, args);
// 缓存起来
cache.set(key, result);
return result;
};
memoized.cache = new Map();
return memoized;
});
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/** @deprecated */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
var ctx;
/**
* 计算文本的宽度
*/
memoize(function (text, font) {
if (font === void 0) { font = {}; }
var fontSize = font.fontSize, fontFamily = font.fontFamily, fontWeight = font.fontWeight, fontStyle = font.fontStyle, fontVariant = font.fontVariant;
if (!ctx) {
ctx = document.createElement('canvas').getContext('2d');
}
ctx.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
return ctx.measureText(isString(text) ? text : '').width;
}, function (text, font) {
if (font === void 0) { font = {}; }
return __spreadArrays([text], values(font)).join('');
});
function generatePath$6(context, parsedStyle) {

@@ -292,3 +442,3 @@ var radius = parsedStyle.radius,

var _radius$map = radius.map(function (r) {
return g.clamp(r, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
return clamp(r, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
}),

@@ -327,3 +477,3 @@ tlr = _radius$map[0],

var containerModule = g.Module(function (register) {
var containerModule = gLite.Module(function (register) {
/**

@@ -335,3 +485,3 @@ * register shape renderers

token: PathGenerator,
named: g.Shape.CIRCLE
named: gLite.Shape.CIRCLE
},

@@ -343,3 +493,3 @@ useValue: generatePath

token: PathGenerator,
named: g.Shape.ELLIPSE
named: gLite.Shape.ELLIPSE
},

@@ -351,3 +501,3 @@ useValue: generatePath$1

token: PathGenerator,
named: g.Shape.RECT
named: gLite.Shape.RECT
},

@@ -359,3 +509,3 @@ useValue: generatePath$6

token: PathGenerator,
named: g.Shape.LINE
named: gLite.Shape.LINE
},

@@ -367,3 +517,3 @@ useValue: generatePath$2

token: PathGenerator,
named: g.Shape.POLYLINE
named: gLite.Shape.POLYLINE
},

@@ -375,3 +525,3 @@ useValue: generatePath$5

token: PathGenerator,
named: g.Shape.POLYGON
named: gLite.Shape.POLYGON
},

@@ -383,3 +533,3 @@ useValue: generatePath$4

token: PathGenerator,
named: g.Shape.PATH
named: gLite.Shape.PATH
},

@@ -427,3 +577,3 @@ useValue: generatePath$3

return Plugin;
}(g.AbstractRendererPlugin);
}(gLite.AbstractRendererPlugin);

@@ -430,0 +580,0 @@ exports.PathGenerator = PathGenerator;

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g")):"function"==typeof define&&define.amd?define(["exports","@antv/g"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.CanvasPathGenerator={}),e.window.G)}(this,(function(e,t){"use strict";function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}var n=t.Syringe.defineToken(""),o=t.Syringe.defineToken("");function r(e,t){var a=t.r;e.arc(a,a,a,0,2*Math.PI,!1)}function i(e,t){var a=t.rx,n=t.ry;if(e.ellipse)e.ellipse(a,n,a,n,0,0,2*Math.PI,!1);else{var o=a>n?a:n,r=a>n?1:a/n,i=a>n?n/a:1;e.save(),e.scale(r,i),e.arc(0,0,o,0,2*Math.PI)}}function s(e,a){var n,o,r=a.x1,i=a.y1,s=a.x2,c=a.y2,f=a.defX,h=void 0===f?0:f,u=a.defY,d=void 0===u?0:u,l=a.markerStart,p=a.markerEnd,v=a.markerStartOffset,M=a.markerEndOffset,m=0,k=0,y=0,P=0,O=0;l&&l instanceof t.DisplayObject&&v&&(n=s-r,o=c-i,O=Math.atan2(o,n),m=Math.cos(O)*(v||0),k=Math.sin(O)*(v||0)),p&&p instanceof t.DisplayObject&&M&&(n=r-s,o=i-c,O=Math.atan2(o,n),y=Math.cos(O)*(M||0),P=Math.sin(O)*(M||0)),e.moveTo(r-h+m,i-d+k),e.lineTo(s-h+y,c-d+P)}function c(e,a){var n=a.defX,o=void 0===n?0:n,r=a.defY,i=void 0===r?0:r,s=a.markerStart,c=a.markerEnd,f=a.markerStartOffset,h=a.markerEndOffset,u=a.path,d=u.zCommandIndexes,l=[].concat(u.curve);d.forEach((function(e,t){l.splice(e+t,1,["Z"])}));var p,v,M=l.length&&"Z"===l[l.length-1][0],m=0,k=0,y=0,P=0,O=0;if(s&&s instanceof t.DisplayObject&&f){var g=s.parentNode.getStartTangent(),T=g[0],b=g[1];p=T[0]-b[0],v=T[1]-b[1],O=Math.atan2(v,p),m=Math.cos(O)*(f||0),k=Math.sin(O)*(f||0)}if(c&&c instanceof t.DisplayObject&&h){var I=c.parentNode.getEndTangent(),S=I[0],E=I[1];p=S[0]-E[0],v=S[1]-E[1],O=Math.atan2(v,p),y=Math.cos(O)*(h||0),P=Math.sin(O)*(h||0)}for(var j=0;l.length>j;j++){var D=l[j];switch(D[0]){case"M":e.moveTo(D[1]-o+m,D[2]-i+k);break;case"C":e.bezierCurveTo(D[1]-o,D[2]-i,D[3]-o,D[4]-i,D[5]-o+(j===l.length-(M?2:1)?y:0),D[6]-i+(j===l.length-(M?2:1)?P:0));break;case"Z":e.closePath()}}}function f(e,a){var n,o,r=a.defX,i=void 0===r?0:r,s=a.defY,c=void 0===s?0:s,f=a.markerStart,h=a.markerEnd,u=a.markerStartOffset,d=a.markerEndOffset,l=a.points.points,p=l.length,v=l[0][0]-i,M=l[0][1]-c,m=l[p-1][0]-i,k=l[p-1][1]-c,y=0,P=0,O=0,g=0,T=0;f&&f instanceof t.DisplayObject&&u&&(n=l[1][0]-l[0][0],o=l[1][1]-l[0][1],T=Math.atan2(o,n),y=Math.cos(T)*(u||0),P=Math.sin(T)*(u||0)),h&&h instanceof t.DisplayObject&&d&&(n=l[p-1][0]-l[0][0],o=l[p-1][1]-l[0][1],T=Math.atan2(o,n),O=Math.cos(T)*(d||0),g=Math.sin(T)*(d||0)),e.moveTo(v+(y||O),M+(P||g));for(var b=1;p-1>b;b++){var I=l[b];e.lineTo(I[0]-i,I[1]-c)}e.lineTo(m,k)}function h(e,a){var n,o,r=a.defX,i=void 0===r?0:r,s=a.defY,c=void 0===s?0:s,f=a.markerStart,h=a.markerEnd,u=a.markerStartOffset,d=a.markerEndOffset,l=a.points.points,p=l.length,v=l[0][0]-i,M=l[0][1]-c,m=l[p-1][0]-i,k=l[p-1][1]-c,y=0,P=0,O=0,g=0,T=0;f&&f instanceof t.DisplayObject&&u&&(n=l[1][0]-l[0][0],o=l[1][1]-l[0][1],T=Math.atan2(o,n),y=Math.cos(T)*(u||0),P=Math.sin(T)*(u||0)),h&&h instanceof t.DisplayObject&&d&&(n=l[p-2][0]-l[p-1][0],o=l[p-2][1]-l[p-1][1],T=Math.atan2(o,n),O=Math.cos(T)*(d||0),g=Math.sin(T)*(d||0)),e.moveTo(v+y,M+P);for(var b=1;p-1>b;b++){var I=l[b];e.lineTo(I[0]-i,I[1]-c)}e.lineTo(m+O,k+g)}function u(e,a){var n=a.radius,o=a.width,r=a.height,i=o,s=r;if(n&&n.some((function(e){return 0!==e}))){var c=o>0?1:-1,f=r>0?1:-1,h=c+f===0,u=n.map((function(e){return t.clamp(e,0,Math.min(Math.abs(i)/2,Math.abs(s)/2))})),d=u[0],l=u[1],p=u[2],v=u[3];e.moveTo(c*d,0),e.lineTo(i-c*l,0),0!==l&&e.arc(i-c*l,f*l,l,-f*Math.PI/2,c>0?0:Math.PI,h),e.lineTo(i,s-f*p),0!==p&&e.arc(i-c*p,s-f*p,p,c>0?0:Math.PI,f>0?Math.PI/2:1.5*Math.PI,h),e.lineTo(c*v,s),0!==v&&e.arc(c*v,s-f*v,v,f>0?Math.PI/2:-Math.PI/2,c>0?Math.PI:0,h),e.lineTo(0,f*d),0!==d&&e.arc(c*d,f*d,d,c>0?Math.PI:0,f>0?1.5*Math.PI:Math.PI/2,h)}else e.rect(0,0,i,s)}var d=t.Module((function(e){e({token:{token:o,named:t.Shape.CIRCLE},useValue:r}),e({token:{token:o,named:t.Shape.ELLIPSE},useValue:i}),e({token:{token:o,named:t.Shape.RECT},useValue:u}),e({token:{token:o,named:t.Shape.LINE},useValue:s}),e({token:{token:o,named:t.Shape.POLYLINE},useValue:h}),e({token:{token:o,named:t.Shape.POLYGON},useValue:f}),e({token:{token:o,named:t.Shape.PATH},useValue:c}),e({token:n,useFactory:function(e){return function(t){return e.container.isBoundNamed(o,t)?e.container.getNamed(o,t):null}}})})),l=function(e){var t,n;function o(){for(var t,a=arguments.length,n=new Array(a),o=0;a>o;o++)n[o]=arguments[o];return(t=e.call.apply(e,[this].concat(n))||this).name="canvas-path-generator",t}n=e,(t=o).prototype=Object.create(n.prototype),t.prototype.constructor=t,a(t,n);var r=o.prototype;return r.init=function(){this.container.load(d,!0)},r.destroy=function(){this.container.unload(d)},o}(t.AbstractRendererPlugin);e.PathGenerator=o,e.PathGeneratorFactory=n,e.Plugin=l,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.CanvasPathGenerator={}),t.window.G)}(this,(function(t,e){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var a=e.Syringe.defineToken(""),r=e.Syringe.defineToken("");function o(t,e){var n=e.r;t.arc(n,n,n,0,2*Math.PI,!1)}function i(t,e){var n=e.rx,a=e.ry;if(t.ellipse)t.ellipse(n,a,n,a,0,0,2*Math.PI,!1);else{var r=n>a?n:a,o=n>a?1:n/a,i=n>a?a/n:1;t.save(),t.scale(o,i),t.arc(0,0,r,0,2*Math.PI)}}function c(t,n){var a,r,o=n.x1,i=n.y1,c=n.x2,f=n.y2,s=n.defX,u=void 0===s?0:s,h=n.defY,l=void 0===h?0:h,d=n.markerStart,v=n.markerEnd,p=n.markerStartOffset,M=n.markerEndOffset,y=0,m=0,k=0,g=0,O=0;d&&d instanceof e.DisplayObject&&p&&(a=c-o,r=f-i,O=Math.atan2(r,a),y=Math.cos(O)*(p||0),m=Math.sin(O)*(p||0)),v&&v instanceof e.DisplayObject&&M&&(a=o-c,r=i-f,O=Math.atan2(r,a),k=Math.cos(O)*(M||0),g=Math.sin(O)*(M||0)),t.moveTo(o-u+y,i-l+m),t.lineTo(c-u+k,f-l+g)}function f(t,n){var a=n.defX,r=void 0===a?0:a,o=n.defY,i=void 0===o?0:o,c=n.markerStart,f=n.markerEnd,s=n.markerStartOffset,u=n.markerEndOffset,h=n.path,l=h.zCommandIndexes,d=[].concat(h.curve);l.forEach((function(t,e){d.splice(t+e,1,["Z"])}));var v,p,M=d.length&&"Z"===d[d.length-1][0],y=0,m=0,k=0,g=0,O=0;if(c&&c instanceof e.DisplayObject&&s){var P=c.parentNode.getStartTangent(),b=P[0],T=P[1];v=b[0]-T[0],p=b[1]-T[1],O=Math.atan2(p,v),y=Math.cos(O)*(s||0),m=Math.sin(O)*(s||0)}if(f&&f instanceof e.DisplayObject&&u){var S=f.parentNode.getEndTangent(),j=S[0],E=S[1];v=j[0]-E[0],p=j[1]-E[1],O=Math.atan2(p,v),k=Math.cos(O)*(u||0),g=Math.sin(O)*(u||0)}for(var I=0;d.length>I;I++){var x=d[I];switch(x[0]){case"M":t.moveTo(x[1]-r+y,x[2]-i+m);break;case"C":t.bezierCurveTo(x[1]-r,x[2]-i,x[3]-r,x[4]-i,x[5]-r+(I===d.length-(M?2:1)?k:0),x[6]-i+(I===d.length-(M?2:1)?g:0));break;case"Z":t.closePath()}}}function s(t,n){var a,r,o=n.defX,i=void 0===o?0:o,c=n.defY,f=void 0===c?0:c,s=n.markerStart,u=n.markerEnd,h=n.markerStartOffset,l=n.markerEndOffset,d=n.points.points,v=d.length,p=d[0][0]-i,M=d[0][1]-f,y=d[v-1][0]-i,m=d[v-1][1]-f,k=0,g=0,O=0,P=0,b=0;s&&s instanceof e.DisplayObject&&h&&(a=d[1][0]-d[0][0],r=d[1][1]-d[0][1],b=Math.atan2(r,a),k=Math.cos(b)*(h||0),g=Math.sin(b)*(h||0)),u&&u instanceof e.DisplayObject&&l&&(a=d[v-1][0]-d[0][0],r=d[v-1][1]-d[0][1],b=Math.atan2(r,a),O=Math.cos(b)*(l||0),P=Math.sin(b)*(l||0)),t.moveTo(p+(k||O),M+(g||P));for(var T=1;v-1>T;T++){var S=d[T];t.lineTo(S[0]-i,S[1]-f)}t.lineTo(y,m)}function u(t,n){var a,r,o=n.defX,i=void 0===o?0:o,c=n.defY,f=void 0===c?0:c,s=n.markerStart,u=n.markerEnd,h=n.markerStartOffset,l=n.markerEndOffset,d=n.points.points,v=d.length,p=d[0][0]-i,M=d[0][1]-f,y=d[v-1][0]-i,m=d[v-1][1]-f,k=0,g=0,O=0,P=0,b=0;s&&s instanceof e.DisplayObject&&h&&(a=d[1][0]-d[0][0],r=d[1][1]-d[0][1],b=Math.atan2(r,a),k=Math.cos(b)*(h||0),g=Math.sin(b)*(h||0)),u&&u instanceof e.DisplayObject&&l&&(a=d[v-2][0]-d[v-1][0],r=d[v-2][1]-d[v-1][1],b=Math.atan2(r,a),O=Math.cos(b)*(l||0),P=Math.sin(b)*(l||0)),t.moveTo(p+k,M+g);for(var T=1;v-1>T;T++){var S=d[T];t.lineTo(S[0]-i,S[1]-f)}t.lineTo(y+O,m+P)}var h={}.toString,l=function(t,e){return h.call(t)==="[object "+e+"]"},d=function(t){return l(t,"Function")};function v(t,e){var n;if(t)if(n=t,Array.isArray?Array.isArray(n):l(n,"Array"))for(var a=0,r=t.length;r>a&&!1!==e(t[a],a);a++);else if(function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e}(t))for(var o in t)if(t.hasOwnProperty(o)&&!1===e(t[o],o))break}var p,M=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return v(t,(function(n,a){d(t)&&"prototype"===a||e.push(n)})),e};function y(t,e){var n=e.radius,a=e.width,r=e.height,o=a,i=r;if(n&&n.some((function(t){return 0!==t}))){var c=a>0?1:-1,f=r>0?1:-1,s=c+f===0,u=n.map((function(t){return e=t,n=0,a=Math.min(Math.abs(o)/2,Math.abs(i)/2),n>e?n:e>a?a:e;var e,n,a})),h=u[0],l=u[1],d=u[2],v=u[3];t.moveTo(c*h,0),t.lineTo(o-c*l,0),0!==l&&t.arc(o-c*l,f*l,l,-f*Math.PI/2,c>0?0:Math.PI,s),t.lineTo(o,i-f*d),0!==d&&t.arc(o-c*d,i-f*d,d,c>0?0:Math.PI,f>0?Math.PI/2:1.5*Math.PI,s),t.lineTo(c*v,i),0!==v&&t.arc(c*v,i-f*v,v,f>0?Math.PI/2:-Math.PI/2,c>0?Math.PI:0,s),t.lineTo(0,f*h),0!==h&&t.arc(c*h,f*h,h,c>0?Math.PI:0,f>0?1.5*Math.PI:Math.PI/2,s)}else t.rect(0,0,o,i)}!function(t,e){if(!d(t))throw new TypeError("Expected a function");var n=function(){for(var a=[],r=0;arguments.length>r;r++)a[r]=arguments[r];var o=e?e.apply(this,a):a[0],i=n.cache;if(i.has(o))return i.get(o);var c=t.apply(this,a);return i.set(o,c),c};n.cache=new Map}((function(t,e){void 0===e&&(e={});var n,a=e.fontSize,r=e.fontFamily,o=e.fontWeight,i=e.fontStyle,c=e.fontVariant;return p||(p=document.createElement("canvas").getContext("2d")),p.font=[i,c,o,a+"px",r].join(" "),p.measureText((n=t,l(n,"String")?t:"")).width}),(function(t,e){return void 0===e&&(e={}),function(){for(var t=0,e=0,n=arguments.length;n>e;e++)t+=arguments[e].length;var a=Array(t),r=0;for(e=0;n>e;e++)for(var o=arguments[e],i=0,c=o.length;c>i;i++,r++)a[r]=o[i];return a}([t],M(e)).join("")}));var m=e.Module((function(t){t({token:{token:r,named:e.Shape.CIRCLE},useValue:o}),t({token:{token:r,named:e.Shape.ELLIPSE},useValue:i}),t({token:{token:r,named:e.Shape.RECT},useValue:y}),t({token:{token:r,named:e.Shape.LINE},useValue:c}),t({token:{token:r,named:e.Shape.POLYLINE},useValue:u}),t({token:{token:r,named:e.Shape.POLYGON},useValue:s}),t({token:{token:r,named:e.Shape.PATH},useValue:f}),t({token:a,useFactory:function(t){return function(e){return t.container.isBoundNamed(r,e)?t.container.getNamed(r,e):null}}})})),k=function(t){var e,a;function r(){for(var e,n=arguments.length,a=new Array(n),r=0;n>r;r++)a[r]=arguments[r];return(e=t.call.apply(t,[this].concat(a))||this).name="canvas-path-generator",e}a=t,(e=r).prototype=Object.create(a.prototype),e.prototype.constructor=e,n(e,a);var o=r.prototype;return o.init=function(){this.container.load(m,!0)},o.destroy=function(){this.container.unload(m)},r}(e.AbstractRendererPlugin);t.PathGenerator=r,t.PathGeneratorFactory=a,t.Plugin=k,Object.defineProperty(t,"__esModule",{value:!0})}));

@@ -1,3 +0,3 @@

import type { ParsedBaseStyleProps } from '@antv/g';
import { Syringe } from '@antv/g';
import type { ParsedBaseStyleProps } from '@antv/g-lite';
import { Syringe } from '@antv/g-lite';
export declare const PathGeneratorFactory: Syringe.DefinedToken;

@@ -4,0 +4,0 @@ export declare const PathGenerator: Syringe.DefinedToken;

@@ -1,3 +0,3 @@

import type { ParsedCircleStyleProps } from '@antv/g';
import type { ParsedCircleStyleProps } from '@antv/g-lite';
export declare function generatePath(context: CanvasRenderingContext2D, parsedStyle: ParsedCircleStyleProps): void;
//# sourceMappingURL=Circle.d.ts.map

@@ -1,3 +0,3 @@

import type { ParsedEllipseStyleProps } from '@antv/g';
import type { ParsedEllipseStyleProps } from '@antv/g-lite';
export declare function generatePath(context: CanvasRenderingContext2D, parsedStyle: ParsedEllipseStyleProps): void;
//# sourceMappingURL=Ellipse.d.ts.map

@@ -1,3 +0,3 @@

import type { ParsedLineStyleProps } from '@antv/g';
import type { ParsedLineStyleProps } from '@antv/g-lite';
export declare function generatePath(context: CanvasRenderingContext2D, parsedStyle: ParsedLineStyleProps): void;
//# sourceMappingURL=Line.d.ts.map

@@ -1,3 +0,3 @@

import type { ParsedPathStyleProps } from '@antv/g';
import type { ParsedPathStyleProps } from '@antv/g-lite';
export declare function generatePath(context: CanvasRenderingContext2D, parsedStyle: ParsedPathStyleProps): void;
//# sourceMappingURL=Path.d.ts.map

@@ -1,3 +0,3 @@

import type { ParsedPolygonStyleProps } from '@antv/g';
import type { ParsedPolygonStyleProps } from '@antv/g-lite';
export declare function generatePath(context: CanvasRenderingContext2D, parsedStyle: ParsedPolygonStyleProps): void;
//# sourceMappingURL=Polygon.d.ts.map

@@ -1,3 +0,3 @@

import type { ParsedPolylineStyleProps } from '@antv/g';
import type { ParsedPolylineStyleProps } from '@antv/g-lite';
export declare function generatePath(context: CanvasRenderingContext2D, parsedStyle: ParsedPolylineStyleProps): void;
//# sourceMappingURL=Polyline.d.ts.map

@@ -1,3 +0,3 @@

import type { ParsedRectStyleProps } from '@antv/g';
import type { ParsedRectStyleProps } from '@antv/g-lite';
export declare function generatePath(context: CanvasRenderingContext2D, parsedStyle: ParsedRectStyleProps): void;
//# sourceMappingURL=Rect.d.ts.map
{
"name": "@antv/g-plugin-canvas-path-generator",
"version": "1.1.11",
"version": "1.1.12",
"description": "A G plugin of path generator with Canvas2D API",

@@ -30,3 +30,3 @@ "keywords": [

"dependencies": {
"@antv/g-math": "^1.7.11",
"@antv/g-math": "^1.7.12",
"tslib": "^2.3.1"

@@ -38,3 +38,3 @@ },

"peerDependencies": {
"@antv/g": "^5.0.1"
"@antv/g-lite": "^1.0.0"
},

@@ -44,3 +44,3 @@ "publishConfig": {

},
"gitHead": "32c0eab45e1b2350b9d1b12895b05e90e1fc7971"
"gitHead": "d2a0433cdcc3f58ba90513d1054dd824ab1491a5"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc