@amcharts/amcharts5 5.16.2 → 5.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.internal/charts/map/MapChartDefaultTheme.d.ts.map +1 -1
- package/.internal/charts/map/MapChartDefaultTheme.js +3 -0
- package/.internal/charts/map/MapChartDefaultTheme.js.map +1 -1
- package/.internal/charts/map/MapSankeyNodes.d.ts +155 -0
- package/.internal/charts/map/MapSankeyNodes.d.ts.map +1 -0
- package/.internal/charts/map/MapSankeyNodes.js +151 -0
- package/.internal/charts/map/MapSankeyNodes.js.map +1 -0
- package/.internal/charts/map/MapSankeySeries.d.ts +412 -0
- package/.internal/charts/map/MapSankeySeries.d.ts.map +1 -0
- package/.internal/charts/map/MapSankeySeries.js +868 -0
- package/.internal/charts/map/MapSankeySeries.js.map +1 -0
- package/.internal/core/Classes.d.ts +6 -0
- package/.internal/core/Classes.d.ts.map +1 -1
- package/.internal/core/Classes.js.map +1 -1
- package/.internal/core/Registry.js +1 -1
- package/.internal/core/Registry.js.map +1 -1
- package/.internal/core/util/Entity.d.ts.map +1 -1
- package/.internal/core/util/Entity.js +6 -0
- package/.internal/core/util/Entity.js.map +1 -1
- package/.internal/core/util/Math.d.ts +132 -49
- package/.internal/core/util/Math.d.ts.map +1 -1
- package/.internal/core/util/Math.js +151 -50
- package/.internal/core/util/Math.js.map +1 -1
- package/.internal/core/util/Object.d.ts +24 -1
- package/.internal/core/util/Object.d.ts.map +1 -1
- package/.internal/core/util/Object.js +24 -1
- package/.internal/core/util/Object.js.map +1 -1
- package/.internal/core/util/Utils.d.ts +69 -3
- package/.internal/core/util/Utils.d.ts.map +1 -1
- package/.internal/core/util/Utils.js +72 -18
- package/.internal/core/util/Utils.js.map +1 -1
- package/.internal/plugins/json/Classes-script.d.ts +6 -0
- package/.internal/plugins/json/Classes-script.d.ts.map +1 -1
- package/.internal/plugins/json/Classes-script.js +3 -0
- package/.internal/plugins/json/Classes-script.js.map +1 -1
- package/.internal/plugins/json/Classes.d.ts +6 -0
- package/.internal/plugins/json/Classes.d.ts.map +1 -1
- package/.internal/plugins/json/Classes.js +3 -0
- package/.internal/plugins/json/Classes.js.map +1 -1
- package/CHANGELOG.md +23 -8
- package/examples/javascript/flow-arc-horizontal/package.json +1 -1
- package/examples/javascript/flow-arc-vertical/package.json +1 -1
- package/examples/javascript/flow-chord/package.json +1 -1
- package/examples/javascript/flow-chord-directed/package.json +1 -1
- package/examples/javascript/flow-chord-non-ribbon/package.json +1 -1
- package/examples/javascript/flow-sankey/package.json +1 -1
- package/examples/javascript/gantt/package.json +1 -1
- package/examples/javascript/gantt-multilevel/package.json +1 -1
- package/examples/javascript/gantt-simple/package.json +1 -1
- package/examples/javascript/gauge/package.json +1 -1
- package/examples/javascript/gauge-bands/package.json +1 -1
- package/examples/javascript/hierarchy-force-directed/package.json +1 -1
- package/examples/javascript/hierarchy-pack/package.json +1 -1
- package/examples/javascript/hierarchy-partition/package.json +1 -1
- package/examples/javascript/hierarchy-sunburst/package.json +1 -1
- package/examples/javascript/hierarchy-tree/package.json +1 -1
- package/examples/javascript/hierarchy-treemap/package.json +1 -1
- package/examples/javascript/hierarchy-voronoi-treemap/package.json +1 -1
- package/examples/javascript/jest/package.json +1 -1
- package/examples/javascript/json-pie/package.json +1 -1
- package/examples/javascript/json-xy/package.json +1 -1
- package/examples/javascript/map-animating-along-lines/package.json +1 -1
- package/examples/javascript/map-clustered-points/package.json +1 -1
- package/examples/javascript/map-day-and-night/package.json +1 -1
- package/examples/javascript/map-globe-rotate-to-country/package.json +1 -1
- package/examples/javascript/map-globe-with-projected-circles/package.json +1 -1
- package/examples/javascript/map-sankey/README.md +6 -0
- package/examples/javascript/map-sankey/index.css +11 -0
- package/examples/javascript/map-sankey/index.html +13 -0
- package/examples/javascript/map-sankey/index.js +361 -0
- package/examples/javascript/map-sankey/package.json +17 -0
- package/examples/javascript/map-sankey/webpack.config.js +38 -0
- package/examples/javascript/map-sankey-waypoints/README.md +6 -0
- package/examples/javascript/map-sankey-waypoints/index.css +11 -0
- package/examples/javascript/map-sankey-waypoints/index.html +13 -0
- package/examples/javascript/map-sankey-waypoints/index.js +394 -0
- package/examples/javascript/map-sankey-waypoints/package.json +17 -0
- package/examples/javascript/map-sankey-waypoints/webpack.config.js +38 -0
- package/examples/javascript/map-with-bubbles/package.json +1 -1
- package/examples/javascript/map-zoom-to-country/package.json +1 -1
- package/examples/javascript/misc-40-charts/package.json +1 -1
- package/examples/javascript/misc-microchart-grid/package.json +1 -1
- package/examples/javascript/pie-chart/package.json +1 -1
- package/examples/javascript/pie-donut-chart/package.json +1 -1
- package/examples/javascript/pie-variable-radius/package.json +1 -1
- package/examples/javascript/radar-column-iwatch-style/package.json +1 -1
- package/examples/javascript/radar-heat-map/package.json +1 -1
- package/examples/javascript/radar-line/package.json +1 -1
- package/examples/javascript/radar-time-line/package.json +1 -1
- package/examples/javascript/sliced-funnel/package.json +1 -1
- package/examples/javascript/sliced-pictorial-stacked/package.json +1 -1
- package/examples/javascript/sliced-pyramid/package.json +1 -1
- package/examples/javascript/stock-chart/package.json +1 -1
- package/examples/javascript/stock-chart-comparing-stocks/package.json +1 -1
- package/examples/javascript/stock-chart-data-granularity/package.json +1 -1
- package/examples/javascript/stock-chart-data-grouping/package.json +1 -1
- package/examples/javascript/stock-chart-intraday/package.json +1 -1
- package/examples/javascript/stock-chart-live/package.json +1 -1
- package/examples/javascript/stock-chart-volume-separate-panel/package.json +1 -1
- package/examples/javascript/timeline-horizontal-serpentine-chart/package.json +1 -1
- package/examples/javascript/timeline-linear-process-diagram/package.json +1 -1
- package/examples/javascript/timeline-serpentine-chart/package.json +1 -1
- package/examples/javascript/timeline-spiral-chart/package.json +1 -1
- package/examples/javascript/venn-diagram/package.json +1 -1
- package/examples/javascript/wordcloud-with-data/package.json +1 -1
- package/examples/javascript/wordcloud-with-text/package.json +1 -1
- package/examples/javascript/xy-100-percent-stacked-column/package.json +1 -1
- package/examples/javascript/xy-animated-bullet-at-the-end-of-the-series/package.json +1 -1
- package/examples/javascript/xy-bubble/package.json +1 -1
- package/examples/javascript/xy-candlestick/package.json +1 -1
- package/examples/javascript/xy-clustered-column/package.json +1 -1
- package/examples/javascript/xy-column/package.json +1 -1
- package/examples/javascript/xy-comparing-series-google-analytics-style/package.json +1 -1
- package/examples/javascript/xy-data-grouping/package.json +1 -1
- package/examples/javascript/xy-draggable-range/package.json +1 -1
- package/examples/javascript/xy-drawing-series-with-mouse-or-touch/package.json +1 -1
- package/examples/javascript/xy-dumbbell plot/package.json +1 -1
- package/examples/javascript/xy-evenly-spaced-date-axis/package.json +1 -1
- package/examples/javascript/xy-line/package.json +1 -1
- package/examples/javascript/xy-line-highlight-on-legend-hover/package.json +1 -1
- package/examples/javascript/xy-live-data/package.json +1 -1
- package/examples/javascript/xy-multiple-synced-value-axes/package.json +1 -1
- package/examples/javascript/xy-ohlc/package.json +1 -1
- package/examples/javascript/xy-real-time-data-sorting/package.json +1 -1
- package/examples/javascript/xy-smoothed-line/package.json +1 -1
- package/examples/javascript/xy-stacked-and-clustered-column/package.json +1 -1
- package/examples/javascript/xy-stacked-column/package.json +1 -1
- package/examples/javascript/xy-stacked-step/package.json +1 -1
- package/examples/javascript/xy-stock/package.json +1 -1
- package/examples/javascript/xy-stock-comparing/package.json +1 -1
- package/examples/typescript/flow-arc-horizontal/package.json +1 -1
- package/examples/typescript/flow-arc-vertical/package.json +1 -1
- package/examples/typescript/flow-chord/package.json +1 -1
- package/examples/typescript/flow-chord-directed/package.json +1 -1
- package/examples/typescript/flow-chord-non-ribbon/package.json +1 -1
- package/examples/typescript/flow-sankey/package.json +1 -1
- package/examples/typescript/gantt/package.json +1 -1
- package/examples/typescript/gantt-multilevel/package.json +1 -1
- package/examples/typescript/gantt-simple/package.json +1 -1
- package/examples/typescript/gauge/package.json +1 -1
- package/examples/typescript/gauge-bands/package.json +1 -1
- package/examples/typescript/hierarchy-force-directed/package.json +1 -1
- package/examples/typescript/hierarchy-pack/package.json +1 -1
- package/examples/typescript/hierarchy-partition/package.json +1 -1
- package/examples/typescript/hierarchy-sunburst/package.json +1 -1
- package/examples/typescript/hierarchy-tree/package.json +1 -1
- package/examples/typescript/hierarchy-treemap/package.json +1 -1
- package/examples/typescript/hierarchy-voronoi-treemap/package.json +1 -1
- package/examples/typescript/jest/package.json +1 -1
- package/examples/typescript/json-pie/package.json +1 -1
- package/examples/typescript/json-xy/package.json +1 -1
- package/examples/typescript/map-animating-along-lines/package.json +1 -1
- package/examples/typescript/map-clustered-points/package.json +1 -1
- package/examples/typescript/map-day-and-night/package.json +1 -1
- package/examples/typescript/map-globe-rotate-to-country/package.json +1 -1
- package/examples/typescript/map-globe-with-projected-circles/package.json +1 -1
- package/examples/typescript/map-sankey/README.md +6 -0
- package/examples/typescript/map-sankey/index.css +11 -0
- package/examples/typescript/map-sankey/index.html +13 -0
- package/examples/typescript/map-sankey/index.ts +361 -0
- package/examples/typescript/map-sankey/package.json +19 -0
- package/examples/typescript/map-sankey/tsconfig.json +12 -0
- package/examples/typescript/map-sankey/webpack.config.js +45 -0
- package/examples/typescript/map-sankey-waypoints/README.md +6 -0
- package/examples/typescript/map-sankey-waypoints/index.css +11 -0
- package/examples/typescript/map-sankey-waypoints/index.html +13 -0
- package/examples/typescript/map-sankey-waypoints/index.ts +394 -0
- package/examples/typescript/map-sankey-waypoints/package.json +19 -0
- package/examples/typescript/map-sankey-waypoints/tsconfig.json +12 -0
- package/examples/typescript/map-sankey-waypoints/webpack.config.js +45 -0
- package/examples/typescript/map-with-bubbles/package.json +1 -1
- package/examples/typescript/map-zoom-to-country/package.json +1 -1
- package/examples/typescript/misc-40-charts/package.json +1 -1
- package/examples/typescript/misc-microchart-grid/package.json +1 -1
- package/examples/typescript/pie-chart/package.json +1 -1
- package/examples/typescript/pie-donut-chart/package.json +1 -1
- package/examples/typescript/pie-variable-radius/package.json +1 -1
- package/examples/typescript/radar-column-iwatch-style/package.json +1 -1
- package/examples/typescript/radar-heat-map/package.json +1 -1
- package/examples/typescript/radar-line/package.json +1 -1
- package/examples/typescript/radar-time-line/package.json +1 -1
- package/examples/typescript/sliced-funnel/package.json +1 -1
- package/examples/typescript/sliced-pictorial-stacked/package.json +1 -1
- package/examples/typescript/sliced-pyramid/package.json +1 -1
- package/examples/typescript/stock-chart/package.json +1 -1
- package/examples/typescript/stock-chart-comparing-stocks/package.json +1 -1
- package/examples/typescript/stock-chart-data-granularity/package.json +1 -1
- package/examples/typescript/stock-chart-data-grouping/package.json +1 -1
- package/examples/typescript/stock-chart-intraday/package.json +1 -1
- package/examples/typescript/stock-chart-live/package.json +1 -1
- package/examples/typescript/stock-chart-volume-separate-panel/package.json +1 -1
- package/examples/typescript/timeline-horizontal-serpentine-chart/package.json +1 -1
- package/examples/typescript/timeline-linear-process-diagram/package.json +1 -1
- package/examples/typescript/timeline-serpentine-chart/package.json +1 -1
- package/examples/typescript/timeline-spiral-chart/package.json +1 -1
- package/examples/typescript/venn-diagram/package.json +1 -1
- package/examples/typescript/wordcloud-with-data/package.json +1 -1
- package/examples/typescript/wordcloud-with-text/package.json +1 -1
- package/examples/typescript/xy-100-percent-stacked-column/package.json +1 -1
- package/examples/typescript/xy-animated-bullet-at-the-end-of-the-series/package.json +1 -1
- package/examples/typescript/xy-bubble/package.json +1 -1
- package/examples/typescript/xy-candlestick/package.json +1 -1
- package/examples/typescript/xy-clustered-column/package.json +1 -1
- package/examples/typescript/xy-column/package.json +1 -1
- package/examples/typescript/xy-comparing-series-google-analytics-style/package.json +1 -1
- package/examples/typescript/xy-data-grouping/package.json +1 -1
- package/examples/typescript/xy-draggable-range/package.json +1 -1
- package/examples/typescript/xy-drawing-series-with-mouse-or-touch/package.json +1 -1
- package/examples/typescript/xy-dumbbell plot/package.json +1 -1
- package/examples/typescript/xy-evenly-spaced-date-axis/package.json +1 -1
- package/examples/typescript/xy-line/package.json +1 -1
- package/examples/typescript/xy-line-highlight-on-legend-hover/package.json +1 -1
- package/examples/typescript/xy-live-data/package.json +1 -1
- package/examples/typescript/xy-multiple-synced-value-axes/package.json +1 -1
- package/examples/typescript/xy-ohlc/package.json +1 -1
- package/examples/typescript/xy-real-time-data-sorting/package.json +1 -1
- package/examples/typescript/xy-smoothed-line/package.json +1 -1
- package/examples/typescript/xy-stacked-and-clustered-column/package.json +1 -1
- package/examples/typescript/xy-stacked-column/package.json +1 -1
- package/examples/typescript/xy-stacked-step/package.json +1 -1
- package/examples/typescript/xy-stock/package.json +1 -1
- package/examples/typescript/xy-stock-comparing/package.json +1 -1
- package/map.d.ts +2 -0
- package/map.d.ts.map +1 -1
- package/map.js +2 -0
- package/map.js.map +1 -1
- package/package.json +1 -1
|
@@ -28,33 +28,39 @@ export declare function round(value: number, precision?: number, floor?: boolean
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function ceil(value: number, precision: number): number;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @
|
|
35
|
-
* @param p0
|
|
36
|
-
* @param p1
|
|
37
|
-
* @param p2
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
40
|
-
* @
|
|
41
|
-
* @return [description]
|
|
31
|
+
* Returns the first control point for a cubic bezier spline segment
|
|
32
|
+
* interpolating through three consecutive points with the given tension.
|
|
33
|
+
*
|
|
34
|
+
* @ignore
|
|
35
|
+
* @param p0 Previous point
|
|
36
|
+
* @param p1 Current point
|
|
37
|
+
* @param p2 Next point
|
|
38
|
+
* @param tensionX Horizontal tension (0–1)
|
|
39
|
+
* @param tensionY Vertical tension (0–1)
|
|
40
|
+
* @return First control point
|
|
42
41
|
*/
|
|
43
42
|
export declare function getCubicControlPointA(p0: IPoint, p1: IPoint, p2: IPoint, tensionX: number, tensionY: number): IPoint;
|
|
44
43
|
/**
|
|
45
|
-
*
|
|
44
|
+
* Returns the second control point for a cubic bezier spline segment
|
|
45
|
+
* interpolating through three consecutive points with the given tension.
|
|
46
46
|
*
|
|
47
|
-
* @ignore
|
|
48
|
-
* @
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
53
|
-
* @
|
|
54
|
-
* @param tensionY [description]
|
|
55
|
-
* @return [description]
|
|
47
|
+
* @ignore
|
|
48
|
+
* @param p1 Current point
|
|
49
|
+
* @param p2 Next point
|
|
50
|
+
* @param p3 Point after next
|
|
51
|
+
* @param tensionX Horizontal tension (0–1)
|
|
52
|
+
* @param tensionY Vertical tension (0–1)
|
|
53
|
+
* @return Second control point
|
|
56
54
|
*/
|
|
57
55
|
export declare function getCubicControlPointB(p1: IPoint, p2: IPoint, p3: IPoint, tensionX: number, tensionY: number): IPoint;
|
|
56
|
+
/**
|
|
57
|
+
* Clamps a value to the given [min, max] range.
|
|
58
|
+
*
|
|
59
|
+
* @param value Value to clamp
|
|
60
|
+
* @param min Minimum
|
|
61
|
+
* @param max Maximum
|
|
62
|
+
* @return Clamped value
|
|
63
|
+
*/
|
|
58
64
|
export declare function fitToRange(value: number, min: number, max: number): number;
|
|
59
65
|
/**
|
|
60
66
|
* Returns sine of an angle specified in degrees.
|
|
@@ -77,37 +83,112 @@ export declare function tan(angle: number): number;
|
|
|
77
83
|
* @return Cosine
|
|
78
84
|
*/
|
|
79
85
|
export declare function cos(angle: number): number;
|
|
86
|
+
/**
|
|
87
|
+
* Normalizes an angle to the 0–360 range.
|
|
88
|
+
*
|
|
89
|
+
* @param value Angle in degrees
|
|
90
|
+
* @return Normalized angle (0–360)
|
|
91
|
+
*/
|
|
80
92
|
export declare function normalizeAngle(value: number): number;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the bounding box of a circular arc.
|
|
95
|
+
*
|
|
96
|
+
* @param cx Center X
|
|
97
|
+
* @param cy Center Y
|
|
98
|
+
* @param startAngle Start angle in degrees
|
|
99
|
+
* @param endAngle End angle in degrees
|
|
100
|
+
* @param radius Arc radius
|
|
101
|
+
* @return Bounding box
|
|
102
|
+
*/
|
|
81
103
|
export declare function getArcBounds(cx: number, cy: number, startAngle: number, endAngle: number, radius: number): IBounds;
|
|
82
104
|
/**
|
|
83
|
-
* Returns point on
|
|
105
|
+
* Returns a point on a circle at the given angle.
|
|
84
106
|
*
|
|
85
|
-
* @param
|
|
86
|
-
* @param
|
|
87
|
-
* @
|
|
88
|
-
* @return {boolean}
|
|
107
|
+
* @param radius Circle radius
|
|
108
|
+
* @param arc Angle in degrees
|
|
109
|
+
* @return Point on the arc
|
|
89
110
|
*/
|
|
90
111
|
export declare function getArcPoint(radius: number, arc: number): {
|
|
91
112
|
x: number;
|
|
92
113
|
y: number;
|
|
93
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Merges an array of bounds into a single bounding box that encompasses all of them.
|
|
117
|
+
*
|
|
118
|
+
* @param bounds Array of bounds to merge
|
|
119
|
+
* @return Combined bounding box
|
|
120
|
+
*/
|
|
94
121
|
export declare function mergeBounds(bounds: IBounds[]): IBounds;
|
|
122
|
+
/**
|
|
123
|
+
* Fits an angle into the given start/end range, snapping to the
|
|
124
|
+
* nearest boundary when the angle falls outside.
|
|
125
|
+
*
|
|
126
|
+
* @param value Angle in degrees
|
|
127
|
+
* @param startAngle Range start in degrees
|
|
128
|
+
* @param endAngle Range end in degrees
|
|
129
|
+
* @return Angle clamped to the range
|
|
130
|
+
*/
|
|
95
131
|
export declare function fitAngleToRange(value: number, startAngle: number, endAngle: number): number;
|
|
132
|
+
/**
|
|
133
|
+
* Returns `true` if a point is inside the given bounds (inclusive).
|
|
134
|
+
*
|
|
135
|
+
* @param point Point to test
|
|
136
|
+
* @param bounds Bounding box
|
|
137
|
+
* @return Whether the point is inside
|
|
138
|
+
*/
|
|
96
139
|
export declare function inBounds(point: IPoint, bounds: IBounds): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Returns the angle in degrees from `point1` to `point2`.
|
|
142
|
+
* If `point2` is omitted, uses double of `point1` coordinates.
|
|
143
|
+
*
|
|
144
|
+
* @param point1 Origin point
|
|
145
|
+
* @param point2 Target point (optional)
|
|
146
|
+
* @return Angle in degrees (0–360)
|
|
147
|
+
*/
|
|
97
148
|
export declare function getAngle(point1: IPoint, point2?: IPoint): number;
|
|
98
149
|
/**
|
|
99
|
-
*
|
|
150
|
+
* Returns a point on a quadratic bezier curve at the given position (0–1).
|
|
100
151
|
*
|
|
101
|
-
* @
|
|
102
|
-
* @
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @
|
|
106
|
-
* @param position [description]
|
|
107
|
-
* @return [description]
|
|
152
|
+
* @param pointA Start point
|
|
153
|
+
* @param pointB End point
|
|
154
|
+
* @param controlPoint Control point
|
|
155
|
+
* @param position Relative position (0 = start, 1 = end)
|
|
156
|
+
* @return Point on the curve
|
|
108
157
|
*/
|
|
109
158
|
export declare function getPointOnQuadraticCurve(pointA: IPoint, pointB: IPoint, controlPoint: IPoint, position: number): IPoint;
|
|
159
|
+
/**
|
|
160
|
+
* Returns a point on a cubic bezier curve at the given position (0–1).
|
|
161
|
+
*
|
|
162
|
+
* @param pointA Start point
|
|
163
|
+
* @param pointB End point
|
|
164
|
+
* @param controlPointA First control point (near start)
|
|
165
|
+
* @param controlPointB Second control point (near end)
|
|
166
|
+
* @param position Relative position (0 = start, 1 = end)
|
|
167
|
+
* @return Point on the curve
|
|
168
|
+
*/
|
|
169
|
+
export declare function getPointOnCubicCurve(pointA: IPoint, pointB: IPoint, controlPointA: IPoint, controlPointB: IPoint, position: number): IPoint;
|
|
170
|
+
/**
|
|
171
|
+
* Returns a point at a relative position along a straight line between two points.
|
|
172
|
+
*
|
|
173
|
+
* @param pointA Start point
|
|
174
|
+
* @param pointB End point
|
|
175
|
+
* @param position Relative position (0 = start, 1 = end)
|
|
176
|
+
* @return Point on the line
|
|
177
|
+
*/
|
|
110
178
|
export declare function getPointOnLine(pointA: IPoint, pointB: IPoint, position: number): IPoint;
|
|
179
|
+
/**
|
|
180
|
+
* Given a normalized location (0–1) along a multi-segment path and an array
|
|
181
|
+
* of cumulative segment lengths, returns which segment the location falls in
|
|
182
|
+
* and the local parameter t within that segment.
|
|
183
|
+
*
|
|
184
|
+
* @param location Relative position along the full path (0–1)
|
|
185
|
+
* @param cumulativeLengths Cumulative length at the end of each segment
|
|
186
|
+
* @return Segment index and local t (0–1)
|
|
187
|
+
*/
|
|
188
|
+
export declare function resolveLocationOnPath(location: number, cumulativeLengths: number[]): {
|
|
189
|
+
index: number;
|
|
190
|
+
t: number;
|
|
191
|
+
};
|
|
111
192
|
/**
|
|
112
193
|
* Returns the closest value from the array of values to the reference value.
|
|
113
194
|
*
|
|
@@ -124,24 +205,26 @@ export declare function closest(values: number[], referenceValue: number): numbe
|
|
|
124
205
|
*/
|
|
125
206
|
export declare function boundsOverlap(bounds1: IBounds, bounds2: IBounds): boolean;
|
|
126
207
|
/**
|
|
127
|
-
* Generates points
|
|
128
|
-
*
|
|
129
|
-
* @param
|
|
130
|
-
* @param
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
134
|
-
* @param
|
|
135
|
-
* @param
|
|
136
|
-
* @param
|
|
137
|
-
* @
|
|
208
|
+
* Generates points along a spiral path.
|
|
209
|
+
*
|
|
210
|
+
* @param cx Center X
|
|
211
|
+
* @param cy Center Y
|
|
212
|
+
* @param radius Outer radius
|
|
213
|
+
* @param radiusY Vertical radius (for elliptical spirals)
|
|
214
|
+
* @param innerRadius Inner radius where the spiral starts
|
|
215
|
+
* @param step Base step size between points
|
|
216
|
+
* @param radiusStep Radius increase per full revolution
|
|
217
|
+
* @param startAngle Start angle in degrees
|
|
218
|
+
* @param endAngle End angle in degrees
|
|
219
|
+
* @return Array of points along the spiral
|
|
138
220
|
*/
|
|
139
221
|
export declare function spiralPoints(cx: number, cy: number, radius: number, radiusY: number, innerRadius: number, step: number, radiusStep: number, startAngle: number, endAngle: number): IPoint[];
|
|
140
222
|
/**
|
|
141
|
-
* Returns true if circles overlap
|
|
142
|
-
*
|
|
143
|
-
* @param
|
|
144
|
-
* @
|
|
223
|
+
* Returns `true` if two circles overlap or touch.
|
|
224
|
+
*
|
|
225
|
+
* @param circle1 First circle (x, y, radius)
|
|
226
|
+
* @param circle2 Second circle (x, y, radius)
|
|
227
|
+
* @return Whether the circles overlap
|
|
145
228
|
*/
|
|
146
229
|
export declare function circlesOverlap(circle1: {
|
|
147
230
|
x: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Math.d.ts","sourceRoot":"","sources":["../../../../../src/.internal/core/util/Math.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,EAAE,QAAU,CAAC;AAC1B,eAAO,MAAM,MAAM,QAAS,CAAC;AAC7B,eAAO,MAAM,OAAO,QAAW,CAAC;AAChC,eAAO,MAAM,OAAO,QAAW,CAAC;AAEhC;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAehF;AAGD;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAQ7D;AAGD
|
|
1
|
+
{"version":3,"file":"Math.d.ts","sourceRoot":"","sources":["../../../../../src/.internal/core/util/Math.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,EAAE,QAAU,CAAC;AAC1B,eAAO,MAAM,MAAM,QAAS,CAAC;AAC7B,eAAO,MAAM,OAAO,QAAW,CAAC;AAChC,eAAO,MAAM,OAAO,QAAW,CAAC;AAEhC;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC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MAAM,CAIxE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAIzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CA0C3L;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAE5I"}
|
|
@@ -49,37 +49,43 @@ export function ceil(value, precision) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Returns the first control point for a cubic bezier spline segment
|
|
53
|
+
* interpolating through three consecutive points with the given tension.
|
|
53
54
|
*
|
|
54
|
-
* @ignore
|
|
55
|
-
* @
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @
|
|
61
|
-
* @param tensionY [description]
|
|
62
|
-
* @return [description]
|
|
55
|
+
* @ignore
|
|
56
|
+
* @param p0 Previous point
|
|
57
|
+
* @param p1 Current point
|
|
58
|
+
* @param p2 Next point
|
|
59
|
+
* @param tensionX Horizontal tension (0–1)
|
|
60
|
+
* @param tensionY Vertical tension (0–1)
|
|
61
|
+
* @return First control point
|
|
63
62
|
*/
|
|
64
63
|
export function getCubicControlPointA(p0, p1, p2, tensionX, tensionY) {
|
|
65
64
|
return { x: ((-p0.x + p1.x / tensionX + p2.x) * tensionX), y: ((-p0.y + p1.y / tensionY + p2.y) * tensionY) };
|
|
66
65
|
}
|
|
67
66
|
/**
|
|
68
|
-
*
|
|
67
|
+
* Returns the second control point for a cubic bezier spline segment
|
|
68
|
+
* interpolating through three consecutive points with the given tension.
|
|
69
69
|
*
|
|
70
|
-
* @ignore
|
|
71
|
-
* @
|
|
72
|
-
* @param
|
|
73
|
-
* @param
|
|
74
|
-
* @param
|
|
75
|
-
* @param
|
|
76
|
-
* @
|
|
77
|
-
* @param tensionY [description]
|
|
78
|
-
* @return [description]
|
|
70
|
+
* @ignore
|
|
71
|
+
* @param p1 Current point
|
|
72
|
+
* @param p2 Next point
|
|
73
|
+
* @param p3 Point after next
|
|
74
|
+
* @param tensionX Horizontal tension (0–1)
|
|
75
|
+
* @param tensionY Vertical tension (0–1)
|
|
76
|
+
* @return Second control point
|
|
79
77
|
*/
|
|
80
78
|
export function getCubicControlPointB(p1, p2, p3, tensionX, tensionY) {
|
|
81
79
|
return { x: ((p1.x + p2.x / tensionX - p3.x) * tensionX), y: ((p1.y + p2.y / tensionY - p3.y) * tensionY) };
|
|
82
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Clamps a value to the given [min, max] range.
|
|
83
|
+
*
|
|
84
|
+
* @param value Value to clamp
|
|
85
|
+
* @param min Minimum
|
|
86
|
+
* @param max Maximum
|
|
87
|
+
* @return Clamped value
|
|
88
|
+
*/
|
|
83
89
|
export function fitToRange(value, min, max) {
|
|
84
90
|
return Math.min(Math.max(value, min), max);
|
|
85
91
|
}
|
|
@@ -110,7 +116,12 @@ export function tan(angle) {
|
|
|
110
116
|
export function cos(angle) {
|
|
111
117
|
return Math.cos(RADIANS * angle);
|
|
112
118
|
}
|
|
113
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Normalizes an angle to the 0–360 range.
|
|
121
|
+
*
|
|
122
|
+
* @param value Angle in degrees
|
|
123
|
+
* @return Normalized angle (0–360)
|
|
124
|
+
*/
|
|
114
125
|
export function normalizeAngle(value) {
|
|
115
126
|
value = value % 360;
|
|
116
127
|
if (value < 0) {
|
|
@@ -118,7 +129,16 @@ export function normalizeAngle(value) {
|
|
|
118
129
|
}
|
|
119
130
|
return value;
|
|
120
131
|
}
|
|
121
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Returns the bounding box of a circular arc.
|
|
134
|
+
*
|
|
135
|
+
* @param cx Center X
|
|
136
|
+
* @param cy Center Y
|
|
137
|
+
* @param startAngle Start angle in degrees
|
|
138
|
+
* @param endAngle End angle in degrees
|
|
139
|
+
* @param radius Arc radius
|
|
140
|
+
* @return Bounding box
|
|
141
|
+
*/
|
|
122
142
|
export function getArcBounds(cx, cy, startAngle, endAngle, radius) {
|
|
123
143
|
let minX = Number.MAX_VALUE;
|
|
124
144
|
let minY = Number.MAX_VALUE;
|
|
@@ -152,16 +172,21 @@ export function getArcBounds(cx, cy, startAngle, endAngle, radius) {
|
|
|
152
172
|
return ({ left: cx + minX, top: cy + minY, right: cx + maxX, bottom: cy + maxY });
|
|
153
173
|
}
|
|
154
174
|
/**
|
|
155
|
-
* Returns point on
|
|
175
|
+
* Returns a point on a circle at the given angle.
|
|
156
176
|
*
|
|
157
|
-
* @param
|
|
158
|
-
* @param
|
|
159
|
-
* @
|
|
160
|
-
* @return {boolean}
|
|
177
|
+
* @param radius Circle radius
|
|
178
|
+
* @param arc Angle in degrees
|
|
179
|
+
* @return Point on the arc
|
|
161
180
|
*/
|
|
162
181
|
export function getArcPoint(radius, arc) {
|
|
163
182
|
return ({ x: radius * cos(arc), y: radius * sin(arc) });
|
|
164
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Merges an array of bounds into a single bounding box that encompasses all of them.
|
|
186
|
+
*
|
|
187
|
+
* @param bounds Array of bounds to merge
|
|
188
|
+
* @return Combined bounding box
|
|
189
|
+
*/
|
|
165
190
|
export function mergeBounds(bounds) {
|
|
166
191
|
const len = bounds.length;
|
|
167
192
|
if (len > 0) {
|
|
@@ -183,6 +208,15 @@ export function mergeBounds(bounds) {
|
|
|
183
208
|
}
|
|
184
209
|
return { left: 0, right: 0, top: 0, bottom: 0 };
|
|
185
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Fits an angle into the given start/end range, snapping to the
|
|
213
|
+
* nearest boundary when the angle falls outside.
|
|
214
|
+
*
|
|
215
|
+
* @param value Angle in degrees
|
|
216
|
+
* @param startAngle Range start in degrees
|
|
217
|
+
* @param endAngle Range end in degrees
|
|
218
|
+
* @return Angle clamped to the range
|
|
219
|
+
*/
|
|
186
220
|
export function fitAngleToRange(value, startAngle, endAngle) {
|
|
187
221
|
if (startAngle > endAngle) {
|
|
188
222
|
let temp = startAngle;
|
|
@@ -219,12 +253,27 @@ export function fitAngleToRange(value, startAngle, endAngle) {
|
|
|
219
253
|
}
|
|
220
254
|
return value;
|
|
221
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Returns `true` if a point is inside the given bounds (inclusive).
|
|
258
|
+
*
|
|
259
|
+
* @param point Point to test
|
|
260
|
+
* @param bounds Bounding box
|
|
261
|
+
* @return Whether the point is inside
|
|
262
|
+
*/
|
|
222
263
|
export function inBounds(point, bounds) {
|
|
223
264
|
if (point.x >= bounds.left && point.y >= bounds.top && point.x <= bounds.right && point.y <= bounds.bottom) {
|
|
224
265
|
return true;
|
|
225
266
|
}
|
|
226
267
|
return false;
|
|
227
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Returns the angle in degrees from `point1` to `point2`.
|
|
271
|
+
* If `point2` is omitted, uses double of `point1` coordinates.
|
|
272
|
+
*
|
|
273
|
+
* @param point1 Origin point
|
|
274
|
+
* @param point2 Target point (optional)
|
|
275
|
+
* @return Angle in degrees (0–360)
|
|
276
|
+
*/
|
|
228
277
|
export function getAngle(point1, point2) {
|
|
229
278
|
if (!point2) {
|
|
230
279
|
point2 = { x: point1.x * 2, y: point1.y * 2 };
|
|
@@ -238,24 +287,74 @@ export function getAngle(point1, point2) {
|
|
|
238
287
|
return normalizeAngle(angle);
|
|
239
288
|
}
|
|
240
289
|
/**
|
|
241
|
-
*
|
|
290
|
+
* Returns a point on a quadratic bezier curve at the given position (0–1).
|
|
242
291
|
*
|
|
243
|
-
* @
|
|
244
|
-
* @
|
|
245
|
-
* @param
|
|
246
|
-
* @param
|
|
247
|
-
* @
|
|
248
|
-
* @param position [description]
|
|
249
|
-
* @return [description]
|
|
292
|
+
* @param pointA Start point
|
|
293
|
+
* @param pointB End point
|
|
294
|
+
* @param controlPoint Control point
|
|
295
|
+
* @param position Relative position (0 = start, 1 = end)
|
|
296
|
+
* @return Point on the curve
|
|
250
297
|
*/
|
|
251
298
|
export function getPointOnQuadraticCurve(pointA, pointB, controlPoint, position) {
|
|
252
299
|
let x = (1 - position) * (1 - position) * pointA.x + 2 * (1 - position) * position * controlPoint.x + position * position * pointB.x;
|
|
253
300
|
let y = (1 - position) * (1 - position) * pointA.y + 2 * (1 - position) * position * controlPoint.y + position * position * pointB.y;
|
|
254
301
|
return { x: x, y: y };
|
|
255
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Returns a point on a cubic bezier curve at the given position (0–1).
|
|
305
|
+
*
|
|
306
|
+
* @param pointA Start point
|
|
307
|
+
* @param pointB End point
|
|
308
|
+
* @param controlPointA First control point (near start)
|
|
309
|
+
* @param controlPointB Second control point (near end)
|
|
310
|
+
* @param position Relative position (0 = start, 1 = end)
|
|
311
|
+
* @return Point on the curve
|
|
312
|
+
*/
|
|
313
|
+
export function getPointOnCubicCurve(pointA, pointB, controlPointA, controlPointB, position) {
|
|
314
|
+
let s = 1 - position;
|
|
315
|
+
let x = s * s * s * pointA.x + 3 * s * s * position * controlPointA.x + 3 * s * position * position * controlPointB.x + position * position * position * pointB.x;
|
|
316
|
+
let y = s * s * s * pointA.y + 3 * s * s * position * controlPointA.y + 3 * s * position * position * controlPointB.y + position * position * position * pointB.y;
|
|
317
|
+
return { x: x, y: y };
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Returns a point at a relative position along a straight line between two points.
|
|
321
|
+
*
|
|
322
|
+
* @param pointA Start point
|
|
323
|
+
* @param pointB End point
|
|
324
|
+
* @param position Relative position (0 = start, 1 = end)
|
|
325
|
+
* @return Point on the line
|
|
326
|
+
*/
|
|
256
327
|
export function getPointOnLine(pointA, pointB, position) {
|
|
257
328
|
return { x: pointA.x + (pointB.x - pointA.x) * position, y: pointA.y + (pointB.y - pointA.y) * position };
|
|
258
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* Given a normalized location (0–1) along a multi-segment path and an array
|
|
332
|
+
* of cumulative segment lengths, returns which segment the location falls in
|
|
333
|
+
* and the local parameter t within that segment.
|
|
334
|
+
*
|
|
335
|
+
* @param location Relative position along the full path (0–1)
|
|
336
|
+
* @param cumulativeLengths Cumulative length at the end of each segment
|
|
337
|
+
* @return Segment index and local t (0–1)
|
|
338
|
+
*/
|
|
339
|
+
export function resolveLocationOnPath(location, cumulativeLengths) {
|
|
340
|
+
const n = cumulativeLengths.length;
|
|
341
|
+
if (n > 0) {
|
|
342
|
+
const totalLength = cumulativeLengths[n - 1];
|
|
343
|
+
const targetLength = location * totalLength;
|
|
344
|
+
let index = 0;
|
|
345
|
+
for (let i = 0; i < n; i++) {
|
|
346
|
+
if (cumulativeLengths[i] >= targetLength) {
|
|
347
|
+
index = i;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
const segStart = index > 0 ? cumulativeLengths[index - 1] : 0;
|
|
352
|
+
const segLength = cumulativeLengths[index] - segStart;
|
|
353
|
+
const t = segLength > 0 ? (targetLength - segStart) / segLength : 0;
|
|
354
|
+
return { index, t };
|
|
355
|
+
}
|
|
356
|
+
return { index: 0, t: 0 };
|
|
357
|
+
}
|
|
259
358
|
/**
|
|
260
359
|
* Returns the closest value from the array of values to the reference value.
|
|
261
360
|
*
|
|
@@ -280,17 +379,18 @@ export function boundsOverlap(bounds1, bounds2) {
|
|
|
280
379
|
return horizontalOverlap && verticalOverlap;
|
|
281
380
|
}
|
|
282
381
|
/**
|
|
283
|
-
* Generates points
|
|
284
|
-
*
|
|
285
|
-
* @param
|
|
286
|
-
* @param
|
|
287
|
-
* @param
|
|
288
|
-
* @param
|
|
289
|
-
* @param
|
|
290
|
-
* @param
|
|
291
|
-
* @param
|
|
292
|
-
* @param
|
|
293
|
-
* @
|
|
382
|
+
* Generates points along a spiral path.
|
|
383
|
+
*
|
|
384
|
+
* @param cx Center X
|
|
385
|
+
* @param cy Center Y
|
|
386
|
+
* @param radius Outer radius
|
|
387
|
+
* @param radiusY Vertical radius (for elliptical spirals)
|
|
388
|
+
* @param innerRadius Inner radius where the spiral starts
|
|
389
|
+
* @param step Base step size between points
|
|
390
|
+
* @param radiusStep Radius increase per full revolution
|
|
391
|
+
* @param startAngle Start angle in degrees
|
|
392
|
+
* @param endAngle End angle in degrees
|
|
393
|
+
* @return Array of points along the spiral
|
|
294
394
|
*/
|
|
295
395
|
export function spiralPoints(cx, cy, radius, radiusY, innerRadius, step, radiusStep, startAngle, endAngle) {
|
|
296
396
|
let r = innerRadius + 0.01;
|
|
@@ -321,10 +421,11 @@ export function spiralPoints(cx, cy, radius, radiusY, innerRadius, step, radiusS
|
|
|
321
421
|
return points;
|
|
322
422
|
}
|
|
323
423
|
/**
|
|
324
|
-
* Returns true if circles overlap
|
|
325
|
-
*
|
|
326
|
-
* @param
|
|
327
|
-
* @
|
|
424
|
+
* Returns `true` if two circles overlap or touch.
|
|
425
|
+
*
|
|
426
|
+
* @param circle1 First circle (x, y, radius)
|
|
427
|
+
* @param circle2 Second circle (x, y, radius)
|
|
428
|
+
* @return Whether the circles overlap
|
|
328
429
|
*/
|
|
329
430
|
export function circlesOverlap(circle1, circle2) {
|
|
330
431
|
return Math.hypot(circle1.x - circle2.x, circle1.y - circle2.y) <= circle1.radius + circle2.radius;
|
|
@@ -1 +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K,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAEzC,IAAI,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,UAAU,CAAC,EAAE;YACtF,MAAM;SACN;KACD;IAED,MAAM,CAAC,KAAK,EAAE,CAAC;IAEf,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAAiD,EAAE,OAAiD;IAClI,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACpG,CAAC","sourcesContent":["import type { IPoint } from \"./IPoint\";\nimport { isNumber } from \"./Type\";\nimport type { IBounds } from \"./IBounds\";\n\n/**\n * ============================================================================\n * CONSTANTS\n * ============================================================================\n * @hidden\n */\nexport const PI = Math.PI;\nexport const HALFPI = PI / 2;\nexport const RADIANS = PI / 180;\nexport const DEGREES = 180 / PI;\n\n/**\n * Rounds the numeric value to whole number or specific precision of set.\n *\n * @param value Value\n * @param precision Precision (number of decimal points)\n * @param floor In case value ends with 0.5 and precision is 0, we might need to floor the value instead of ceiling it.\n * @return Rounded value\n */\nexport function round(value: number, precision?: number, floor?: boolean): number {\n\tif (!isNumber(precision) || precision <= 0) {\n\n\t\tlet rounded = Math.round(value);\n\t\tif (floor) {\n\t\t\tif (rounded - value == 0.5) {\n\t\t\t\trounded--;\n\t\t\t}\n\t\t}\n\t\treturn rounded;\n\t}\n\telse {\n\t\tlet d: number = Math.pow(10, precision);\n\t\treturn Math.round(value * d) / d;\n\t}\n}\n\n\n/**\n * Ceils the numeric value to whole number or specific precision of set.\n *\n * @param value Value\n * @param precision Precision (number of decimal points)\n * @return Rounded value\n */\nexport function ceil(value: number, precision: number): number {\n\tif (!isNumber(precision) || precision <= 0) {\n\t\treturn Math.ceil(value);\n\t}\n\telse {\n\t\tlet d: number = Math.pow(10, precision);\n\t\treturn Math.ceil(value * d) / d;\n\t}\n}\n\n\n/**\n * [getCubicControlPointA description]\n *\n * @ignore Exclude from docs\n * @todo Description\n * @param p0 [description]\n * @param p1 [description]\n * @param p2 [description]\n * @param p3 [description]\n * @param tensionX [description]\n * @param tensionY [description]\n * @return [description]\n */\nexport function getCubicControlPointA(p0: IPoint, p1: IPoint, p2: IPoint, tensionX: number, tensionY: number): IPoint {\n\treturn { x: ((-p0.x + p1.x / tensionX + p2.x) * tensionX), y: ((-p0.y + p1.y / tensionY + p2.y) * tensionY) };\n}\n\n/**\n * [getCubicControlPointB description]\n *\n * @ignore Exclude from docs\n * @todo Description\n * @param p0 [description]\n * @param p1 [description]\n * @param p2 [description]\n * @param p3 [description]\n * @param tensionX [description]\n * @param tensionY [description]\n * @return [description]\n */\nexport function getCubicControlPointB(p1: IPoint, p2: IPoint, p3: IPoint, tensionX: number, tensionY: number): IPoint {\n\treturn { x: ((p1.x + p2.x / tensionX - p3.x) * tensionX), y: ((p1.y + p2.y / tensionY - p3.y) * tensionY) };\n}\n\n\nexport function fitToRange(value: number, min: number, max: number): number {\n\treturn Math.min(Math.max(value, min), max);\n}\n\n/**\n * Returns sine of an angle specified in degrees.\n *\n * @param value Value\n * @return Sine\n */\nexport function sin(angle: number): number {\n\treturn Math.sin(RADIANS * angle);\n}\n\n/**\n * Returns tan of an angle specified in degrees.\n *\n * @param value Value\n * @return Sine\n */\nexport function tan(angle: number): number {\n\treturn Math.tan(RADIANS * angle);\n}\n\n/**\n * Returns cosine of an angle specified in degrees.\n *\n * @param value Value\n * @return Cosine\n */\nexport function cos(angle: number): number {\n\treturn Math.cos(RADIANS * angle);\n}\n\n// 0 to 360\nexport function normalizeAngle(value: number): number {\n\tvalue = value % 360;\n\tif (value < 0) {\n\t\tvalue += 360;\n\t}\n\treturn value;\n}\n\n// TODO this doesn't work properly for skewing, and it's probably broken for rotation too\nexport function getArcBounds(cx: number, cy: number, startAngle: number, endAngle: number, radius: number): IBounds {\n\n\tlet minX = Number.MAX_VALUE;\n\tlet minY = Number.MAX_VALUE;\n\tlet maxX = -Number.MAX_VALUE;\n\tlet maxY = -Number.MAX_VALUE;\n\n\tlet bpoints = [];\n\n\tbpoints.push(getArcPoint(radius, startAngle));\n\tbpoints.push(getArcPoint(radius, endAngle));\n\n\tlet fromAngle = Math.min(Math.floor(startAngle / 90) * 90, Math.floor(endAngle / 90) * 90);\n\tlet toAngle = Math.max(Math.ceil(startAngle / 90) * 90, Math.ceil(endAngle / 90) * 90);\n\n\tfor (let angle = fromAngle; angle <= toAngle; angle += 90) {\n\t\tif (angle >= startAngle && angle <= endAngle) {\n\t\t\tbpoints.push(getArcPoint(radius, angle));\n\t\t}\n\t}\n\n\tfor (let i = 0; i < bpoints.length; i++) {\n\t\tlet pt = bpoints[i];\n\t\tif (pt.x < minX) { minX = pt.x; }\n\t\tif (pt.y < minY) { minY = pt.y; }\n\t\tif (pt.x > maxX) { maxX = pt.x; }\n\t\tif (pt.y > maxY) { maxY = pt.y; }\n\t}\n\n\treturn ({ left: cx + minX, top: cy + minY, right: cx + maxX, bottom: cy + maxY });\n}\n\n/**\n * Returns point on arc\n *\n * @param center point\n * @param radius\n * @param arc\n * @return {boolean}\n */\nexport function getArcPoint(radius: number, arc: number) {\n\treturn ({ x: radius * cos(arc), y: radius * sin(arc) });\n}\n\n\nexport function mergeBounds(bounds: IBounds[]): IBounds {\n\tconst len = bounds.length;\n\n\tif (len > 0) {\n\t\tlet bound = bounds[0];\n\t\tlet left = bound.left;\n\t\tlet top = bound.top;\n\t\tlet right = bound.right;\n\t\tlet bottom = bound.bottom;\n\n\t\tif (len > 1) {\n\t\t\tfor (let i = 1; i < len; i++) {\n\t\t\t\tbound = bounds[i];\n\t\t\t\tleft = Math.min(bound.left, left);\n\t\t\t\tright = Math.max(bound.right, right);\n\t\t\t\ttop = Math.min(bound.top, top);\n\t\t\t\tbottom = Math.max(bound.bottom, bottom);\n\t\t\t}\n\t\t}\n\n\t\treturn { left, right, top, bottom };\n\t}\n\treturn { left: 0, right: 0, top: 0, bottom: 0 };\n}\n\n\nexport function fitAngleToRange(value: number, startAngle: number, endAngle: number): number {\n\n\tif (startAngle > endAngle) {\n\t\tlet temp: number = startAngle;\n\t\tstartAngle = endAngle;\n\t\tendAngle = temp;\n\t}\n\n\tvalue = normalizeAngle(value);\n\n\tlet count = (startAngle - normalizeAngle(startAngle)) / 360;\n\n\tif (value < startAngle) {\n\t\tvalue += 360 * (count + 1);\n\t}\n\n\tlet maxEnd: number = startAngle + (endAngle - startAngle) / 2 + 180;\n\tlet maxStart: number = startAngle + (endAngle - startAngle) / 2 - 180;\n\n\tif (value > endAngle) {\n\n\t\tif (value - 360 > startAngle) {\n\t\t\tvalue -= 360;\n\t\t}\n\t\telse {\n\t\t\tif (value < maxEnd) {\n\t\t\t\tvalue = endAngle;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvalue = startAngle;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (value < startAngle) {\n\t\tif (value > maxStart) {\n\t\t\tvalue = startAngle;\n\t\t}\n\t\telse {\n\t\t\tvalue = endAngle;\n\t\t}\n\t}\n\n\treturn value;\n}\n\nexport function inBounds(point: IPoint, bounds: IBounds) {\n\tif (point.x >= bounds.left && point.y >= bounds.top && point.x <= bounds.right && point.y <= bounds.bottom) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport function getAngle(point1: IPoint, point2?: IPoint): number {\n\tif (!point2) {\n\t\tpoint2 = { x: point1.x * 2, y: point1.y * 2 };\n\t}\n\tlet diffX: number = point2.x - point1.x;\n\tlet diffY: number = point2.y - point1.y;\n\tlet angle: number = Math.atan2(diffY, diffX) * DEGREES;\n\tif (angle < 0) {\n\t\tangle += 360;\n\t}\n\treturn normalizeAngle(angle);\n}\n\n/**\n * [getPointOnQuadraticCurve description]\n *\n * @ignore Exclude from docs\n * @todo Description\n * @param pointA [description]\n * @param pointB [description]\n * @param controlPoint [description]\n * @param position [description]\n * @return [description]\n */\nexport function getPointOnQuadraticCurve(pointA: IPoint, pointB: IPoint, controlPoint: IPoint, position: number): IPoint {\n\tlet x: number = (1 - position) * (1 - position) * pointA.x + 2 * (1 - position) * position * controlPoint.x + position * position * pointB.x;\n\tlet y: number = (1 - position) * (1 - position) * pointA.y + 2 * (1 - position) * position * controlPoint.y + position * position * pointB.y;\n\treturn { x: x, y: y };\n}\n\nexport function getPointOnLine(pointA: IPoint, pointB: IPoint, position: number): IPoint {\n\treturn { x: pointA.x + (pointB.x - pointA.x) * position, y: pointA.y + (pointB.y - pointA.y) * position };\n}\n\n\n/**\n * Returns the closest value from the array of values to the reference value.\n *\n * @param values Array of values\n * @param value Reference value\n * @return Closes value from the array\n */\nexport function closest(values: number[], referenceValue: number): number {\n\treturn values.reduce(function(prev, curr) {\n\t\treturn (Math.abs(curr - referenceValue) < Math.abs(prev - referenceValue) ? curr : prev);\n\t});\n}\n\n/**\n * Returns true if bounds overlap\n * @param bounds1 IBounds\n * @param bounds2 IBounds\n * @returns boolean\n */\nexport function boundsOverlap(bounds1: IBounds, bounds2: IBounds): boolean {\n\tconst horizontalOverlap = bounds1.left < bounds2.right && bounds1.right > bounds2.left;\n\tconst verticalOverlap = bounds1.top < bounds2.bottom && bounds1.bottom > bounds2.top;\n\treturn horizontalOverlap && verticalOverlap;\n}\n\n/**\n * Generates points of a spiral\n * @param cx \n * @param cy \n * @param radius \n * @param radiusY \n * @param innerRadius \n * @param step \n * @param radiusStep \n * @param startAngle \n * @param endAngle \n * @returns IPoint[]\n */\nexport function spiralPoints(cx: number, cy: number, radius: number, radiusY: number, innerRadius: number, step: number, radiusStep: number, startAngle: number, endAngle: number): IPoint[] {\n\n\tlet r = innerRadius + 0.01;\n\tstartAngle = normalizeAngle(startAngle);\n\tendAngle = normalizeAngle(endAngle);\n\t\n\tlet angle = startAngle * RADIANS;\n\t\n\tif(endAngle < startAngle) {\n\t\tendAngle += 360;\n\t}\n\tlet points = [];\n\n\twhile (r < radius + radiusStep) {\n\n\t\tlet stepSize = step;\n\t\tif (stepSize / 2 > r) {\n\t\t\tstepSize = 2 * r;\n\t\t}\n\n\t\tlet c = Math.max(0.01, Math.min(1, r / 200));\n\n\t\tstepSize = stepSize * c;\n\t\n\t\tlet degrees = angle * DEGREES;\n\n\n\t\tlet point = { x: cx + r * Math.cos(angle), y: cy + r * radiusY / radius * Math.sin(angle) };\n\t\tpoints.push(point);\n\n\t\tr = innerRadius + 0.01 + (degrees - startAngle) / 360 * radiusStep;\n\n\t\tangle += 2 * Math.asin(stepSize / 2 / r);\n\n\t\tif (angle * DEGREES > endAngle + 360 * Math.ceil((radius - innerRadius) / radiusStep)) {\n\t\t\tbreak;\n\t\t}\t\t\n\t}\n\n\tpoints.shift();\n\n\treturn points;\n}\n\n/**\n * Returns true if circles overlap\n * @param circle1\n * @param circle2 \n * @returns boolean\n */\nexport function circlesOverlap(circle1: { x: number, y: number, radius: number }, circle2: { x: number, y: number, radius: number }): boolean {\n\treturn Math.hypot(circle1.x - circle2.x, circle1.y - circle2.y) <= circle1.radius + circle2.radius;\n}"]}
|
|
1
|
+
{"version":3,"file":"Math.js","sourceRoot":"","sources":["../../../../../src/.internal/core/util/Math.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;AAC1B,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,GAAG,EAAE,CAAC;AAEhC;;;;;;;GAOG;AACH,MA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EAAE,GAAG,CAAC,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5F,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEnB,CAAC,GAAG,WAAW,GAAG,IAAI,GAAG,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,GAAG,GAAG,UAAU,CAAC;QAEnE,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAEzC,IAAI,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,UAAU,CAAC,EAAE;YACtF,MAAM;SACN;KACD;IAED,MAAM,CAAC,KAAK,EAAE,CAAC;IAEf,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAiD,EAAE,OAAiD;IAClI,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACpG,CAAC","sourcesContent":["import type { IPoint } from \"./IPoint\";\nimport { isNumber } from \"./Type\";\nimport type { IBounds } from \"./IBounds\";\n\n/**\n * ============================================================================\n * CONSTANTS\n * ============================================================================\n * @hidden\n */\nexport const PI = Math.PI;\nexport const HALFPI = PI / 2;\nexport const RADIANS = PI / 180;\nexport const DEGREES = 180 / PI;\n\n/**\n * Rounds the numeric value to whole number or specific precision of set.\n *\n * @param value Value\n * @param precision Precision (number of decimal points)\n * @param floor In case value ends with 0.5 and precision is 0, we might need to floor the value instead of ceiling it.\n * @return Rounded value\n */\nexport function round(value: number, precision?: number, floor?: boolean): number {\n\tif (!isNumber(precision) || precision <= 0) {\n\n\t\tlet rounded = Math.round(value);\n\t\tif (floor) {\n\t\t\tif (rounded - value == 0.5) {\n\t\t\t\trounded--;\n\t\t\t}\n\t\t}\n\t\treturn rounded;\n\t}\n\telse {\n\t\tlet d: number = Math.pow(10, precision);\n\t\treturn Math.round(value * d) / d;\n\t}\n}\n\n\n/**\n * Ceils the numeric value to whole number or specific precision of set.\n *\n * @param value Value\n * @param precision Precision (number of decimal points)\n * @return Rounded value\n */\nexport function ceil(value: number, precision: number): number {\n\tif (!isNumber(precision) || precision <= 0) {\n\t\treturn Math.ceil(value);\n\t}\n\telse {\n\t\tlet d: number = Math.pow(10, precision);\n\t\treturn Math.ceil(value * d) / d;\n\t}\n}\n\n\n/**\n * Returns the first control point for a cubic bezier spline segment\n * interpolating through three consecutive points with the given tension.\n *\n * @ignore\n * @param p0 Previous point\n * @param p1 Current point\n * @param p2 Next point\n * @param tensionX Horizontal tension (0–1)\n * @param tensionY Vertical tension (0–1)\n * @return First control point\n */\nexport function getCubicControlPointA(p0: IPoint, p1: IPoint, p2: IPoint, tensionX: number, tensionY: number): IPoint {\n\treturn { x: ((-p0.x + p1.x / tensionX + p2.x) * tensionX), y: ((-p0.y + p1.y / tensionY + p2.y) * tensionY) };\n}\n\n/**\n * Returns the second control point for a cubic bezier spline segment\n * interpolating through three consecutive points with the given tension.\n *\n * @ignore\n * @param p1 Current point\n * @param p2 Next point\n * @param p3 Point after next\n * @param tensionX Horizontal tension (0–1)\n * @param tensionY Vertical tension (0–1)\n * @return Second control point\n */\nexport function getCubicControlPointB(p1: IPoint, p2: IPoint, p3: IPoint, tensionX: number, tensionY: number): IPoint {\n\treturn { x: ((p1.x + p2.x / tensionX - p3.x) * tensionX), y: ((p1.y + p2.y / tensionY - p3.y) * tensionY) };\n}\n\n/**\n * Clamps a value to the given [min, max] range.\n *\n * @param value Value to clamp\n * @param min Minimum\n * @param max Maximum\n * @return Clamped value\n */\nexport function fitToRange(value: number, min: number, max: number): number {\n\treturn Math.min(Math.max(value, min), max);\n}\n\n/**\n * Returns sine of an angle specified in degrees.\n *\n * @param value Value\n * @return Sine\n */\nexport function sin(angle: number): number {\n\treturn Math.sin(RADIANS * angle);\n}\n\n/**\n * Returns tan of an angle specified in degrees.\n *\n * @param value Value\n * @return Sine\n */\nexport function tan(angle: number): number {\n\treturn Math.tan(RADIANS * angle);\n}\n\n/**\n * Returns cosine of an angle specified in degrees.\n *\n * @param value Value\n * @return Cosine\n */\nexport function cos(angle: number): number {\n\treturn Math.cos(RADIANS * angle);\n}\n\n/**\n * Normalizes an angle to the 0–360 range.\n *\n * @param value Angle in degrees\n * @return Normalized angle (0–360)\n */\nexport function normalizeAngle(value: number): number {\n\tvalue = value % 360;\n\tif (value < 0) {\n\t\tvalue += 360;\n\t}\n\treturn value;\n}\n\n/**\n * Returns the bounding box of a circular arc.\n *\n * @param cx Center X\n * @param cy Center Y\n * @param startAngle Start angle in degrees\n * @param endAngle End angle in degrees\n * @param radius Arc radius\n * @return Bounding box\n */\nexport function getArcBounds(cx: number, cy: number, startAngle: number, endAngle: number, radius: number): IBounds {\n\n\tlet minX = Number.MAX_VALUE;\n\tlet minY = Number.MAX_VALUE;\n\tlet maxX = -Number.MAX_VALUE;\n\tlet maxY = -Number.MAX_VALUE;\n\n\tlet bpoints = [];\n\n\tbpoints.push(getArcPoint(radius, startAngle));\n\tbpoints.push(getArcPoint(radius, endAngle));\n\n\tlet fromAngle = Math.min(Math.floor(startAngle / 90) * 90, Math.floor(endAngle / 90) * 90);\n\tlet toAngle = Math.max(Math.ceil(startAngle / 90) * 90, Math.ceil(endAngle / 90) * 90);\n\n\tfor (let angle = fromAngle; angle <= toAngle; angle += 90) {\n\t\tif (angle >= startAngle && angle <= endAngle) {\n\t\t\tbpoints.push(getArcPoint(radius, angle));\n\t\t}\n\t}\n\n\tfor (let i = 0; i < bpoints.length; i++) {\n\t\tlet pt = bpoints[i];\n\t\tif (pt.x < minX) { minX = pt.x; }\n\t\tif (pt.y < minY) { minY = pt.y; }\n\t\tif (pt.x > maxX) { maxX = pt.x; }\n\t\tif (pt.y > maxY) { maxY = pt.y; }\n\t}\n\n\treturn ({ left: cx + minX, top: cy + minY, right: cx + maxX, bottom: cy + maxY });\n}\n\n/**\n * Returns a point on a circle at the given angle.\n *\n * @param radius Circle radius\n * @param arc Angle in degrees\n * @return Point on the arc\n */\nexport function getArcPoint(radius: number, arc: number) {\n\treturn ({ x: radius * cos(arc), y: radius * sin(arc) });\n}\n\n\n/**\n * Merges an array of bounds into a single bounding box that encompasses all of them.\n *\n * @param bounds Array of bounds to merge\n * @return Combined bounding box\n */\nexport function mergeBounds(bounds: IBounds[]): IBounds {\n\tconst len = bounds.length;\n\n\tif (len > 0) {\n\t\tlet bound = bounds[0];\n\t\tlet left = bound.left;\n\t\tlet top = bound.top;\n\t\tlet right = bound.right;\n\t\tlet bottom = bound.bottom;\n\n\t\tif (len > 1) {\n\t\t\tfor (let i = 1; i < len; i++) {\n\t\t\t\tbound = bounds[i];\n\t\t\t\tleft = Math.min(bound.left, left);\n\t\t\t\tright = Math.max(bound.right, right);\n\t\t\t\ttop = Math.min(bound.top, top);\n\t\t\t\tbottom = Math.max(bound.bottom, bottom);\n\t\t\t}\n\t\t}\n\n\t\treturn { left, right, top, bottom };\n\t}\n\treturn { left: 0, right: 0, top: 0, bottom: 0 };\n}\n\n\n/**\n * Fits an angle into the given start/end range, snapping to the\n * nearest boundary when the angle falls outside.\n *\n * @param value Angle in degrees\n * @param startAngle Range start in degrees\n * @param endAngle Range end in degrees\n * @return Angle clamped to the range\n */\nexport function fitAngleToRange(value: number, startAngle: number, endAngle: number): number {\n\n\tif (startAngle > endAngle) {\n\t\tlet temp: number = startAngle;\n\t\tstartAngle = endAngle;\n\t\tendAngle = temp;\n\t}\n\n\tvalue = normalizeAngle(value);\n\n\tlet count = (startAngle - normalizeAngle(startAngle)) / 360;\n\n\tif (value < startAngle) {\n\t\tvalue += 360 * (count + 1);\n\t}\n\n\tlet maxEnd: number = startAngle + (endAngle - startAngle) / 2 + 180;\n\tlet maxStart: number = startAngle + (endAngle - startAngle) / 2 - 180;\n\n\tif (value > endAngle) {\n\n\t\tif (value - 360 > startAngle) {\n\t\t\tvalue -= 360;\n\t\t}\n\t\telse {\n\t\t\tif (value < maxEnd) {\n\t\t\t\tvalue = endAngle;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvalue = startAngle;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (value < startAngle) {\n\t\tif (value > maxStart) {\n\t\t\tvalue = startAngle;\n\t\t}\n\t\telse {\n\t\t\tvalue = endAngle;\n\t\t}\n\t}\n\n\treturn value;\n}\n\n/**\n * Returns `true` if a point is inside the given bounds (inclusive).\n *\n * @param point Point to test\n * @param bounds Bounding box\n * @return Whether the point is inside\n */\nexport function inBounds(point: IPoint, bounds: IBounds) {\n\tif (point.x >= bounds.left && point.y >= bounds.top && point.x <= bounds.right && point.y <= bounds.bottom) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * Returns the angle in degrees from `point1` to `point2`.\n * If `point2` is omitted, uses double of `point1` coordinates.\n *\n * @param point1 Origin point\n * @param point2 Target point (optional)\n * @return Angle in degrees (0–360)\n */\nexport function getAngle(point1: IPoint, point2?: IPoint): number {\n\tif (!point2) {\n\t\tpoint2 = { x: point1.x * 2, y: point1.y * 2 };\n\t}\n\tlet diffX: number = point2.x - point1.x;\n\tlet diffY: number = point2.y - point1.y;\n\tlet angle: number = Math.atan2(diffY, diffX) * DEGREES;\n\tif (angle < 0) {\n\t\tangle += 360;\n\t}\n\treturn normalizeAngle(angle);\n}\n\n/**\n * Returns a point on a quadratic bezier curve at the given position (0–1).\n *\n * @param pointA Start point\n * @param pointB End point\n * @param controlPoint Control point\n * @param position Relative position (0 = start, 1 = end)\n * @return Point on the curve\n */\nexport function getPointOnQuadraticCurve(pointA: IPoint, pointB: IPoint, controlPoint: IPoint, position: number): IPoint {\n\tlet x: number = (1 - position) * (1 - position) * pointA.x + 2 * (1 - position) * position * controlPoint.x + position * position * pointB.x;\n\tlet y: number = (1 - position) * (1 - position) * pointA.y + 2 * (1 - position) * position * controlPoint.y + position * position * pointB.y;\n\treturn { x: x, y: y };\n}\n\n/**\n * Returns a point on a cubic bezier curve at the given position (0–1).\n *\n * @param pointA Start point\n * @param pointB End point\n * @param controlPointA First control point (near start)\n * @param controlPointB Second control point (near end)\n * @param position Relative position (0 = start, 1 = end)\n * @return Point on the curve\n */\nexport function getPointOnCubicCurve(pointA: IPoint, pointB: IPoint, controlPointA: IPoint, controlPointB: IPoint, position: number): IPoint {\n\tlet s = 1 - position;\n\tlet x = s * s * s * pointA.x + 3 * s * s * position * controlPointA.x + 3 * s * position * position * controlPointB.x + position * position * position * pointB.x;\n\tlet y = s * s * s * pointA.y + 3 * s * s * position * controlPointA.y + 3 * s * position * position * controlPointB.y + position * position * position * pointB.y;\n\treturn { x: x, y: y };\n}\n\n/**\n * Returns a point at a relative position along a straight line between two points.\n *\n * @param pointA Start point\n * @param pointB End point\n * @param position Relative position (0 = start, 1 = end)\n * @return Point on the line\n */\nexport function getPointOnLine(pointA: IPoint, pointB: IPoint, position: number): IPoint {\n\treturn { x: pointA.x + (pointB.x - pointA.x) * position, y: pointA.y + (pointB.y - pointA.y) * position };\n}\n\n/**\n * Given a normalized location (0–1) along a multi-segment path and an array\n * of cumulative segment lengths, returns which segment the location falls in\n * and the local parameter t within that segment.\n *\n * @param location Relative position along the full path (0–1)\n * @param cumulativeLengths Cumulative length at the end of each segment\n * @return Segment index and local t (0–1)\n */\nexport function resolveLocationOnPath(location: number, cumulativeLengths: number[]): { index: number; t: number } {\n\tconst n = cumulativeLengths.length;\n\tif (n > 0) {\n\t\tconst totalLength = cumulativeLengths[n - 1];\n\t\tconst targetLength = location * totalLength;\n\n\t\tlet index = 0;\n\t\tfor (let i = 0; i < n; i++) {\n\t\t\tif (cumulativeLengths[i] >= targetLength) {\n\t\t\t\tindex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst segStart = index > 0 ? cumulativeLengths[index - 1] : 0;\n\t\tconst segLength = cumulativeLengths[index] - segStart;\n\t\tconst t = segLength > 0 ? (targetLength - segStart) / segLength : 0;\n\t\treturn { index, t };\n\t}\n\treturn { index: 0, t: 0 };\n}\n\n\n/**\n * Returns the closest value from the array of values to the reference value.\n *\n * @param values Array of values\n * @param value Reference value\n * @return Closes value from the array\n */\nexport function closest(values: number[], referenceValue: number): number {\n\treturn values.reduce(function(prev, curr) {\n\t\treturn (Math.abs(curr - referenceValue) < Math.abs(prev - referenceValue) ? curr : prev);\n\t});\n}\n\n/**\n * Returns true if bounds overlap\n * @param bounds1 IBounds\n * @param bounds2 IBounds\n * @returns boolean\n */\nexport function boundsOverlap(bounds1: IBounds, bounds2: IBounds): boolean {\n\tconst horizontalOverlap = bounds1.left < bounds2.right && bounds1.right > bounds2.left;\n\tconst verticalOverlap = bounds1.top < bounds2.bottom && bounds1.bottom > bounds2.top;\n\treturn horizontalOverlap && verticalOverlap;\n}\n\n/**\n * Generates points along a spiral path.\n *\n * @param cx Center X\n * @param cy Center Y\n * @param radius Outer radius\n * @param radiusY Vertical radius (for elliptical spirals)\n * @param innerRadius Inner radius where the spiral starts\n * @param step Base step size between points\n * @param radiusStep Radius increase per full revolution\n * @param startAngle Start angle in degrees\n * @param endAngle End angle in degrees\n * @return Array of points along the spiral\n */\nexport function spiralPoints(cx: number, cy: number, radius: number, radiusY: number, innerRadius: number, step: number, radiusStep: number, startAngle: number, endAngle: number): IPoint[] {\n\n\tlet r = innerRadius + 0.01;\n\tstartAngle = normalizeAngle(startAngle);\n\tendAngle = normalizeAngle(endAngle);\n\t\n\tlet angle = startAngle * RADIANS;\n\t\n\tif(endAngle < startAngle) {\n\t\tendAngle += 360;\n\t}\n\tlet points = [];\n\n\twhile (r < radius + radiusStep) {\n\n\t\tlet stepSize = step;\n\t\tif (stepSize / 2 > r) {\n\t\t\tstepSize = 2 * r;\n\t\t}\n\n\t\tlet c = Math.max(0.01, Math.min(1, r / 200));\n\n\t\tstepSize = stepSize * c;\n\t\n\t\tlet degrees = angle * DEGREES;\n\n\n\t\tlet point = { x: cx + r * Math.cos(angle), y: cy + r * radiusY / radius * Math.sin(angle) };\n\t\tpoints.push(point);\n\n\t\tr = innerRadius + 0.01 + (degrees - startAngle) / 360 * radiusStep;\n\n\t\tangle += 2 * Math.asin(stepSize / 2 / r);\n\n\t\tif (angle * DEGREES > endAngle + 360 * Math.ceil((radius - innerRadius) / radiusStep)) {\n\t\t\tbreak;\n\t\t}\t\t\n\t}\n\n\tpoints.shift();\n\n\treturn points;\n}\n\n/**\n * Returns `true` if two circles overlap or touch.\n *\n * @param circle1 First circle (x, y, radius)\n * @param circle2 Second circle (x, y, radius)\n * @return Whether the circles overlap\n */\nexport function circlesOverlap(circle1: { x: number, y: number, radius: number }, circle2: { x: number, y: number, radius: number }): boolean {\n\treturn Math.hypot(circle1.x - circle2.x, circle1.y - circle2.y) <= circle1.radius + circle2.radius;\n}"]}
|