@pie-lib/tools 2.0.2 → 2.0.3-next.0
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/dist/_virtual/_rolldown/runtime.js +11 -0
- package/dist/anchor-utils.d.ts +60 -0
- package/dist/anchor-utils.js +87 -0
- package/dist/anchor.d.ts +13 -0
- package/dist/anchor.js +17 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +5 -0
- package/dist/node_modules/.bun/assert@1.5.1/node_modules/assert/assert.js +174 -0
- package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/actualApply.js +13 -0
- package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionApply.js +8 -0
- package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionCall.js +8 -0
- package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/index.js +16 -0
- package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/reflectApply.js +8 -0
- package/dist/node_modules/.bun/call-bound@1.0.4/node_modules/call-bound/index.js +14 -0
- package/dist/node_modules/.bun/degrees-radians@1.0.3/node_modules/degrees-radians/index.js +12 -0
- package/dist/node_modules/.bun/dunder-proto@1.0.1/node_modules/dunder-proto/get.js +19 -0
- package/dist/node_modules/.bun/es-define-property@1.0.1/node_modules/es-define-property/index.js +14 -0
- package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/eval.js +8 -0
- package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/index.js +8 -0
- package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/range.js +8 -0
- package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/ref.js +8 -0
- package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/syntax.js +8 -0
- package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/type.js +8 -0
- package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/uri.js +8 -0
- package/dist/node_modules/.bun/es-object-atoms@1.1.2/node_modules/es-object-atoms/index.js +8 -0
- package/dist/node_modules/.bun/function-bind@1.1.2/node_modules/function-bind/implementation.js +34 -0
- package/dist/node_modules/.bun/function-bind@1.1.2/node_modules/function-bind/index.js +10 -0
- package/dist/node_modules/.bun/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js +283 -0
- package/dist/node_modules/.bun/get-proto@1.0.1/node_modules/get-proto/Object.getPrototypeOf.js +9 -0
- package/dist/node_modules/.bun/get-proto@1.0.1/node_modules/get-proto/Reflect.getPrototypeOf.js +8 -0
- package/dist/node_modules/.bun/get-proto@1.0.1/node_modules/get-proto/index.js +19 -0
- package/dist/node_modules/.bun/gopd@1.2.0/node_modules/gopd/gOPD.js +8 -0
- package/dist/node_modules/.bun/gopd@1.2.0/node_modules/gopd/index.js +15 -0
- package/dist/node_modules/.bun/has-symbols@1.1.0/node_modules/has-symbols/index.js +12 -0
- package/dist/node_modules/.bun/has-symbols@1.1.0/node_modules/has-symbols/shams.js +23 -0
- package/dist/node_modules/.bun/hasown@2.0.4/node_modules/hasown/index.js +10 -0
- package/dist/node_modules/.bun/inherits@2.0.3/node_modules/inherits/inherits_browser.js +19 -0
- package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/abs.js +8 -0
- package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/floor.js +8 -0
- package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/isNaN.js +10 -0
- package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/max.js +8 -0
- package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/min.js +8 -0
- package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/pow.js +8 -0
- package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/round.js +8 -0
- package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js +12 -0
- package/dist/node_modules/.bun/object-keys@1.1.1/node_modules/object-keys/implementation.js +77 -0
- package/dist/node_modules/.bun/object-keys@1.1.1/node_modules/object-keys/index.js +20 -0
- package/dist/node_modules/.bun/object-keys@1.1.1/node_modules/object-keys/isArguments.js +12 -0
- package/dist/node_modules/.bun/object.assign@4.1.7/node_modules/object.assign/implementation.js +29 -0
- package/dist/node_modules/.bun/object.assign@4.1.7/node_modules/object.assign/polyfill.js +27 -0
- package/dist/node_modules/.bun/radians-degrees@1.0.0/node_modules/radians-degrees/index.js +11 -0
- package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/LegacyPortal.js +77 -0
- package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/Portal.js +55 -0
- package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/PortalCompat.js +9 -0
- package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/utils.js +4 -0
- package/dist/node_modules/.bun/trigonometry-calculator@2.0.0/node_modules/trigonometry-calculator/lib/index.js +53 -0
- package/dist/node_modules/.bun/trigonometry-equations@2.0.1/node_modules/trigonometry-equations/lib/index.js +129 -0
- package/dist/node_modules/.bun/util@0.10.4/node_modules/util/support/isBufferBrowser.js +10 -0
- package/dist/node_modules/.bun/util@0.10.4/node_modules/util/util.js +262 -0
- package/dist/protractor/graphic.d.ts +13 -0
- package/dist/protractor/graphic.js +85 -0
- package/dist/protractor/index.d.ts +29 -0
- package/dist/protractor/index.js +56 -0
- package/dist/rotatable.d.ts +56 -0
- package/dist/rotatable.js +210 -0
- package/dist/ruler/graphic.d.ts +20 -0
- package/dist/ruler/graphic.js +53 -0
- package/dist/ruler/index.d.ts +32 -0
- package/dist/ruler/index.js +77 -0
- package/dist/ruler/unit-type.d.ts +30 -0
- package/dist/ruler/unit-type.js +38 -0
- package/dist/ruler/unit.d.ts +21 -0
- package/dist/ruler/unit.js +69 -0
- package/dist/style-utils.d.ts +12 -0
- package/dist/style-utils.js +5 -0
- package/dist/transform-origin.d.ts +18 -0
- package/dist/transform-origin.js +21 -0
- package/package.json +31 -25
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -626
- package/LICENSE.md +0 -5
- package/lib/anchor-utils.js +0 -193
- package/lib/anchor-utils.js.map +0 -1
- package/lib/anchor.js +0 -33
- package/lib/anchor.js.map +0 -1
- package/lib/index.js +0 -33
- package/lib/index.js.map +0 -1
- package/lib/protractor/graphic.js +0 -147
- package/lib/protractor/graphic.js.map +0 -1
- package/lib/protractor/index.js +0 -90
- package/lib/protractor/index.js.map +0 -1
- package/lib/rotatable.js +0 -335
- package/lib/rotatable.js.map +0 -1
- package/lib/ruler/graphic.js +0 -89
- package/lib/ruler/graphic.js.map +0 -1
- package/lib/ruler/index.js +0 -114
- package/lib/ruler/index.js.map +0 -1
- package/lib/ruler/unit-type.js +0 -55
- package/lib/ruler/unit-type.js.map +0 -1
- package/lib/ruler/unit.js +0 -124
- package/lib/ruler/unit.js.map +0 -1
- package/lib/style-utils.js +0 -21
- package/lib/style-utils.js.map +0 -1
- package/lib/transform-origin.js +0 -71
- package/lib/transform-origin.js.map +0 -1
- package/src/__tests__/anchor-utils.test.js +0 -131
- package/src/__tests__/rotatable.test.jsx +0 -263
- package/src/__tests__/transform-origin.test.jsx +0 -24
- package/src/anchor-utils.js +0 -153
- package/src/anchor.jsx +0 -20
- package/src/index.js +0 -6
- package/src/protractor/__tests__/graphic.test.jsx +0 -64
- package/src/protractor/__tests__/index.test.jsx +0 -65
- package/src/protractor/graphic.jsx +0 -82
- package/src/protractor/index.jsx +0 -67
- package/src/rotatable.jsx +0 -290
- package/src/ruler/__tests__/graphic.test.jsx +0 -64
- package/src/ruler/__tests__/index.test.jsx +0 -85
- package/src/ruler/__tests__/unit-type.test.jsx +0 -66
- package/src/ruler/__tests__/unit.test.jsx +0 -68
- package/src/ruler/graphic.jsx +0 -48
- package/src/ruler/index.jsx +0 -78
- package/src/ruler/unit-type.jsx +0 -39
- package/src/ruler/unit.jsx +0 -83
- package/src/style-utils.js +0 -7
- package/src/transform-origin.jsx +0 -60
package/lib/ruler/unit-type.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = exports.UnitType = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
var _styleUtils = require("../style-utils");
|
|
12
|
-
var _styles = require("@mui/material/styles");
|
|
13
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
-
var StyledText = (0, _styles.styled)('text')(function (_ref) {
|
|
16
|
-
var theme = _ref.theme;
|
|
17
|
-
return _objectSpread(_objectSpread({}, (0, _styleUtils.noSelect)()), {}, {
|
|
18
|
-
fill: (0, _styleUtils.strokeColor)(theme)
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
var UnitType = exports.UnitType = function UnitType(props) {
|
|
22
|
-
var label = props.label,
|
|
23
|
-
x = props.x,
|
|
24
|
-
y = props.y,
|
|
25
|
-
textAlign = props.textAlign,
|
|
26
|
-
fill = props.fill,
|
|
27
|
-
fontSize = props.fontSize,
|
|
28
|
-
stroke = props.stroke;
|
|
29
|
-
return /*#__PURE__*/_react["default"].createElement(StyledText, {
|
|
30
|
-
x: x,
|
|
31
|
-
y: y,
|
|
32
|
-
textAnchor: textAlign,
|
|
33
|
-
stroke: stroke,
|
|
34
|
-
fill: fill,
|
|
35
|
-
fontSize: fontSize
|
|
36
|
-
}, label);
|
|
37
|
-
};
|
|
38
|
-
UnitType.propTypes = {
|
|
39
|
-
label: _propTypes["default"].string.isRequired,
|
|
40
|
-
x: _propTypes["default"].number,
|
|
41
|
-
y: _propTypes["default"].number,
|
|
42
|
-
textAlign: _propTypes["default"].string,
|
|
43
|
-
fill: _propTypes["default"].string,
|
|
44
|
-
fontSize: _propTypes["default"].number,
|
|
45
|
-
stroke: _propTypes["default"].string
|
|
46
|
-
};
|
|
47
|
-
UnitType.defaultProps = {
|
|
48
|
-
textAnchor: 'start',
|
|
49
|
-
fontSize: 11,
|
|
50
|
-
stroke: 'none',
|
|
51
|
-
x: 8,
|
|
52
|
-
y: 14
|
|
53
|
-
};
|
|
54
|
-
var _default = exports["default"] = UnitType;
|
|
55
|
-
//# sourceMappingURL=unit-type.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unit-type.js","names":["_react","_interopRequireDefault","require","_propTypes","_styleUtils","_styles","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","StyledText","styled","_ref","theme","noSelect","fill","strokeColor","UnitType","exports","props","label","x","y","textAlign","fontSize","stroke","createElement","textAnchor","propTypes","PropTypes","string","isRequired","number","defaultProps","_default"],"sources":["../../src/ruler/unit-type.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { noSelect, strokeColor } from '../style-utils';\nimport { styled } from '@mui/material/styles';\n\nconst StyledText = styled('text')(({ theme }) => ({\n ...noSelect(),\n fill: strokeColor(theme),\n}));\n\nexport const UnitType = (props) => {\n const { label, x, y, textAlign, fill, fontSize, stroke } = props;\n\n return (\n <StyledText x={x} y={y} textAnchor={textAlign} stroke={stroke} fill={fill} fontSize={fontSize}>\n {label}\n </StyledText>\n );\n};\n\nUnitType.propTypes = {\n label: PropTypes.string.isRequired,\n x: PropTypes.number,\n y: PropTypes.number,\n textAlign: PropTypes.string,\n fill: PropTypes.string,\n fontSize: PropTypes.number,\n stroke: PropTypes.string,\n};\n\nUnitType.defaultProps = {\n textAnchor: 'start',\n fontSize: 11,\n stroke: 'none',\n x: 8,\n y: 14,\n};\n\nexport default UnitType;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAA8C,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,C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,GAAKN,KAAK,CAAhBM,MAAM;EAEtD,oBACE1C,MAAA,YAAA2C,aAAA,CAAChB,UAAU;IAACW,CAAC,EAAEA,CAAE;IAACC,CAAC,EAAEA,CAAE;IAACK,UAAU,EAAEJ,SAAU;IAACE,MAAM,EAAEA,MAAO;IAACV,IAAI,EAAEA,IAAK;IAACS,QAAQ,EAAEA;EAAS,GAC3FJ,KACS,CAAC;AAEjB,CAAC;AAEDH,QAAQ,CAACW,SAAS,GAAG;EACnBR,KAAK,EAAES,qBAAS,CAACC,MAAM,CAACC,UAAU;EAClCV,CAAC,EAAEQ,qBAAS,CAACG,MAAM;EACnBV,CAAC,EAAEO,qBAAS,CAACG,MAAM;EACnBT,SAAS,EAAEM,qBAAS,CAACC,MAAM;EAC3Bf,IAAI,EAAEc,qBAAS,CAACC,MAAM;EACtBN,QAAQ,EAAEK,qBAAS,CAACG,MAAM;EAC1BP,MAAM,EAAEI,qBAAS,CAACC;AACpB,CAAC;AAEDb,QAAQ,CAACgB,YAAY,GAAG;EACtBN,UAAU,EAAE,OAAO;EACnBH,QAAQ,EAAE,EAAE;EACZC,MAAM,EAAE,MAAM;EACdJ,CAAC,EAAE,CAAC;EACJC,CAAC,EAAE;AACL,CAAC;AAAC,IAAAY,QAAA,GAAAhB,OAAA,cAEaD,QAAQ","ignoreList":[]}
|
package/lib/ruler/unit.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = exports.Unit = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
11
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
|
-
var _styles = require("@mui/material/styles");
|
|
17
|
-
var _styleUtils = require("../style-utils");
|
|
18
|
-
var _lodashEs = require("lodash-es");
|
|
19
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
20
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
21
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
|
-
var StyledTick = (0, _styles.styled)('line')(function (_ref) {
|
|
24
|
-
var theme = _ref.theme;
|
|
25
|
-
return {
|
|
26
|
-
stroke: (0, _styleUtils.strokeColor)(theme)
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
var Tick = function Tick(_ref2) {
|
|
30
|
-
var x = _ref2.x,
|
|
31
|
-
height = _ref2.height,
|
|
32
|
-
bottom = _ref2.bottom,
|
|
33
|
-
major = _ref2.major,
|
|
34
|
-
minor = _ref2.minor;
|
|
35
|
-
var y1 = major ? bottom - height * 2 : minor ? bottom - height * 1.5 : bottom - height;
|
|
36
|
-
return /*#__PURE__*/_react["default"].createElement(StyledTick, {
|
|
37
|
-
y1: y1,
|
|
38
|
-
y2: bottom,
|
|
39
|
-
x1: x,
|
|
40
|
-
x2: x
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
var Ticks = function Ticks(_ref3) {
|
|
44
|
-
var count = _ref3.count,
|
|
45
|
-
width = _ref3.width,
|
|
46
|
-
height = _ref3.height;
|
|
47
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (0, _lodashEs.range)(1, count).map(function (r) {
|
|
48
|
-
return /*#__PURE__*/_react["default"].createElement(Tick, {
|
|
49
|
-
key: r,
|
|
50
|
-
value: r,
|
|
51
|
-
x: r * (width / count),
|
|
52
|
-
major: r % (count / 2) === 0,
|
|
53
|
-
minor: r % (count / 4) === 0,
|
|
54
|
-
bottom: height,
|
|
55
|
-
height: 10
|
|
56
|
-
});
|
|
57
|
-
}));
|
|
58
|
-
};
|
|
59
|
-
Ticks.propTypes = {
|
|
60
|
-
count: _propTypes["default"].number.isRequired,
|
|
61
|
-
width: _propTypes["default"].number.isRequired,
|
|
62
|
-
height: _propTypes["default"].number.isRequired
|
|
63
|
-
};
|
|
64
|
-
var StyledEndTick = (0, _styles.styled)('line')(function (_ref4) {
|
|
65
|
-
var theme = _ref4.theme;
|
|
66
|
-
return {
|
|
67
|
-
stroke: (0, _styleUtils.strokeColor)(theme),
|
|
68
|
-
strokeWidth: 1
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
var StyledLabel = (0, _styles.styled)('text')(function (_ref5) {
|
|
72
|
-
var theme = _ref5.theme;
|
|
73
|
-
return _objectSpread({
|
|
74
|
-
textAnchor: 'end',
|
|
75
|
-
fontSize: '12px',
|
|
76
|
-
fill: (0, _styleUtils.strokeColor)(theme)
|
|
77
|
-
}, (0, _styleUtils.noSelect)());
|
|
78
|
-
});
|
|
79
|
-
var Unit = exports.Unit = /*#__PURE__*/function (_React$Component) {
|
|
80
|
-
function Unit() {
|
|
81
|
-
(0, _classCallCheck2["default"])(this, Unit);
|
|
82
|
-
return _callSuper(this, Unit, arguments);
|
|
83
|
-
}
|
|
84
|
-
(0, _inherits2["default"])(Unit, _React$Component);
|
|
85
|
-
return (0, _createClass2["default"])(Unit, [{
|
|
86
|
-
key: "render",
|
|
87
|
-
value: function render() {
|
|
88
|
-
var _this$props = this.props,
|
|
89
|
-
index = _this$props.index,
|
|
90
|
-
width = _this$props.width,
|
|
91
|
-
height = _this$props.height,
|
|
92
|
-
last = _this$props.last,
|
|
93
|
-
config = _this$props.config;
|
|
94
|
-
var style = {
|
|
95
|
-
transform: "translate(".concat(width * (index - 1), "px, 0px)")
|
|
96
|
-
};
|
|
97
|
-
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
98
|
-
style: style
|
|
99
|
-
}, !last && /*#__PURE__*/_react["default"].createElement(StyledEndTick, {
|
|
100
|
-
x1: width,
|
|
101
|
-
y1: 0,
|
|
102
|
-
x2: width,
|
|
103
|
-
y2: height
|
|
104
|
-
}), /*#__PURE__*/_react["default"].createElement(Ticks, {
|
|
105
|
-
count: config.ticks,
|
|
106
|
-
width: width,
|
|
107
|
-
height: height
|
|
108
|
-
}), /*#__PURE__*/_react["default"].createElement(StyledLabel, {
|
|
109
|
-
width: width,
|
|
110
|
-
x: width - 5,
|
|
111
|
-
y: 15
|
|
112
|
-
}, index));
|
|
113
|
-
}
|
|
114
|
-
}]);
|
|
115
|
-
}(_react["default"].Component);
|
|
116
|
-
(0, _defineProperty2["default"])(Unit, "propTypes", {
|
|
117
|
-
index: _propTypes["default"].number.isRequired,
|
|
118
|
-
width: _propTypes["default"].number.isRequired,
|
|
119
|
-
height: _propTypes["default"].number.isRequired,
|
|
120
|
-
last: _propTypes["default"].bool.isRequired,
|
|
121
|
-
config: _propTypes["default"].object.isRequired
|
|
122
|
-
});
|
|
123
|
-
var _default = exports["default"] = Unit;
|
|
124
|
-
//# sourceMappingURL=unit.js.map
|
package/lib/ruler/unit.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unit.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_styleUtils","_lodashEs","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","ownKeys","r","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","StyledTick","styled","_ref","theme","stroke","strokeColor","Tick","_ref2","x","height","bottom","major","minor","y1","createElement","y2","x1","x2","Ticks","_ref3","count","width","Fragment","range","map","key","value","propTypes","PropTypes","number","isRequired","StyledEndTick","_ref4","strokeWidth","StyledLabel","_ref5","textAnchor","fontSize","fill","noSelect","Unit","exports","_React$Component","_classCallCheck2","_inherits2","_createClass2","render","_this$props","props","index","last","config","style","transform","concat","ticks","y","React","Component","bool","object","_default"],"sources":["../../src/ruler/unit.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { noSelect, strokeColor } from '../style-utils';\nimport { range } from 'lodash-es';\n\nconst StyledTick = styled('line')(({ theme }) => ({\n stroke: strokeColor(theme),\n}));\n\nconst Tick = ({ x, height, bottom, major, minor }) => {\n const y1 = major ? bottom - height * 2 : minor ? bottom - height * 1.5 : bottom - height;\n\n return <StyledTick y1={y1} y2={bottom} x1={x} x2={x} />;\n};\n\nconst Ticks = ({ count, width, height }) => {\n return (\n <React.Fragment>\n {range(1, count).map((r) => {\n return (\n <Tick\n key={r}\n value={r}\n x={r * (width / count)}\n major={r % (count / 2) === 0}\n minor={r % (count / 4) === 0}\n bottom={height}\n height={10}\n />\n );\n })}\n </React.Fragment>\n );\n};\n\nTicks.propTypes = {\n count: PropTypes.number.isRequired,\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired,\n};\n\nconst StyledEndTick = styled('line')(({ theme }) => ({\n stroke: strokeColor(theme),\n strokeWidth: 1,\n}));\n\nconst StyledLabel = styled('text')(({ theme }) => ({\n textAnchor: 'end',\n fontSize: '12px',\n fill: strokeColor(theme),\n ...noSelect(),\n}));\n\nexport class Unit extends React.Component {\n static propTypes = {\n index: PropTypes.number.isRequired,\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired,\n last: PropTypes.bool.isRequired,\n config: PropTypes.object.isRequired,\n };\n\n render() {\n const { index, width, height, last, config } = this.props;\n\n const style = {\n transform: `translate(${width * (index - 1)}px, 0px)`,\n };\n return (\n <g style={style}>\n {!last && <StyledEndTick x1={width} y1={0} x2={width} y2={height} />}\n\n <Ticks count={config.ticks} width={width} height={height} />\n <StyledLabel width={width} x={width - 5} y={15}>\n {index}\n </StyledLabel>\n </g>\n );\n }\n}\n\nexport default Unit;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAAkC,SAAAK,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aAAAF,CAAA,OAAAG,2BAAA,aAAAJ,CAAA,EAAAK,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAN,CAAA,EAAAC,CAAA,YAAAC,gBAA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qBAAS,CAACC,MAAM,CAACC,UAAU;EAClCrB,MAAM,EAAEmB,qBAAS,CAACC,MAAM,CAACC,UAAU;EACnCoB,IAAI,EAAEtB,qBAAS,CAAC+B,IAAI,CAAC7B,UAAU;EAC/BqB,MAAM,EAAEvB,qBAAS,CAACgC,MAAM,CAAC9B;AAC3B,CAAC;AAAA,IAAA+B,QAAA,GAAApB,OAAA,cAqBYD,IAAI","ignoreList":[]}
|
package/lib/style-utils.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fillColor = void 0;
|
|
7
|
-
Object.defineProperty(exports, "noSelect", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function get() {
|
|
10
|
-
return _styleUtils.noSelect;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
exports.strokeColor = void 0;
|
|
14
|
-
var _styleUtils = require("@pie-lib/style-utils");
|
|
15
|
-
var strokeColor = exports.strokeColor = function strokeColor(theme) {
|
|
16
|
-
return "var(--ruler-stroke, ".concat(theme.palette.primary.main, ")");
|
|
17
|
-
};
|
|
18
|
-
var fillColor = exports.fillColor = function fillColor(theme) {
|
|
19
|
-
return "var(--ruler-bg, ".concat(theme.palette.primary.contrastText, ")");
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=style-utils.js.map
|
package/lib/style-utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style-utils.js","names":["_styleUtils","require","strokeColor","exports","theme","concat","palette","primary","main","fillColor","contrastText"],"sources":["../src/style-utils.js"],"sourcesContent":["import { noSelect } from '@pie-lib/style-utils';\n\nexport { noSelect };\n\nexport const strokeColor = (theme) => `var(--ruler-stroke, ${theme.palette.primary.main})`;\n\nexport const fillColor = (theme) => `var(--ruler-bg, ${theme.palette.primary.contrastText})`;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAIO,IAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,SAAdA,WAAWA,CAAIE,KAAK;EAAA,8BAAAC,MAAA,CAA4BD,KAAK,CAACE,OAAO,CAACC,OAAO,CAACC,IAAI;AAAA,CAAG;AAEnF,IAAMC,SAAS,GAAAN,OAAA,CAAAM,SAAA,GAAG,SAAZA,SAASA,CAAIL,KAAK;EAAA,0BAAAC,MAAA,CAAwBD,KAAK,CAACE,OAAO,CAACC,OAAO,CAACG,YAAY;AAAA,CAAG","ignoreList":[]}
|
package/lib/transform-origin.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parse = void 0;
|
|
7
|
-
var keyWordToPercent = function keyWordToPercent(v) {
|
|
8
|
-
if (v === 'left' || v === 'top') {
|
|
9
|
-
return 0;
|
|
10
|
-
} else if (v === 'right' || v === 'bottom') {
|
|
11
|
-
return 100;
|
|
12
|
-
} else if (v === 'center') {
|
|
13
|
-
return 50;
|
|
14
|
-
} else if (v.endsWith('%')) {
|
|
15
|
-
return parseFloat(v);
|
|
16
|
-
} else {
|
|
17
|
-
return v;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var getValue = function getValue(s, length) {
|
|
21
|
-
if (s.endsWith('px')) {
|
|
22
|
-
return parseFloat(s);
|
|
23
|
-
} else {
|
|
24
|
-
s = keyWordToPercent(s);
|
|
25
|
-
var v = length * (s / 100);
|
|
26
|
-
return v;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var normalize = function normalize(a) {
|
|
30
|
-
if (a[0] === 'bottom' || a[0] === 'top' || a[1] === 'left' || a[1] === 'right') {
|
|
31
|
-
return [a[1], a[0]];
|
|
32
|
-
} else {
|
|
33
|
-
return a;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Parse a transform origin string to x/y values.
|
|
39
|
-
* @param {{width: number, height: number}} rect
|
|
40
|
-
* @param {string} value
|
|
41
|
-
* @returns {x:number, y:number}
|
|
42
|
-
*/
|
|
43
|
-
var parse = exports.parse = function parse(rect, value) {
|
|
44
|
-
if (!value) {
|
|
45
|
-
return {
|
|
46
|
-
x: rect.width / 2,
|
|
47
|
-
y: rect.height / 2
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
var arr = value.split(' ');
|
|
51
|
-
if (arr.length === 1) {
|
|
52
|
-
//1 val
|
|
53
|
-
var x = getValue(arr[0], rect.width);
|
|
54
|
-
var y = getValue('50%', rect.height);
|
|
55
|
-
return {
|
|
56
|
-
x: x,
|
|
57
|
-
y: y
|
|
58
|
-
};
|
|
59
|
-
} else if (arr.length === 2) {
|
|
60
|
-
var sorted = normalize(arr);
|
|
61
|
-
var _x = getValue(sorted[0], rect.width);
|
|
62
|
-
var _y = getValue(sorted[1], rect.height);
|
|
63
|
-
return {
|
|
64
|
-
x: _x,
|
|
65
|
-
y: _y
|
|
66
|
-
};
|
|
67
|
-
} else if (arr.length === 3) {
|
|
68
|
-
throw new Error('transform-origin values with 3 fields not supported.');
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=transform-origin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform-origin.js","names":["keyWordToPercent","v","endsWith","parseFloat","getValue","s","length","normalize","a","parse","exports","rect","value","x","width","y","height","arr","split","sorted","Error"],"sources":["../src/transform-origin.jsx"],"sourcesContent":["const keyWordToPercent = (v) => {\n if (v === 'left' || v === 'top') {\n return 0;\n } else if (v === 'right' || v === 'bottom') {\n return 100;\n } else if (v === 'center') {\n return 50;\n } else if (v.endsWith('%')) {\n return parseFloat(v);\n } else {\n return v;\n }\n};\n\nconst getValue = (s, length) => {\n if (s.endsWith('px')) {\n return parseFloat(s);\n } else {\n s = keyWordToPercent(s);\n const v = length * (s / 100);\n return v;\n }\n};\n\nconst normalize = (a) => {\n if (a[0] === 'bottom' || a[0] === 'top' || a[1] === 'left' || a[1] === 'right') {\n return [a[1], a[0]];\n } else {\n return a;\n }\n};\n\n/**\n * Parse a transform origin string to x/y values.\n * @param {{width: number, height: number}} rect\n * @param {string} value\n * @returns {x:number, y:number}\n */\nexport const parse = (rect, value) => {\n if (!value) {\n return {\n x: rect.width / 2,\n y: rect.height / 2,\n };\n }\n const arr = value.split(' ');\n if (arr.length === 1) {\n //1 val\n const x = getValue(arr[0], rect.width);\n const y = getValue('50%', rect.height);\n return { x, y };\n } else if (arr.length === 2) {\n const sorted = normalize(arr);\n const x = getValue(sorted[0], rect.width);\n const y = getValue(sorted[1], rect.height);\n return { x, y };\n } else if (arr.length === 3) {\n throw new Error('transform-origin values with 3 fields not supported.');\n }\n};\n"],"mappings":";;;;;;AAAA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,CAAC,EAAK;EAC9B,IAAIA,CAAC,KAAK,MAAM,IAAIA,CAAC,KAAK,KAAK,EAAE;IAC/B,OAAO,CAAC;EACV,CAAC,MAAM,IAAIA,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,QAAQ,EAAE;IAC1C,OAAO,GAAG;EACZ,CAAC,MAAM,IAAIA,CAAC,KAAK,QAAQ,EAAE;IACzB,OAAO,EAAE;EACX,CAAC,MAAM,IAAIA,CAAC,CAACC,QAAQ,CAAC,GAAG,CAAC,EAAE;IAC1B,OAAOC,UAAU,CAACF,CAAC,CAAC;EACtB,CAAC,MAAM;IACL,OAAOA,CAAC;EACV;AACF,CAAC;AAED,IAAMG,QAAQ,GAAG,SAAXA,QAAQA,CAAIC,CAAC,EAAEC,MAAM,EAAK;EAC9B,IAAID,CAAC,CAACH,QAAQ,CAAC,IAAI,CAAC,EAAE;IACpB,OAAOC,UAAU,CAACE,CAAC,CAAC;EACtB,CAA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B,IAAMa,MAAM,GAAGZ,SAAS,CAACU,GAAG,CAAC;IAC7B,IAAMJ,EAAC,GAAGT,QAAQ,CAACe,MAAM,CAAC,CAAC,CAAC,EAAER,IAAI,CAACG,KAAK,CAAC;IACzC,IAAMC,EAAC,GAAGX,QAAQ,CAACe,MAAM,CAAC,CAAC,CAAC,EAAER,IAAI,CAACK,MAAM,CAAC;IAC1C,OAAO;MAAEH,CAAC,EAADA,EAAC;MAAEE,CAAC,EAADA;IAAE,CAAC;EACjB,CAAC,MAAM,IAAIE,GAAG,CAACX,MAAM,KAAK,CAAC,EAAE;IAC3B,MAAM,IAAIc,KAAK,CAAC,sDAAsD,CAAC;EACzE;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { getAnchor, getAngleAndHypotenuse, normalizeAngle } from '../anchor-utils';
|
|
2
|
-
|
|
3
|
-
const o = (strings, ...exp) => {
|
|
4
|
-
return strings.reduce((acc, v, index) => {
|
|
5
|
-
const e = exp[index];
|
|
6
|
-
const s = typeof e === 'object' ? JSON.stringify(e) : e;
|
|
7
|
-
return `${acc}${v}${s || ''}`;
|
|
8
|
-
}, '');
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const rect = { width: 100, height: 100 };
|
|
12
|
-
|
|
13
|
-
describe('getAngleAndHypotenuse', () => {
|
|
14
|
-
const assert = (corner, rect, point, expected) => {
|
|
15
|
-
it(o`${corner}, ${rect}, ${point} => ${expected}`, () => {
|
|
16
|
-
const result = getAngleAndHypotenuse(corner, rect, point);
|
|
17
|
-
expect(result).toMatchObject(expected);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
assert('top-left', rect, { x: 50, y: 50 }, { degrees: -45 });
|
|
21
|
-
assert('bottom-left', rect, { x: 50, y: 50 }, { degrees: -135 });
|
|
22
|
-
assert('top-right', rect, { x: 50, y: 50 }, { degrees: 45 });
|
|
23
|
-
assert('bottom-right', rect, { x: 50, y: 50 }, { degrees: 135 });
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('getAnchor', () => {
|
|
27
|
-
describe('rect', () => {
|
|
28
|
-
it('does this: ', () => {
|
|
29
|
-
const result = getAnchor(
|
|
30
|
-
{
|
|
31
|
-
width: 400,
|
|
32
|
-
height: 100,
|
|
33
|
-
},
|
|
34
|
-
{ x: 0, y: 100 },
|
|
35
|
-
0,
|
|
36
|
-
);
|
|
37
|
-
expect(result.top).not.toBeUndefined();
|
|
38
|
-
expect(result.left).not.toBeUndefined();
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe('square', () => {
|
|
42
|
-
it('square @ 45', () => {
|
|
43
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 50, y: 50 }, 45);
|
|
44
|
-
expect(result.top).toBeCloseTo(70.71);
|
|
45
|
-
expect(result.left).toBeCloseTo(70.71);
|
|
46
|
-
});
|
|
47
|
-
it('square @ 90', () => {
|
|
48
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 50, y: 50 }, 90);
|
|
49
|
-
expect(result.top).toBeCloseTo(50);
|
|
50
|
-
expect(result.left).toBeCloseTo(50);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('square @ 180', () => {
|
|
54
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 50, y: 50 }, 180);
|
|
55
|
-
expect(result.top).toBeCloseTo(50);
|
|
56
|
-
expect(result.left).toBeCloseTo(50);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('square @ 270', () => {
|
|
60
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 50, y: 50 }, 180);
|
|
61
|
-
expect(result.top).toBeCloseTo(50);
|
|
62
|
-
expect(result.left).toBeCloseTo(50);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('square @ -45 - bottom right anchor', () => {
|
|
66
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 100, y: 100 }, -45);
|
|
67
|
-
expect(result.left).toBeCloseTo(141.42);
|
|
68
|
-
expect(result.top).toBeCloseTo(70.71);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('square @ 45 - bottom right anchor', () => {
|
|
72
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 100, y: 100 }, 45);
|
|
73
|
-
expect(result.top).toBeCloseTo(141.42);
|
|
74
|
-
expect(result.left).toBeCloseTo(70.71);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('square @ 20 - bottom right anchor', () => {
|
|
78
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 100, y: 100 }, 20);
|
|
79
|
-
|
|
80
|
-
expect(result.top).toBeCloseTo(128.17);
|
|
81
|
-
expect(result.left).toBeCloseTo(93.969);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('square @ 45, shifted center', () => {
|
|
85
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 25, y: 25 }, 45);
|
|
86
|
-
expect(result.top).toBeCloseTo(35.36);
|
|
87
|
-
expect(result.left).toBeCloseTo(70.71);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('square @ 20, shifted center', () => {
|
|
91
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 25, y: 25 }, 20);
|
|
92
|
-
expect(result.top).toBeCloseTo(32.04);
|
|
93
|
-
expect(result.left).toBeCloseTo(49.14);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('square @ 20', () => {
|
|
97
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 50, y: 50 }, 20);
|
|
98
|
-
expect(result.top).toBeCloseTo(64.085);
|
|
99
|
-
expect(result.left).toBeCloseTo(64.085);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('square @ 135', () => {
|
|
103
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 50, y: 50 }, 135);
|
|
104
|
-
expect(result.top).toBeCloseTo(70.71);
|
|
105
|
-
expect(result.left).toBeCloseTo(70.71);
|
|
106
|
-
});
|
|
107
|
-
it('square @ 225', () => {
|
|
108
|
-
const result = getAnchor({ width: 100, height: 100 }, { x: 50, y: 50 }, 135);
|
|
109
|
-
expect(result.top).toBeCloseTo(70.71);
|
|
110
|
-
expect(result.left).toBeCloseTo(70.71);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
describe('normalizeAngle', () => {
|
|
116
|
-
const assert = (a, expected) => {
|
|
117
|
-
it(`${a} -> ${expected}`, () => {
|
|
118
|
-
expect(normalizeAngle(a)).toEqual(expected);
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
assert(360, 360);
|
|
123
|
-
assert(0, 0);
|
|
124
|
-
assert(10, 10);
|
|
125
|
-
assert(361, 1);
|
|
126
|
-
assert(450, 90);
|
|
127
|
-
assert(721, 1);
|
|
128
|
-
assert(-1, 359);
|
|
129
|
-
assert(-361, 359);
|
|
130
|
-
assert(-721, 359);
|
|
131
|
-
});
|