MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / buildPath$1

Function buildPath$1

libs/echarts/echarts.simple.js:16044–16077  ·  view source on GitHub ↗
(ctx, shape, closePath)

Source from the content-addressed store, hash-verified

16042};
16043
16044function buildPath$1(ctx, shape, closePath) {
16045 var points = shape.points;
16046 var smooth = shape.smooth;
16047 if (points && points.length >= 2) {
16048 if (smooth && smooth !== 'spline') {
16049 var controlPoints = smoothBezier(
16050 points, smooth, closePath, shape.smoothConstraint
16051 );
16052
16053 ctx.moveTo(points[0][0], points[0][1]);
16054 var len = points.length;
16055 for (var i = 0; i < (closePath ? len : len - 1); i++) {
16056 var cp1 = controlPoints[i * 2];
16057 var cp2 = controlPoints[i * 2 + 1];
16058 var p = points[(i + 1) % len];
16059 ctx.bezierCurveTo(
16060 cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]
16061 );
16062 }
16063 }
16064 else {
16065 if (smooth === 'spline') {
16066 points = smoothSpline(points, closePath);
16067 }
16068
16069 ctx.moveTo(points[0][0], points[0][1]);
16070 for (var i = 1, l = points.length; i < l; i++) {
16071 ctx.lineTo(points[i][0], points[i][1]);
16072 }
16073 }
16074
16075 closePath && ctx.closePath();
16076 }
16077}
16078
16079/**
16080 * 多边形

Callers 1

echarts.simple.jsFile · 0.70

Calls 3

smoothBezierFunction · 0.70
smoothSplineFunction · 0.70
moveToMethod · 0.45

Tested by

no test coverage detected