-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
284b3a3
commit efca428
Showing
10 changed files
with
4,755 additions
and
6,403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
{ | ||
"presets": ["es2015", "stage-0"] | ||
"presets": [ | ||
"@babel/preset-env" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-syntax-dynamic-import", | ||
"@babel/plugin-syntax-import-meta", | ||
"@babel/plugin-proposal-class-properties", | ||
"@babel/plugin-proposal-json-strings", | ||
[ | ||
"@babel/plugin-proposal-decorators", | ||
{ | ||
"legacy": true | ||
} | ||
], | ||
"@babel/plugin-proposal-function-sent", | ||
"@babel/plugin-proposal-export-namespace-from", | ||
"@babel/plugin-proposal-numeric-separator", | ||
"@babel/plugin-proposal-throw-expressions", | ||
"@babel/plugin-proposal-export-default-from", | ||
"@babel/plugin-proposal-logical-assignment-operators", | ||
"@babel/plugin-proposal-optional-chaining", | ||
[ | ||
"@babel/plugin-proposal-pipeline-operator", | ||
{ | ||
"proposal": "minimal" | ||
} | ||
], | ||
"@babel/plugin-proposal-nullish-coalescing-operator", | ||
"@babel/plugin-proposal-do-expressions", | ||
"@babel/plugin-proposal-function-bind" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,198 +1,120 @@ | ||
/* | ||
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). | ||
* This devtool is neither made for production nor for readable output files. | ||
* It uses "eval()" calls to create a separate source file in the browser devtools. | ||
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) | ||
* or disable the default devtool with "devtool: false". | ||
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). | ||
*/ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(require("@danehansen/math")); | ||
else if(typeof define === 'function' && define.amd) | ||
define(["@danehansen/math"], factory); | ||
else if(typeof exports === 'object') | ||
exports["point"] = factory(require("@danehansen/math")); | ||
exports["danehansen"] = factory(require("@danehansen/math")); | ||
else | ||
root["danehansen"] = root["danehansen"] || {}, root["danehansen"]["point"] = factory(root["danehansen"]["math"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_0__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
})(self, function(__WEBPACK_EXTERNAL_MODULE__danehansen_math__) { | ||
return /******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
/******/ var __webpack_modules__ = ({ | ||
|
||
/***/ "./src/point.js": | ||
/*!**********************!*\ | ||
!*** ./src/point.js ***! | ||
\**********************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
|
||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"add\": () => (/* binding */ add),\n/* harmony export */ \"angle\": () => (/* binding */ angle),\n/* harmony export */ \"distance\": () => (/* binding */ distance),\n/* harmony export */ \"interpolate\": () => (/* binding */ interpolate),\n/* harmony export */ \"intersection\": () => (/* binding */ intersection),\n/* harmony export */ \"length\": () => (/* binding */ length),\n/* harmony export */ \"normalize\": () => (/* binding */ normalize),\n/* harmony export */ \"polar\": () => (/* binding */ polar),\n/* harmony export */ \"randomPointInCircle\": () => (/* binding */ randomPointInCircle),\n/* harmony export */ \"rotate\": () => (/* binding */ rotate),\n/* harmony export */ \"round\": () => (/* binding */ round),\n/* harmony export */ \"toString\": () => (/* binding */ toString)\n/* harmony export */ });\n/* harmony import */ var _danehansen_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @danehansen/math */ \"@danehansen/math\");\n/* harmony import */ var _danehansen_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_danehansen_math__WEBPACK_IMPORTED_MODULE_0__);\n\nfunction add(a, b) {\n return {\n x: a.x + b.x,\n y: a.y + b.y\n };\n}\nfunction angle(point) {\n return Math.atan2(point.y, point.x);\n}\nfunction distance(a, b) {\n return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));\n}\nfunction interpolate(start, end, amount) {\n return {\n x: start.x + (end.x - start.x) * amount,\n y: start.y + (end.y - start.y) * amount\n };\n}\nfunction intersection(startA, endA, startB, endB) {\n var x1 = startA.x;\n var y1 = startA.y;\n var x2 = endA.x;\n var y2 = endA.y;\n var x3 = startB.x;\n var y3 = startB.y;\n var x4 = endB.x;\n var y4 = endB.y;\n var a = x1 - x2;\n var b = y3 - y4;\n var c = y1 - y2;\n var d = x3 - x4;\n var e = a * b - c * d;\n\n if (e === 0) {\n return null;\n }\n\n var f = x1 * y2 - y1 * x2;\n var g = x3 * y4 - y3 * x4;\n return {\n x: (f * d - a * g) / e,\n y: (f * b - c * g) / e\n };\n}\nfunction length(point) {\n return distance(point, {\n x: 0,\n y: 0\n });\n}\nfunction normalize(point, thickness) {\n var l = length(point);\n var ratio = thickness / l;\n return {\n x: point.x * ratio,\n y: point.y * ratio\n };\n}\nfunction polar(len, angle) {\n return {\n x: Math.cos(angle) * len,\n y: Math.sin(angle) * len\n };\n}\nfunction randomPointInCircle(center, radius) {\n var random = {};\n\n do {\n random.x = Math.random() * radius * 2 + center.x - radius;\n random.y = Math.random() * radius * 2 + center.y - radius;\n } while (distance(random, center) > radius);\n\n return random;\n}\nfunction rotate(point, angle) {\n var center = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {\n x: 0,\n y: 0\n };\n var sin = Math.sin(angle);\n var cos = Math.cos(angle);\n var x = point.x,\n y = point.y;\n var centerX = center.x;\n var centerY = center.y;\n x -= centerX;\n y -= centerY;\n return {\n x: x * cos - y * sin + centerX,\n y: x * sin + y * cos + centerY\n };\n}\nfunction round(point) {\n var increment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n return {\n x: (0,_danehansen_math__WEBPACK_IMPORTED_MODULE_0__.round)(point.x, increment),\n y: (0,_danehansen_math__WEBPACK_IMPORTED_MODULE_0__.round)(point.y, increment)\n };\n}\nfunction toString(point) {\n return \"{x: \".concat(point.x, \", y: \").concat(point.y, \"}\");\n}\n\n//# sourceURL=webpack://danehansen.point/./src/point.js?"); | ||
|
||
/***/ }), | ||
|
||
/***/ "@danehansen/math": | ||
/*!*************************************************************************************************************************************!*\ | ||
!*** external {"amd":"@danehansen/math","commonjs":"@danehansen/math","commonjs2":"@danehansen/math","root":["danehansen","math"]} ***! | ||
\*************************************************************************************************************************************/ | ||
/***/ ((module) => { | ||
|
||
module.exports = __WEBPACK_EXTERNAL_MODULE__danehansen_math__; | ||
|
||
/***/ }) | ||
|
||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // identity function for calling harmony imports with the correct context | ||
/******/ __webpack_require__.i = function(value) { return value; }; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 1); | ||
/******/ }) | ||
/******/ | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports) { | ||
|
||
module.exports = __WEBPACK_EXTERNAL_MODULE_0__; | ||
|
||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
|
||
"use strict"; | ||
|
||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.add = add; | ||
exports.angle = angle; | ||
exports.distance = distance; | ||
exports.interpolate = interpolate; | ||
exports.intersection = intersection; | ||
exports.length = length; | ||
exports.normalize = normalize; | ||
exports.polar = polar; | ||
exports.randomPointInCircle = randomPointInCircle; | ||
exports.rotate = rotate; | ||
exports.round = round; | ||
exports.toString = toString; | ||
|
||
var _math = __webpack_require__(0); | ||
|
||
function add(a, b) { | ||
return { x: a.x + b.x, y: a.y + b.y }; | ||
} | ||
|
||
function angle(point) { | ||
return Math.atan2(point.y, point.x); | ||
} | ||
|
||
function distance(a, b) { | ||
return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2)); | ||
} | ||
|
||
function interpolate(start, end, amount) { | ||
return { x: start.x + (end.x - start.x) * amount, y: start.y + (end.y - start.y) * amount }; | ||
} | ||
|
||
function intersection(startA, endA, startB, endB) { | ||
var x1 = startA.x; | ||
var y1 = startA.y; | ||
var x2 = endA.x; | ||
var y2 = endA.y; | ||
var x3 = startB.x; | ||
var y3 = startB.y; | ||
var x4 = endB.x; | ||
var y4 = endB.y; | ||
var a = x1 - x2; | ||
var b = y3 - y4; | ||
var c = y1 - y2; | ||
var d = x3 - x4; | ||
var e = a * b - c * d; | ||
if (e === 0) { | ||
return null; | ||
} | ||
var f = x1 * y2 - y1 * x2; | ||
var g = x3 * y4 - y3 * x4; | ||
return { x: (f * d - a * g) / e, y: (f * b - c * g) / e }; | ||
} | ||
|
||
function length(point) { | ||
return distance(point, { x: 0, y: 0 }); | ||
} | ||
|
||
function normalize(point, thickness) { | ||
var l = length(point); | ||
var ratio = thickness / l; | ||
return { x: point.x * ratio, y: point.y * ratio }; | ||
} | ||
|
||
function polar(len, angle) { | ||
return { x: Math.cos(angle) * len, y: Math.sin(angle) * len }; | ||
} | ||
|
||
function randomPointInCircle(center, radius) { | ||
var random = {}; | ||
do { | ||
random.x = Math.random() * radius * 2 + center.x - radius; | ||
random.y = Math.random() * radius * 2 + center.y - radius; | ||
} while (distance(random, center) > radius); | ||
return random; | ||
} | ||
|
||
function rotate(point, angle) { | ||
var center = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { x: 0, y: 0 }; | ||
|
||
var sin = Math.sin(angle); | ||
var cos = Math.cos(angle); | ||
var x = point.x, | ||
y = point.y; | ||
|
||
var centerX = center.x; | ||
var centerY = center.y; | ||
x -= centerX; | ||
y -= centerY; | ||
return { x: x * cos - y * sin + centerX, y: x * sin + y * cos + centerY }; | ||
} | ||
|
||
function round(point) { | ||
var increment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; | ||
|
||
return { x: (0, _math.round)(point.x, increment), y: (0, _math.round)(point.y, increment) }; | ||
} | ||
|
||
function toString(point) { | ||
return '{x: ' + point.x + ', y: ' + point.y + '}'; | ||
} | ||
|
||
/***/ }) | ||
/******/ ]); | ||
/******/ /* webpack/runtime/compat get default export */ | ||
/******/ (() => { | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = (module) => { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ () => (module['default']) : | ||
/******/ () => (module); | ||
/******/ __webpack_require__.d(getter, { a: getter }); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/define property getters */ | ||
/******/ (() => { | ||
/******/ // define getter functions for harmony exports | ||
/******/ __webpack_require__.d = (exports, definition) => { | ||
/******/ for(var key in definition) { | ||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | ||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | ||
/******/ } | ||
/******/ } | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/hasOwnProperty shorthand */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/make namespace object */ | ||
/******/ (() => { | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = (exports) => { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/************************************************************************/ | ||
/******/ | ||
/******/ // startup | ||
/******/ // Load entry module and return exports | ||
/******/ // This entry module can't be inlined because the eval devtool is used. | ||
/******/ var __webpack_exports__ = __webpack_require__("./src/point.js"); | ||
/******/ | ||
/******/ return __webpack_exports__; | ||
/******/ })() | ||
; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.