Download node_modules/d3-geo/src/path/area.js from NKessler/Horizon: direct link, hf CLI and curl.
- Browser
- Download file 973 Bytes
-
https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-geo/src/path/area.js
- Command line
-
hf download hf://NKessler/Horizon/node_modules/d3-geo/src/path/area.js
-
curl -L -o area.js https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-geo/src/path/area.js
973 Bytes
| import {Adder} from "d3-array"; | |
| import {abs} from "../math.js"; | |
| import noop from "../noop.js"; | |
| var areaSum = new Adder(), | |
| areaRingSum = new Adder(), | |
| x00, | |
| y00, | |
| x0, | |
| y0; | |
| var areaStream = { | |
| point: noop, | |
| lineStart: noop, | |
| lineEnd: noop, | |
| polygonStart: function() { | |
| areaStream.lineStart = areaRingStart; | |
| areaStream.lineEnd = areaRingEnd; | |
| }, | |
| polygonEnd: function() { | |
| areaStream.lineStart = areaStream.lineEnd = areaStream.point = noop; | |
| areaSum.add(abs(areaRingSum)); | |
| areaRingSum = new Adder(); | |
| }, | |
| result: function() { | |
| var area = areaSum / 2; | |
| areaSum = new Adder(); | |
| return area; | |
| } | |
| }; | |
| function areaRingStart() { | |
| areaStream.point = areaPointFirst; | |
| } | |
| function areaPointFirst(x, y) { | |
| areaStream.point = areaPoint; | |
| x00 = x0 = x, y00 = y0 = y; | |
| } | |
| function areaPoint(x, y) { | |
| areaRingSum.add(y0 * x - x0 * y); | |
| x0 = x, y0 = y; | |
| } | |
| function areaRingEnd() { | |
| areaPoint(x00, y00); | |
| } | |
| export default areaStream; | |