@vived/core 1.4.0 → 1.4.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/package.json +3 -6
- package/dist/cjs/AppObject/AppObject.js +0 -59
- package/dist/cjs/AppObject/AppObject.js.map +0 -1
- package/dist/cjs/AppObject/AppObject.test.js +0 -113
- package/dist/cjs/AppObject/AppObject.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectComponent.js +0 -82
- package/dist/cjs/AppObject/AppObjectComponent.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectComponent.test.js +0 -132
- package/dist/cjs/AppObject/AppObjectComponent.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectController.js +0 -12
- package/dist/cjs/AppObject/AppObjectController.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectEntity.js +0 -38
- package/dist/cjs/AppObject/AppObjectEntity.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectEntity.test.js +0 -108
- package/dist/cjs/AppObject/AppObjectEntity.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectEntityRepo.js +0 -56
- package/dist/cjs/AppObject/AppObjectEntityRepo.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectEntityRepo.test.js +0 -149
- package/dist/cjs/AppObject/AppObjectEntityRepo.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectPM.js +0 -40
- package/dist/cjs/AppObject/AppObjectPM.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectPM.test.js +0 -103
- package/dist/cjs/AppObject/AppObjectPM.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectRepo.js +0 -133
- package/dist/cjs/AppObject/AppObjectRepo.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectRepo.test.js +0 -213
- package/dist/cjs/AppObject/AppObjectRepo.test.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectUC.js +0 -12
- package/dist/cjs/AppObject/AppObjectUC.js.map +0 -1
- package/dist/cjs/AppObject/AppObjectView.js +0 -12
- package/dist/cjs/AppObject/AppObjectView.js.map +0 -1
- package/dist/cjs/AppObject/getSingletonComponent.js +0 -7
- package/dist/cjs/AppObject/getSingletonComponent.js.map +0 -1
- package/dist/cjs/AppObject/getSingletonComponent.test.js +0 -13
- package/dist/cjs/AppObject/getSingletonComponent.test.js.map +0 -1
- package/dist/cjs/AppObject/index.js +0 -27
- package/dist/cjs/AppObject/index.js.map +0 -1
- package/dist/cjs/AppObject/printAppObjectDetails.js +0 -18
- package/dist/cjs/AppObject/printAppObjectDetails.js.map +0 -1
- package/dist/cjs/Entities/MemoizedAngle.js +0 -23
- package/dist/cjs/Entities/MemoizedAngle.js.map +0 -1
- package/dist/cjs/Entities/MemoizedAngle.test.js +0 -30
- package/dist/cjs/Entities/MemoizedAngle.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedBoolean.js +0 -23
- package/dist/cjs/Entities/MemoizedBoolean.js.map +0 -1
- package/dist/cjs/Entities/MemoizedBoolean.test.js +0 -34
- package/dist/cjs/Entities/MemoizedBoolean.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedColor.js +0 -24
- package/dist/cjs/Entities/MemoizedColor.js.map +0 -1
- package/dist/cjs/Entities/MemoizedColor.test.js +0 -32
- package/dist/cjs/Entities/MemoizedColor.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedNumber.js +0 -23
- package/dist/cjs/Entities/MemoizedNumber.js.map +0 -1
- package/dist/cjs/Entities/MemoizedNumber.test.js +0 -29
- package/dist/cjs/Entities/MemoizedNumber.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedQuaternion.js +0 -24
- package/dist/cjs/Entities/MemoizedQuaternion.js.map +0 -1
- package/dist/cjs/Entities/MemoizedQuaternion.test.js +0 -32
- package/dist/cjs/Entities/MemoizedQuaternion.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedString.js +0 -23
- package/dist/cjs/Entities/MemoizedString.js.map +0 -1
- package/dist/cjs/Entities/MemoizedString.test.js +0 -29
- package/dist/cjs/Entities/MemoizedString.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedVector2.js +0 -24
- package/dist/cjs/Entities/MemoizedVector2.js.map +0 -1
- package/dist/cjs/Entities/MemoizedVector2.test.js +0 -32
- package/dist/cjs/Entities/MemoizedVector2.test.js.map +0 -1
- package/dist/cjs/Entities/MemoizedVector3.js +0 -24
- package/dist/cjs/Entities/MemoizedVector3.js.map +0 -1
- package/dist/cjs/Entities/MemoizedVector3.test.js +0 -32
- package/dist/cjs/Entities/MemoizedVector3.test.js.map +0 -1
- package/dist/cjs/Entities/ObservableEntity.js +0 -20
- package/dist/cjs/Entities/ObservableEntity.js.map +0 -1
- package/dist/cjs/Entities/ObservableEntity.test.js +0 -25
- package/dist/cjs/Entities/ObservableEntity.test.js.map +0 -1
- package/dist/cjs/Entities/ObserverList.js +0 -27
- package/dist/cjs/Entities/ObserverList.js.map +0 -1
- package/dist/cjs/Entities/ObserverList.test.js +0 -44
- package/dist/cjs/Entities/ObserverList.test.js.map +0 -1
- package/dist/cjs/Entities/RangedNumber.js +0 -36
- package/dist/cjs/Entities/RangedNumber.js.map +0 -1
- package/dist/cjs/Entities/RangedNumber.test.js +0 -96
- package/dist/cjs/Entities/RangedNumber.test.js.map +0 -1
- package/dist/cjs/Entities/index.js +0 -28
- package/dist/cjs/Entities/index.js.map +0 -1
- package/dist/cjs/Types/AppBoundary.js +0 -3
- package/dist/cjs/Types/AppBoundary.js.map +0 -1
- package/dist/cjs/Types/EaseFn.js +0 -3
- package/dist/cjs/Types/EaseFn.js.map +0 -1
- package/dist/cjs/Types/PmAdapter.js +0 -3
- package/dist/cjs/Types/PmAdapter.js.map +0 -1
- package/dist/cjs/Types/SingletonPmAdapter.js +0 -3
- package/dist/cjs/Types/SingletonPmAdapter.js.map +0 -1
- package/dist/cjs/Types/index.js +0 -21
- package/dist/cjs/Types/index.js.map +0 -1
- package/dist/cjs/Utilities/LengthConverters.js +0 -21
- package/dist/cjs/Utilities/LengthConverters.js.map +0 -1
- package/dist/cjs/Utilities/LengthConverters.test.js +0 -24
- package/dist/cjs/Utilities/LengthConverters.test.js.map +0 -1
- package/dist/cjs/Utilities/LerpNumber.js +0 -85
- package/dist/cjs/Utilities/LerpNumber.js.map +0 -1
- package/dist/cjs/Utilities/LerpNumber.test.js +0 -90
- package/dist/cjs/Utilities/LerpNumber.test.js.map +0 -1
- package/dist/cjs/Utilities/addAlphaToHex.js +0 -16
- package/dist/cjs/Utilities/addAlphaToHex.js.map +0 -1
- package/dist/cjs/Utilities/addAlphaToHex.test.js +0 -34
- package/dist/cjs/Utilities/addAlphaToHex.test.js.map +0 -1
- package/dist/cjs/Utilities/alphaToHex.js +0 -21
- package/dist/cjs/Utilities/alphaToHex.js.map +0 -1
- package/dist/cjs/Utilities/alphaToHex.test.js +0 -75
- package/dist/cjs/Utilities/alphaToHex.test.js.map +0 -1
- package/dist/cjs/Utilities/degreesToRadians.js +0 -7
- package/dist/cjs/Utilities/degreesToRadians.js.map +0 -1
- package/dist/cjs/Utilities/degreesToRadians.test.js +0 -9
- package/dist/cjs/Utilities/degreesToRadians.test.js.map +0 -1
- package/dist/cjs/Utilities/downloadFile.js +0 -14
- package/dist/cjs/Utilities/downloadFile.js.map +0 -1
- package/dist/cjs/Utilities/easeFunctions.js +0 -208
- package/dist/cjs/Utilities/easeFunctions.js.map +0 -1
- package/dist/cjs/Utilities/easeFunctions.test.js +0 -209
- package/dist/cjs/Utilities/easeFunctions.test.js.map +0 -1
- package/dist/cjs/Utilities/generateUniqueID.js +0 -8
- package/dist/cjs/Utilities/generateUniqueID.js.map +0 -1
- package/dist/cjs/Utilities/index.js +0 -25
- package/dist/cjs/Utilities/index.js.map +0 -1
- package/dist/cjs/Utilities/interpolateNumber.js +0 -18
- package/dist/cjs/Utilities/interpolateNumber.js.map +0 -1
- package/dist/cjs/Utilities/interpolateNumber.test.js +0 -26
- package/dist/cjs/Utilities/interpolateNumber.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Angle.js +0 -47
- package/dist/cjs/ValueObjects/Angle.js.map +0 -1
- package/dist/cjs/ValueObjects/Angle.test.js +0 -28
- package/dist/cjs/ValueObjects/Angle.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Color.js +0 -859
- package/dist/cjs/ValueObjects/Color.js.map +0 -1
- package/dist/cjs/ValueObjects/Color.test.js +0 -147
- package/dist/cjs/ValueObjects/Color.test.js.map +0 -1
- package/dist/cjs/ValueObjects/LineSegment2D.js +0 -72
- package/dist/cjs/ValueObjects/LineSegment2D.js.map +0 -1
- package/dist/cjs/ValueObjects/LineSegment2D.test.js +0 -102
- package/dist/cjs/ValueObjects/LineSegment2D.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Matrix.js +0 -466
- package/dist/cjs/ValueObjects/Matrix.js.map +0 -1
- package/dist/cjs/ValueObjects/Matrix.test.js +0 -385
- package/dist/cjs/ValueObjects/Matrix.test.js.map +0 -1
- package/dist/cjs/ValueObjects/ParametricLine.js +0 -77
- package/dist/cjs/ValueObjects/ParametricLine.js.map +0 -1
- package/dist/cjs/ValueObjects/ParametricLine.test.js +0 -126
- package/dist/cjs/ValueObjects/ParametricLine.test.js.map +0 -1
- package/dist/cjs/ValueObjects/ParametricPlane.js +0 -65
- package/dist/cjs/ValueObjects/ParametricPlane.js.map +0 -1
- package/dist/cjs/ValueObjects/ParametricPlane.test.js +0 -101
- package/dist/cjs/ValueObjects/ParametricPlane.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Quaternion.js +0 -290
- package/dist/cjs/ValueObjects/Quaternion.js.map +0 -1
- package/dist/cjs/ValueObjects/Quaternion.test.js +0 -240
- package/dist/cjs/ValueObjects/Quaternion.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Rectangle.js +0 -24
- package/dist/cjs/ValueObjects/Rectangle.js.map +0 -1
- package/dist/cjs/ValueObjects/Rectangle.test.js +0 -32
- package/dist/cjs/ValueObjects/Rectangle.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Vector2.js +0 -184
- package/dist/cjs/ValueObjects/Vector2.js.map +0 -1
- package/dist/cjs/ValueObjects/Vector2.test.js +0 -136
- package/dist/cjs/ValueObjects/Vector2.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Vector3.js +0 -231
- package/dist/cjs/ValueObjects/Vector3.js.map +0 -1
- package/dist/cjs/ValueObjects/Vector3.test.js +0 -188
- package/dist/cjs/ValueObjects/Vector3.test.js.map +0 -1
- package/dist/cjs/ValueObjects/Version.js +0 -171
- package/dist/cjs/ValueObjects/Version.js.map +0 -1
- package/dist/cjs/ValueObjects/Version.test.js +0 -310
- package/dist/cjs/ValueObjects/Version.test.js.map +0 -1
- package/dist/cjs/ValueObjects/index.js +0 -28
- package/dist/cjs/ValueObjects/index.js.map +0 -1
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/index.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Color.js","sourceRoot":"","sources":["../../../src/ValueObjects/Color.ts"],"names":[],"mappings":";;;AASA,MAAa,KAAK;IAChB;;;;;;;OAOG;IACI,MAAM,CAAC,IAAI,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;QAC3D,OAAO,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;QAC/C,OAAO,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAC,IAAc;QAClC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC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,EAAE,gBAAgB;QACtB,GAAG,EAAE,QAAQ;QACb,GAAG,EAAE,aAAa;KACnB;IACD;QACE,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,QAAQ;QACb,GAAG,EAAE,aAAa;KACnB;IACD;QACE,IAAI,EAAE,eAAe;QACrB,GAAG,EAAE,QAAQ;QACb,GAAG,EAAE,WAAW;KACjB;IACD;QACE,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,QAAQ;QACb,GAAG,EAAE,QAAQ;KACd;CACF,CAAC","sourcesContent":["export type BasicColor = \"\";\r\n\r\nexport interface ColorDTO {\r\n r: number;\r\n g: number;\r\n b: number;\r\n a: number;\r\n}\r\n\r\nexport class Color {\r\n /**\r\n * Creates a Color from RGBA values\r\n * @param r Red value, between 0-255\r\n * @param g Green value, between 0-255\r\n * @param b Blue value, between 0-255\r\n * @param a Alpha value, between 0-255\r\n * @returns The Color\r\n */\r\n public static RGBA(r: number, g: number, b: number, a: number) {\r\n return new Color(r, g, b, a);\r\n }\r\n\r\n /**\r\n * Creates a Color from RGB values. Alpha is set to 255\r\n * @param r Red value, between 0-255\r\n * @param g Green value, between 0-255\r\n * @param b Blue value, between 0-255\r\n * @returns The Color\r\n */\r\n public static RGB(r: number, g: number, b: number) {\r\n return new Color(r, g, b, 255);\r\n }\r\n\r\n /**\r\n *\r\n * @returns Creates a Color from a DTO\r\n * @param data Data Transfer Object\r\n */\r\n public static FromDTO(data: ColorDTO) {\r\n return new Color(data.r, data.g, data.b, data.a);\r\n }\r\n\r\n /**\r\n * Creates a color from a Hex value\r\n * @param hex The Hex string. Example '808080'\r\n * @returns The Color\r\n */\r\n public static Hex(hex: string): Color {\r\n // Expand shorthand form (e.g. \"03F\") to full form (e.g. \"0033FF\")\r\n const shorthandRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\r\n\r\n // tslint:disable-next-line\r\n hex = hex.replace(shorthandRegex, function (m, r, g, b) {\r\n return r + r + g + g + b + b;\r\n });\r\n\r\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\r\n\r\n let r = 0;\r\n let g = 0;\r\n let b = 0;\r\n\r\n if (result) {\r\n r = parseInt(result[1], 16);\r\n g = parseInt(result[2], 16);\r\n b = parseInt(result[3], 16);\r\n } else {\r\n console.warn(\"Unable to parse hex to color: \" + hex);\r\n }\r\n\r\n return Color.RGB(r, g, b);\r\n }\r\n\r\n /**\r\n * Creates a color from the X11 standard.\r\n * @param name X11 name\r\n * @returns The Color. If the color name is not found, it will return Black.\r\n */\r\n public static X11(name: string): Color {\r\n for (const c of x11Colors) {\r\n if (c.name.toLowerCase() === name.toLowerCase()) {\r\n return Color.Hex(c.hex);\r\n }\r\n }\r\n\r\n console.warn(\"Unable to find X11 color by name: \" + name);\r\n\r\n return Color.RGB(0, 0, 0);\r\n }\r\n\r\n /**\r\n * Checks to see if Color A equals Color B\r\n * @param a Color A\r\n * @param b Color B\r\n * @returns True if Color A === Color B\r\n */\r\n public static Equal(a: Color, b: Color): boolean {\r\n let areEqual = true;\r\n for (let index = 0; index < 4; index++) {\r\n if (a.array[index] !== b.array[index]) {\r\n areEqual = false;\r\n }\r\n }\r\n return areEqual;\r\n }\r\n\r\n readonly r: number;\r\n readonly g: number;\r\n readonly b: number;\r\n readonly a: number;\r\n\r\n /**\r\n * Return the r value as a percent\r\n */\r\n get rPercent(): number {\r\n return this.r / 255;\r\n }\r\n\r\n /**\r\n * Return the g value as a percent\r\n */\r\n get gPercent(): number {\r\n return this.g / 255;\r\n }\r\n\r\n /**\r\n * Return the b value as a percent\r\n */\r\n get bPercent(): number {\r\n return this.b / 255;\r\n }\r\n\r\n /**\r\n * Return the a value as a percent\r\n */\r\n get aPercent(): number {\r\n return this.a / 255;\r\n }\r\n\r\n /**\r\n * Returns the Color values as an array [r,g,b,a]\r\n */\r\n get array(): [number, number, number, number] {\r\n return [this.r, this.g, this.b, this.a];\r\n }\r\n\r\n /**\r\n * Returns the Color values as a hex\r\n */\r\n get hex(): string {\r\n let r = this.r.toString(16);\r\n let g = this.g.toString(16);\r\n let b = this.b.toString(16);\r\n\r\n if (r.length === 1) r = \"0\" + r;\r\n if (g.length === 1) g = \"0\" + g;\r\n if (b.length === 1) b = \"0\" + b;\r\n\r\n return \"#\" + r + g + b;\r\n }\r\n\r\n get dto(): ColorDTO {\r\n return {\r\n a: this.a,\r\n b: this.b,\r\n g: this.g,\r\n r: this.r,\r\n };\r\n }\r\n\r\n private clampVal(val: number): number {\r\n if (val > 255) return 255;\r\n if (val < 0) return 0;\r\n return val;\r\n }\r\n\r\n private constructor(r: number, g: number, b: number, a: number) {\r\n this.r = this.clampVal(r);\r\n this.g = this.clampVal(g);\r\n this.b = this.clampVal(b);\r\n this.a = this.clampVal(a);\r\n }\r\n}\r\n\r\ntype ColorObject = {\r\n name: string;\r\n hex: string;\r\n rgb: string;\r\n};\r\nconst x11Colors: ColorObject[] = [\r\n {\r\n name: \"Pink\",\r\n hex: \"ffc0cb\",\r\n rgb: \"255,192,203\",\r\n },\r\n {\r\n name: \"LightPink\",\r\n hex: \"ffb6c1\",\r\n rgb: \"255,182,193\",\r\n },\r\n {\r\n name: \"HotPink\",\r\n hex: \"ff69b4\",\r\n rgb: \"255,105,180\",\r\n },\r\n {\r\n name: \"DeepPink\",\r\n hex: \"ff1493\",\r\n rgb: \"255,20,147\",\r\n },\r\n {\r\n name: \"PaleVioletRed\",\r\n hex: \"db7093\",\r\n rgb: \"219,112,147\",\r\n },\r\n {\r\n name: \"MediumVioletRed\",\r\n hex: \"c71585\",\r\n rgb: \"199,21,133\",\r\n },\r\n {\r\n name: \"LightSalmon\",\r\n hex: \"ffa07a\",\r\n rgb: \"255,160,122\",\r\n },\r\n {\r\n name: \"Salmon\",\r\n hex: \"fa8072\",\r\n rgb: \"250,128,114\",\r\n },\r\n {\r\n name: \"DarkSalmon\",\r\n hex: \"e9967a\",\r\n rgb: \"233,150,122\",\r\n },\r\n {\r\n name: \"LightCoral\",\r\n hex: \"f08080\",\r\n rgb: \"240,128,128\",\r\n },\r\n {\r\n name: \"IndianRed\",\r\n hex: \"cd5c5c\",\r\n rgb: \"205,92,92\",\r\n },\r\n {\r\n name: \"Crimson\",\r\n hex: \"dc143c\",\r\n rgb: \"220,20,60\",\r\n },\r\n {\r\n name: \"FireBrick\",\r\n hex: \"b22222\",\r\n rgb: \"178,34,34\",\r\n },\r\n {\r\n name: \"DarkRed\",\r\n hex: \"8b0000\",\r\n rgb: \"139,0,0\",\r\n },\r\n {\r\n name: \"Red\",\r\n hex: \"ff0000\",\r\n rgb: \"255,0,0\",\r\n },\r\n {\r\n name: \"OrangeRed\",\r\n hex: \"ff4500\",\r\n rgb: \"255,69,0\",\r\n },\r\n {\r\n name: \"Tomato\",\r\n hex: \"ff6347\",\r\n rgb: \"255,99,71\",\r\n },\r\n {\r\n name: \"Coral\",\r\n hex: \"ff7f50\",\r\n rgb: \"255,127,80\",\r\n },\r\n {\r\n name: \"DarkOrange\",\r\n hex: \"ff8c00\",\r\n rgb: \"255,140,0\",\r\n },\r\n {\r\n name: \"Orange\",\r\n hex: \"ffa500\",\r\n rgb: \"255,165,0\",\r\n },\r\n {\r\n name: \"Gold\",\r\n hex: \"ffd700\",\r\n rgb: \"255,215,0\",\r\n },\r\n {\r\n name: \"Yellow\",\r\n hex: \"ffff00\",\r\n rgb: \"255,255,0\",\r\n },\r\n {\r\n name: \"LightYellow\",\r\n hex: \"ffffe0\",\r\n rgb: \"255,255,224\",\r\n },\r\n {\r\n name: \"LemonChiffon\",\r\n hex: \"fffacd\",\r\n rgb: \"255,250,205\",\r\n },\r\n {\r\n name: \"LightGoldenrodYellow\",\r\n hex: \"fafad2\",\r\n rgb: \"250,250,210\",\r\n },\r\n {\r\n name: \"PapayaWhip\",\r\n hex: \"ffefd5\",\r\n rgb: \"255,239,213\",\r\n },\r\n {\r\n name: \"Moccasin\",\r\n hex: \"ffe4b5\",\r\n rgb: \"255,228,181\",\r\n },\r\n {\r\n name: \"PeachPuff\",\r\n hex: \"ffdab9\",\r\n rgb: \"255,218,185\",\r\n },\r\n {\r\n name: \"PaleGoldenrod\",\r\n hex: \"eee8aa\",\r\n rgb: \"238,232,170\",\r\n },\r\n {\r\n name: \"Khaki\",\r\n hex: \"f0e68c\",\r\n rgb: \"240,230,140\",\r\n },\r\n {\r\n name: \"DarkKhaki\",\r\n hex: \"bdb76b\",\r\n rgb: \"189,183,107\",\r\n },\r\n {\r\n name: \"Cornsilk\",\r\n hex: \"fff8dc\",\r\n rgb: \"255,248,220\",\r\n },\r\n {\r\n name: \"BlanchedAlmond\",\r\n hex: \"ffebcd\",\r\n rgb: \"255,235,205\",\r\n },\r\n {\r\n name: \"Bisque\",\r\n hex: \"ffe4c4\",\r\n rgb: \"255,228,196\",\r\n },\r\n {\r\n name: \"NavajoWhite\",\r\n hex: \"ffdead\",\r\n rgb: \"255,222,173\",\r\n },\r\n {\r\n name: \"Wheat\",\r\n hex: \"f5deb3\",\r\n rgb: \"245,222,179\",\r\n },\r\n {\r\n name: \"BurlyWood\",\r\n hex: \"deb887\",\r\n rgb: \"222,184,135\",\r\n },\r\n {\r\n name: \"Tan\",\r\n hex: \"d2b48c\",\r\n rgb: \"210,180,140\",\r\n },\r\n {\r\n name: \"RosyBrown\",\r\n hex: \"bc8f8f\",\r\n rgb: \"188,143,143\",\r\n },\r\n {\r\n name: \"SandyBrown\",\r\n hex: \"f4a460\",\r\n rgb: \"244,164,96\",\r\n },\r\n {\r\n name: \"Goldenrod\",\r\n hex: \"daa520\",\r\n rgb: \"218,165,32\",\r\n },\r\n {\r\n name: \"DarkGoldenrod\",\r\n hex: \"b8860b\",\r\n rgb: \"184,134,11\",\r\n },\r\n {\r\n name: \"Peru\",\r\n hex: \"cd853f\",\r\n rgb: \"205,133,63\",\r\n },\r\n {\r\n name: \"Chocolate\",\r\n hex: \"d2691e\",\r\n rgb: \"210,105,30\",\r\n },\r\n {\r\n name: \"SaddleBrown\",\r\n hex: \"8b4513\",\r\n rgb: \"139,69,19\",\r\n },\r\n {\r\n name: \"Sienna\",\r\n hex: \"a0522d\",\r\n rgb: \"160,82,45\",\r\n },\r\n {\r\n name: \"Brown\",\r\n hex: \"a52a2a\",\r\n rgb: \"165,42,42\",\r\n },\r\n {\r\n name: \"Maroon\",\r\n hex: \"800000\",\r\n rgb: \"128,0,0\",\r\n },\r\n {\r\n name: \"DarkOliveGreen\",\r\n hex: \"556b2f\",\r\n rgb: \",85,107,47\",\r\n },\r\n {\r\n name: \"Olive\",\r\n hex: \"808000\",\r\n rgb: \"128,128,0\",\r\n },\r\n {\r\n name: \"OliveDrab\",\r\n hex: \"6b8e23\",\r\n rgb: \"107,142,35\",\r\n },\r\n {\r\n name: \"YellowGreen\",\r\n hex: \"9acd32\",\r\n rgb: \"154,205,50\",\r\n },\r\n {\r\n name: \"LimeGreen\",\r\n hex: \"32cd32\",\r\n rgb: \",50,205,50\",\r\n },\r\n {\r\n name: \"Lime\",\r\n hex: \"00ff00\",\r\n rgb: \",0,255,0\",\r\n },\r\n {\r\n name: \"LawnGreen\",\r\n hex: \"7cfc00\",\r\n rgb: \"124,252,0\",\r\n },\r\n {\r\n name: \"Chartreuse\",\r\n hex: \"7fff00\",\r\n rgb: \"127,255,0\",\r\n },\r\n {\r\n name: \"GreenYellow\",\r\n hex: \"adff2f\",\r\n rgb: \"173,255,47\",\r\n },\r\n {\r\n name: \"SpringGreen\",\r\n hex: \"00ff7f\",\r\n rgb: \",0,255,127\",\r\n },\r\n {\r\n name: \"MediumSpringGreen\",\r\n hex: \"00fa9a\",\r\n rgb: \",0,250,154\",\r\n },\r\n {\r\n name: \"LightGreen\",\r\n hex: \"90ee90\",\r\n rgb: \"144,238,144\",\r\n },\r\n {\r\n name: \"PaleGreen\",\r\n hex: \"98fb98\",\r\n rgb: \"152,251,152\",\r\n },\r\n {\r\n name: \"DarkSeaGreen\",\r\n hex: \"8fbc8f\",\r\n rgb: \"143,188,143\",\r\n },\r\n {\r\n name: \"MediumSeaGreen\",\r\n hex: \"3cb371\",\r\n rgb: \",60,179,113\",\r\n },\r\n {\r\n name: \"SeaGreen\",\r\n hex: \"2e8b57\",\r\n rgb: \",46,139,87\",\r\n },\r\n {\r\n name: \"ForestGreen\",\r\n hex: \"228b22\",\r\n rgb: \",34,139,34\",\r\n },\r\n {\r\n name: \"Green\",\r\n hex: \"008000\",\r\n rgb: \",0,128,0\",\r\n },\r\n {\r\n name: \"DarkGreen\",\r\n hex: \"006400\",\r\n rgb: \",0,100,0\",\r\n },\r\n {\r\n name: \"MediumAquamarine\",\r\n hex: \"66cdaa\",\r\n rgb: \"102,205,170\",\r\n },\r\n {\r\n name: \"Aqua\",\r\n hex: \"00ffff\",\r\n rgb: \",0,255,255\",\r\n },\r\n {\r\n name: \"Cyan\",\r\n hex: \"00ffff\",\r\n rgb: \",0,255,255\",\r\n },\r\n {\r\n name: \"LightCyan\",\r\n hex: \"e0ffff\",\r\n rgb: \"224,255,255\",\r\n },\r\n {\r\n name: \"PaleTurquoise\",\r\n hex: \"afeeee\",\r\n rgb: \"175,238,238\",\r\n },\r\n {\r\n name: \"Aquamarine\",\r\n hex: \"7fffd4\",\r\n rgb: \"127,255,212\",\r\n },\r\n {\r\n name: \"Turquoise\",\r\n hex: \"40e0d0\",\r\n rgb: \",64,224,208\",\r\n },\r\n {\r\n name: \"MediumTurquoise\",\r\n hex: \"48d1cc\",\r\n rgb: \",72,209,204\",\r\n },\r\n {\r\n name: \"DarkTurquoise\",\r\n hex: \"00ced1\",\r\n rgb: \",0,206,209\",\r\n },\r\n {\r\n name: \"LightSeaGreen\",\r\n hex: \"20b2aa\",\r\n rgb: \",32,178,170\",\r\n },\r\n {\r\n name: \"CadetBlue\",\r\n hex: \"5f9ea0\",\r\n rgb: \",95,158,160\",\r\n },\r\n {\r\n name: \"DarkCyan\",\r\n hex: \"008b8b\",\r\n rgb: \",0,139,139\",\r\n },\r\n {\r\n name: \"Teal\",\r\n hex: \"008080\",\r\n rgb: \",0,128,128\",\r\n },\r\n {\r\n name: \"LightSteelBlue\",\r\n hex: \"b0c4de\",\r\n rgb: \"176,196,222\",\r\n },\r\n {\r\n name: \"PowderBlue\",\r\n hex: \"b0e0e6\",\r\n rgb: \"176,224,230\",\r\n },\r\n {\r\n name: \"LightBlue\",\r\n hex: \"add8e6\",\r\n rgb: \"173,216,230\",\r\n },\r\n {\r\n name: \"SkyBlue\",\r\n hex: \"87ceeb\",\r\n rgb: \"135,206,235\",\r\n },\r\n {\r\n name: \"LightSkyBlue\",\r\n hex: \"87cefa\",\r\n rgb: \"135,206,250\",\r\n },\r\n {\r\n name: \"DeepSkyBlue\",\r\n hex: \"00bfff\",\r\n rgb: \",0,191,255\",\r\n },\r\n {\r\n name: \"DodgerBlue\",\r\n hex: \"1e90ff\",\r\n rgb: \",30,144,255\",\r\n },\r\n {\r\n name: \"CornflowerBlue\",\r\n hex: \"6495ed\",\r\n rgb: \"100,149,237\",\r\n },\r\n {\r\n name: \"SteelBlue\",\r\n hex: \"4682b4\",\r\n rgb: \",70,130,180\",\r\n },\r\n {\r\n name: \"RoyalBlue\",\r\n hex: \"4169e1\",\r\n rgb: \",65,105,225\",\r\n },\r\n {\r\n name: \"Blue\",\r\n hex: \"0000ff\",\r\n rgb: \",0,0,255\",\r\n },\r\n {\r\n name: \"MediumBlue\",\r\n hex: \"0000cd\",\r\n rgb: \",0,0,205\",\r\n },\r\n {\r\n name: \"DarkBlue\",\r\n hex: \"00008b\",\r\n rgb: \",0,0,139\",\r\n },\r\n {\r\n name: \"Navy\",\r\n hex: \"000080\",\r\n rgb: \",0,0,128\",\r\n },\r\n {\r\n name: \"MidnightBlue\",\r\n hex: \"191970\",\r\n rgb: \",25,25,112\",\r\n },\r\n {\r\n name: \"Lavender\",\r\n hex: \"e6e6fa\",\r\n rgb: \"230,230,250\",\r\n },\r\n {\r\n name: \"Thistle\",\r\n hex: \"d8bfd8\",\r\n rgb: \"216,191,216\",\r\n },\r\n {\r\n name: \"Plum\",\r\n hex: \"dda0dd\",\r\n rgb: \"221,160,221\",\r\n },\r\n {\r\n name: \"Violet\",\r\n hex: \"ee82ee\",\r\n rgb: \"238,130,238\",\r\n },\r\n {\r\n name: \"Orchid\",\r\n hex: \"da70d6\",\r\n rgb: \"218,112,214\",\r\n },\r\n {\r\n name: \"Fuchsia\",\r\n hex: \"ff00ff\",\r\n rgb: \"255,0,255\",\r\n },\r\n {\r\n name: \"Magenta\",\r\n hex: \"ff00ff\",\r\n rgb: \"255,0,255\",\r\n },\r\n {\r\n name: \"MediumOrchid\",\r\n hex: \"ba55d3\",\r\n rgb: \"186,85,211\",\r\n },\r\n {\r\n name: \"MediumPurple\",\r\n hex: \"9370db\",\r\n rgb: \"147,112,219\",\r\n },\r\n {\r\n name: \"BlueViolet\",\r\n hex: \"8a2be2\",\r\n rgb: \"138,43,226\",\r\n },\r\n {\r\n name: \"DarkViolet\",\r\n hex: \"9400d3\",\r\n rgb: \"148,0,211\",\r\n },\r\n {\r\n name: \"DarkOrchid\",\r\n hex: \"9932cc\",\r\n rgb: \"153,50,204\",\r\n },\r\n {\r\n name: \"DarkMagenta\",\r\n hex: \"8b008b\",\r\n rgb: \"139,0,139\",\r\n },\r\n {\r\n name: \"Purple\",\r\n hex: \"800080\",\r\n rgb: \"128,0,128\",\r\n },\r\n {\r\n name: \"Indigo\",\r\n hex: \"4b0082\",\r\n rgb: \",75,0,130\",\r\n },\r\n {\r\n name: \"DarkSlateBlue\",\r\n hex: \"483d8b\",\r\n rgb: \",72,61,139\",\r\n },\r\n {\r\n name: \"SlateBlue\",\r\n hex: \"6a5acd\",\r\n rgb: \"106,90,205\",\r\n },\r\n {\r\n name: \"MediumSlateBlue\",\r\n hex: \"7b68ee\",\r\n rgb: \"123,104,238\",\r\n },\r\n {\r\n name: \"White\",\r\n hex: \"ffffff\",\r\n rgb: \"255,255,255\",\r\n },\r\n {\r\n name: \"Snow\",\r\n hex: \"fffafa\",\r\n rgb: \"255,250,250\",\r\n },\r\n {\r\n name: \"Honeydew\",\r\n hex: \"f0fff0\",\r\n rgb: \"240,255,240\",\r\n },\r\n {\r\n name: \"MintCream\",\r\n hex: \"f5fffa\",\r\n rgb: \"245,255,250\",\r\n },\r\n {\r\n name: \"Azure\",\r\n hex: \"f0ffff\",\r\n rgb: \"240,255,255\",\r\n },\r\n {\r\n name: \"AliceBlue\",\r\n hex: \"f0f8ff\",\r\n rgb: \"240,248,255\",\r\n },\r\n {\r\n name: \"GhostWhite\",\r\n hex: \"f8f8ff\",\r\n rgb: \"248,248,255\",\r\n },\r\n {\r\n name: \"WhiteSmoke\",\r\n hex: \"f5f5f5\",\r\n rgb: \"245,245,245\",\r\n },\r\n {\r\n name: \"Seashell\",\r\n hex: \"fff5ee\",\r\n rgb: \"255,245,238\",\r\n },\r\n {\r\n name: \"Beige\",\r\n hex: \"f5f5dc\",\r\n rgb: \"245,245,220\",\r\n },\r\n {\r\n name: \"OldLace\",\r\n hex: \"fdf5e6\",\r\n rgb: \"253,245,230\",\r\n },\r\n {\r\n name: \"FloralWhite\",\r\n hex: \"fffaf0\",\r\n rgb: \"255,250,240\",\r\n },\r\n {\r\n name: \"Ivory\",\r\n hex: \"fffff0\",\r\n rgb: \"255,255,240\",\r\n },\r\n {\r\n name: \"AntiqueWhite\",\r\n hex: \"faebd7\",\r\n rgb: \"250,235,215\",\r\n },\r\n {\r\n name: \"Linen\",\r\n hex: \"faf0e6\",\r\n rgb: \"250,240,230\",\r\n },\r\n {\r\n name: \"LavenderBlush\",\r\n hex: \"fff0f5\",\r\n rgb: \"255,240,245\",\r\n },\r\n {\r\n name: \"MistyRose\",\r\n hex: \"ffe4e1\",\r\n rgb: \"255,228,225\",\r\n },\r\n {\r\n name: \"Gainsboro\",\r\n hex: \"dcdcdc\",\r\n rgb: \"220,220,220\",\r\n },\r\n {\r\n name: \"LightGray\",\r\n hex: \"d3d3d3\",\r\n rgb: \"211,211,211\",\r\n },\r\n {\r\n name: \"Silver\",\r\n hex: \"c0c0c0\",\r\n rgb: \"192,192,192\",\r\n },\r\n {\r\n name: \"DarkGrey\",\r\n hex: \"a9a9a9\",\r\n rgb: \"169,169,169\",\r\n },\r\n {\r\n name: \"Grey\",\r\n hex: \"808080\",\r\n rgb: \"128,128,128\",\r\n },\r\n {\r\n name: \"DimGrey\",\r\n hex: \"696969\",\r\n rgb: \"105,105,105\",\r\n },\r\n {\r\n name: \"LightSlateGrey\",\r\n hex: \"778899\",\r\n rgb: \"119,136,153\",\r\n },\r\n {\r\n name: \"SlateGrey\",\r\n hex: \"708090\",\r\n rgb: \"112,128,144\",\r\n },\r\n {\r\n name: \"DarkSlateGrey\",\r\n hex: \"2f4f4f\",\r\n rgb: \",47,79,79\",\r\n },\r\n {\r\n name: \"Black\",\r\n hex: \"000000\",\r\n rgb: \",0,0,0\",\r\n },\r\n];\r\n"]}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Color_1 = require("./Color");
|
|
4
|
-
describe("Color value object - RGBA", () => {
|
|
5
|
-
it("Make a color as expected", () => {
|
|
6
|
-
const color = Color_1.Color.RGBA(10, 20, 30, 40);
|
|
7
|
-
expect(color.r).toEqual(10);
|
|
8
|
-
expect(color.g).toEqual(20);
|
|
9
|
-
expect(color.b).toEqual(30);
|
|
10
|
-
expect(color.a).toEqual(40);
|
|
11
|
-
});
|
|
12
|
-
it("Clamps the color values to a minumum value of 0", () => {
|
|
13
|
-
const color = Color_1.Color.RGBA(-1, -1, -1, -1);
|
|
14
|
-
expect(color.r).toEqual(0);
|
|
15
|
-
expect(color.g).toEqual(0);
|
|
16
|
-
expect(color.b).toEqual(0);
|
|
17
|
-
expect(color.a).toEqual(0);
|
|
18
|
-
});
|
|
19
|
-
it("Clamps the color values to a maximum value of 255", () => {
|
|
20
|
-
const color = Color_1.Color.RGBA(300, 300, 300, 300);
|
|
21
|
-
expect(color.r).toEqual(255);
|
|
22
|
-
expect(color.g).toEqual(255);
|
|
23
|
-
expect(color.b).toEqual(255);
|
|
24
|
-
expect(color.a).toEqual(255);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe("Color value object - RGB", () => {
|
|
28
|
-
it("Make a color as expected", () => {
|
|
29
|
-
const color = Color_1.Color.RGB(10, 20, 30);
|
|
30
|
-
expect(color.r).toEqual(10);
|
|
31
|
-
expect(color.g).toEqual(20);
|
|
32
|
-
expect(color.b).toEqual(30);
|
|
33
|
-
expect(color.a).toEqual(255);
|
|
34
|
-
});
|
|
35
|
-
it("Clamps the color values to a minumum value of 0", () => {
|
|
36
|
-
const color = Color_1.Color.RGB(-1, -1, -1);
|
|
37
|
-
expect(color.r).toEqual(0);
|
|
38
|
-
expect(color.g).toEqual(0);
|
|
39
|
-
expect(color.b).toEqual(0);
|
|
40
|
-
expect(color.a).toEqual(255);
|
|
41
|
-
});
|
|
42
|
-
it("Clamps the color values to a maximum value of 255", () => {
|
|
43
|
-
const color = Color_1.Color.RGB(300, 300, 300);
|
|
44
|
-
expect(color.r).toEqual(255);
|
|
45
|
-
expect(color.g).toEqual(255);
|
|
46
|
-
expect(color.b).toEqual(255);
|
|
47
|
-
expect(color.a).toEqual(255);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe("Color from Hex", () => {
|
|
51
|
-
// See https://www.rapidtables.com/convert/color/hex-to-rgb.html
|
|
52
|
-
it("Properly converts red", () => {
|
|
53
|
-
const color = Color_1.Color.Hex("FF0000");
|
|
54
|
-
expect(color.r).toEqual(255);
|
|
55
|
-
expect(color.g).toEqual(0);
|
|
56
|
-
expect(color.b).toEqual(0);
|
|
57
|
-
expect(color.a).toEqual(255);
|
|
58
|
-
});
|
|
59
|
-
it("Properly converts green", () => {
|
|
60
|
-
const color = Color_1.Color.Hex("00FF00");
|
|
61
|
-
expect(color.r).toEqual(0);
|
|
62
|
-
expect(color.g).toEqual(255);
|
|
63
|
-
expect(color.b).toEqual(0);
|
|
64
|
-
expect(color.a).toEqual(255);
|
|
65
|
-
});
|
|
66
|
-
it("Properly converts blue", () => {
|
|
67
|
-
const color = Color_1.Color.Hex("0000FF");
|
|
68
|
-
expect(color.r).toEqual(0);
|
|
69
|
-
expect(color.g).toEqual(0);
|
|
70
|
-
expect(color.b).toEqual(255);
|
|
71
|
-
expect(color.a).toEqual(255);
|
|
72
|
-
});
|
|
73
|
-
it("Properly converts gray", () => {
|
|
74
|
-
const color = Color_1.Color.Hex("808080");
|
|
75
|
-
expect(color.r).toEqual(128);
|
|
76
|
-
expect(color.g).toEqual(128);
|
|
77
|
-
expect(color.b).toEqual(128);
|
|
78
|
-
expect(color.a).toEqual(255);
|
|
79
|
-
});
|
|
80
|
-
it("Warns if something goes wrong and returns black", () => {
|
|
81
|
-
console.warn = jest.fn();
|
|
82
|
-
const color = Color_1.Color.Hex("Your Mom goes to college");
|
|
83
|
-
expect(color.r).toEqual(0);
|
|
84
|
-
expect(color.g).toEqual(0);
|
|
85
|
-
expect(color.b).toEqual(0);
|
|
86
|
-
expect(color.a).toEqual(255);
|
|
87
|
-
expect(console.warn).toBeCalled();
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
describe("Color from X11", () => {
|
|
91
|
-
it("Finds the proper color by name", () => {
|
|
92
|
-
const color = Color_1.Color.X11("OrangeRed");
|
|
93
|
-
expect(color.r).toEqual(255);
|
|
94
|
-
expect(color.g).toEqual(69);
|
|
95
|
-
expect(color.b).toEqual(0);
|
|
96
|
-
expect(color.a).toEqual(255);
|
|
97
|
-
});
|
|
98
|
-
it("Warns if the X11 color is not found and returns black", () => {
|
|
99
|
-
console.warn = jest.fn();
|
|
100
|
-
const color = Color_1.Color.X11("Your Mom goes to college");
|
|
101
|
-
expect(color.r).toEqual(0);
|
|
102
|
-
expect(color.g).toEqual(0);
|
|
103
|
-
expect(color.b).toEqual(0);
|
|
104
|
-
expect(color.a).toEqual(255);
|
|
105
|
-
expect(console.warn).toBeCalled();
|
|
106
|
-
});
|
|
107
|
-
it("Checks for equality", () => {
|
|
108
|
-
const colorA = Color_1.Color.X11("OrangeRed");
|
|
109
|
-
const colorB = Color_1.Color.X11("LemonChiffon");
|
|
110
|
-
const colorC = Color_1.Color.X11("OrangeRed");
|
|
111
|
-
expect(Color_1.Color.Equal(colorA, colorC)).toEqual(true);
|
|
112
|
-
expect(Color_1.Color.Equal(colorA, colorB)).toEqual(false);
|
|
113
|
-
});
|
|
114
|
-
it("Gets the hex", () => {
|
|
115
|
-
const c = Color_1.Color.Hex("#fcba03");
|
|
116
|
-
expect(c.hex).toEqual("#fcba03");
|
|
117
|
-
});
|
|
118
|
-
it("Gets the Data Transfer Object", () => {
|
|
119
|
-
const color = Color_1.Color.RGBA(10, 20, 30, 40);
|
|
120
|
-
expect(color.dto).toEqual({
|
|
121
|
-
r: 10,
|
|
122
|
-
g: 20,
|
|
123
|
-
b: 30,
|
|
124
|
-
a: 40,
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
it("Makes a Color from a DTO", () => {
|
|
128
|
-
const color = Color_1.Color.FromDTO({
|
|
129
|
-
r: 10,
|
|
130
|
-
g: 20,
|
|
131
|
-
b: 30,
|
|
132
|
-
a: 40,
|
|
133
|
-
});
|
|
134
|
-
expect(color.r).toEqual(10);
|
|
135
|
-
expect(color.g).toEqual(20);
|
|
136
|
-
expect(color.b).toEqual(30);
|
|
137
|
-
expect(color.a).toEqual(40);
|
|
138
|
-
});
|
|
139
|
-
it("Color name is not case sensitive", () => {
|
|
140
|
-
const color1 = Color_1.Color.X11("OrangeRed");
|
|
141
|
-
const color2 = Color_1.Color.X11("orangered");
|
|
142
|
-
const color3 = Color_1.Color.X11("orangeRed");
|
|
143
|
-
expect(color1).toEqual(color2);
|
|
144
|
-
expect(color1).toEqual(color3);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
//# sourceMappingURL=Color.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Color.test.js","sourceRoot":"","sources":["../../../src/ValueObjects/Color.test.ts"],"names":[],"mapp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,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { Color } from \"./Color\";\r\n\r\ndescribe(\"Color value object - RGBA\", () => {\r\n it(\"Make a color as expected\", () => {\r\n const color = Color.RGBA(10, 20, 30, 40);\r\n\r\n expect(color.r).toEqual(10);\r\n expect(color.g).toEqual(20);\r\n expect(color.b).toEqual(30);\r\n expect(color.a).toEqual(40);\r\n });\r\n\r\n it(\"Clamps the color values to a minumum value of 0\", () => {\r\n const color = Color.RGBA(-1, -1, -1, -1);\r\n\r\n expect(color.r).toEqual(0);\r\n expect(color.g).toEqual(0);\r\n expect(color.b).toEqual(0);\r\n expect(color.a).toEqual(0);\r\n });\r\n\r\n it(\"Clamps the color values to a maximum value of 255\", () => {\r\n const color = Color.RGBA(300, 300, 300, 300);\r\n\r\n expect(color.r).toEqual(255);\r\n expect(color.g).toEqual(255);\r\n expect(color.b).toEqual(255);\r\n expect(color.a).toEqual(255);\r\n });\r\n});\r\n\r\ndescribe(\"Color value object - RGB\", () => {\r\n it(\"Make a color as expected\", () => {\r\n const color = Color.RGB(10, 20, 30);\r\n\r\n expect(color.r).toEqual(10);\r\n expect(color.g).toEqual(20);\r\n expect(color.b).toEqual(30);\r\n expect(color.a).toEqual(255);\r\n });\r\n\r\n it(\"Clamps the color values to a minumum value of 0\", () => {\r\n const color = Color.RGB(-1, -1, -1);\r\n\r\n expect(color.r).toEqual(0);\r\n expect(color.g).toEqual(0);\r\n expect(color.b).toEqual(0);\r\n expect(color.a).toEqual(255);\r\n });\r\n\r\n it(\"Clamps the color values to a maximum value of 255\", () => {\r\n const color = Color.RGB(300, 300, 300);\r\n\r\n expect(color.r).toEqual(255);\r\n expect(color.g).toEqual(255);\r\n expect(color.b).toEqual(255);\r\n expect(color.a).toEqual(255);\r\n });\r\n});\r\n\r\ndescribe(\"Color from Hex\", () => {\r\n // See https://www.rapidtables.com/convert/color/hex-to-rgb.html\r\n it(\"Properly converts red\", () => {\r\n const color = Color.Hex(\"FF0000\");\r\n\r\n expect(color.r).toEqual(255);\r\n expect(color.g).toEqual(0);\r\n expect(color.b).toEqual(0);\r\n expect(color.a).toEqual(255);\r\n });\r\n\r\n it(\"Properly converts green\", () => {\r\n const color = Color.Hex(\"00FF00\");\r\n\r\n expect(color.r).toEqual(0);\r\n expect(color.g).toEqual(255);\r\n expect(color.b).toEqual(0);\r\n expect(color.a).toEqual(255);\r\n });\r\n\r\n it(\"Properly converts blue\", () => {\r\n const color = Color.Hex(\"0000FF\");\r\n\r\n expect(color.r).toEqual(0);\r\n expect(color.g).toEqual(0);\r\n expect(color.b).toEqual(255);\r\n expect(color.a).toEqual(255);\r\n });\r\n\r\n it(\"Properly converts gray\", () => {\r\n const color = Color.Hex(\"808080\");\r\n\r\n expect(color.r).toEqual(128);\r\n expect(color.g).toEqual(128);\r\n expect(color.b).toEqual(128);\r\n expect(color.a).toEqual(255);\r\n });\r\n\r\n it(\"Warns if something goes wrong and returns black\", () => {\r\n console.warn = jest.fn();\r\n const color = Color.Hex(\"Your Mom goes to college\");\r\n\r\n expect(color.r).toEqual(0);\r\n expect(color.g).toEqual(0);\r\n expect(color.b).toEqual(0);\r\n expect(color.a).toEqual(255);\r\n\r\n expect(console.warn).toBeCalled();\r\n });\r\n});\r\n\r\ndescribe(\"Color from X11\", () => {\r\n it(\"Finds the proper color by name\", () => {\r\n const color = Color.X11(\"OrangeRed\");\r\n\r\n expect(color.r).toEqual(255);\r\n expect(color.g).toEqual(69);\r\n expect(color.b).toEqual(0);\r\n expect(color.a).toEqual(255);\r\n });\r\n\r\n it(\"Warns if the X11 color is not found and returns black\", () => {\r\n console.warn = jest.fn();\r\n const color = Color.X11(\"Your Mom goes to college\");\r\n\r\n expect(color.r).toEqual(0);\r\n expect(color.g).toEqual(0);\r\n expect(color.b).toEqual(0);\r\n expect(color.a).toEqual(255);\r\n\r\n expect(console.warn).toBeCalled();\r\n });\r\n\r\n it(\"Checks for equality\", () => {\r\n const colorA = Color.X11(\"OrangeRed\");\r\n const colorB = Color.X11(\"LemonChiffon\");\r\n const colorC = Color.X11(\"OrangeRed\");\r\n\r\n expect(Color.Equal(colorA, colorC)).toEqual(true);\r\n expect(Color.Equal(colorA, colorB)).toEqual(false);\r\n });\r\n\r\n it(\"Gets the hex\", () => {\r\n const c = Color.Hex(\"#fcba03\");\r\n expect(c.hex).toEqual(\"#fcba03\");\r\n });\r\n\r\n it(\"Gets the Data Transfer Object\", () => {\r\n const color = Color.RGBA(10, 20, 30, 40);\r\n\r\n expect(color.dto).toEqual({\r\n r: 10,\r\n g: 20,\r\n b: 30,\r\n a: 40,\r\n });\r\n });\r\n\r\n it(\"Makes a Color from a DTO\", () => {\r\n const color = Color.FromDTO({\r\n r: 10,\r\n g: 20,\r\n b: 30,\r\n a: 40,\r\n });\r\n\r\n expect(color.r).toEqual(10);\r\n expect(color.g).toEqual(20);\r\n expect(color.b).toEqual(30);\r\n expect(color.a).toEqual(40);\r\n });\r\n\r\n it(\"Color name is not case sensitive\", () => {\r\n const color1 = Color.X11(\"OrangeRed\");\r\n const color2 = Color.X11(\"orangered\");\r\n const color3 = Color.X11(\"orangeRed\");\r\n\r\n expect(color1).toEqual(color2);\r\n expect(color1).toEqual(color3);\r\n });\r\n});\r\n"]}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LineSegment2D = void 0;
|
|
4
|
-
const Vector2_1 = require("./Vector2");
|
|
5
|
-
class LineSegment2D {
|
|
6
|
-
static GetPositionAtPercent(line, percent) {
|
|
7
|
-
const dir = line.direction;
|
|
8
|
-
const length = percent * line.length;
|
|
9
|
-
const localPos = Vector2_1.Vector2.NewVectorOfLength(dir, length);
|
|
10
|
-
return Vector2_1.Vector2.Add(line.start, localPos);
|
|
11
|
-
}
|
|
12
|
-
static Intersect(a, b, tolerance = 0) {
|
|
13
|
-
// See https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
|
|
14
|
-
const x1 = a.start.x;
|
|
15
|
-
const y1 = a.start.y;
|
|
16
|
-
const x2 = a.end.x;
|
|
17
|
-
const y2 = a.end.y;
|
|
18
|
-
const x3 = b.start.x;
|
|
19
|
-
const y3 = b.start.y;
|
|
20
|
-
const x4 = b.end.x;
|
|
21
|
-
const y4 = b.end.y;
|
|
22
|
-
const denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
|
|
23
|
-
if (denominator === 0) {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
const tNumerator = (x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4);
|
|
27
|
-
const t = tNumerator / denominator;
|
|
28
|
-
const tTolearnce = tolerance / a.length;
|
|
29
|
-
if (t < -tTolearnce || t > 1 + tTolearnce) {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
const uNumerator = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
|
|
33
|
-
const u = uNumerator / denominator;
|
|
34
|
-
const uTolearnce = tolerance / b.length;
|
|
35
|
-
if (u < -uTolearnce || u > 1 + uTolearnce)
|
|
36
|
-
return undefined;
|
|
37
|
-
const px = x1 + t * (x2 - x1);
|
|
38
|
-
const py = y1 + t * (y2 - y1);
|
|
39
|
-
return new Vector2_1.Vector2(px, py);
|
|
40
|
-
}
|
|
41
|
-
static ClosestPointOnLine(line, point) {
|
|
42
|
-
// see https://monkeyproofsolutions.nl/wordpress/how-to-calculate-the-shortest-distance-between-a-point-and-a-line/
|
|
43
|
-
let direction = Vector2_1.Vector2.Subtract(line.end, line.start);
|
|
44
|
-
const pointToStart = Vector2_1.Vector2.Subtract(point, line.start);
|
|
45
|
-
const tNumerator = Vector2_1.Vector2.Dot(direction, pointToStart);
|
|
46
|
-
const tDenominator = Vector2_1.Vector2.Dot(direction, direction);
|
|
47
|
-
const t = tNumerator / tDenominator;
|
|
48
|
-
if (t < 0) {
|
|
49
|
-
return line.start;
|
|
50
|
-
}
|
|
51
|
-
else if (t > 1) {
|
|
52
|
-
return line.end;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const length = t * direction.magnitued;
|
|
56
|
-
direction = Vector2_1.Vector2.NewVectorOfLength(direction, length);
|
|
57
|
-
return Vector2_1.Vector2.Add(line.start, direction);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
get length() {
|
|
61
|
-
return Vector2_1.Vector2.Subtract(this.start, this.end).magnitued;
|
|
62
|
-
}
|
|
63
|
-
get direction() {
|
|
64
|
-
return Vector2_1.Vector2.Subtract(this.end, this.start).unit;
|
|
65
|
-
}
|
|
66
|
-
constructor(start, end) {
|
|
67
|
-
this.start = start;
|
|
68
|
-
this.end = end;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.LineSegment2D = LineSegment2D;
|
|
72
|
-
//# sourceMappingURL=LineSegment2D.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LineSegment2D.js","sourceRoot":"","sources":["../../../src/ValueObjects/LineSegment2D.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AAEpC,MAAa,aAAa;IACjB,MAAM,CAAC,oBAAoB,CAChC,IAAmB,EACnB,OAAe;QAEf,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,MAAM,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAErC,MAAM,QAAQ,GAAG,iBAAO,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAExD,OAAO,iBAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAEM,MAAM,CAAC,SAAS,CACrB,CAAgB,EAChB,CAAgB,EAChB,SAAS,GAAG,CAAC;QAEb,mEAAmE;QACnE,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACrB,MAAM,EAAE,GAAG,CA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,OAAO,iBAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAKD,IAAW,MAAM;QACf,OAAO,iBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,iBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;IACrD,CAAC;IAED,YAAY,KAAc,EAAE,GAAY;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;AA1FD,sCA0FC","sourcesContent":["import { Vector2 } from \"./Vector2\";\r\n\r\nexport class LineSegment2D {\r\n public static GetPositionAtPercent(\r\n line: LineSegment2D,\r\n percent: number\r\n ): Vector2 {\r\n const dir = line.direction;\r\n const length = percent * line.length;\r\n\r\n const localPos = Vector2.NewVectorOfLength(dir, length);\r\n\r\n return Vector2.Add(line.start, localPos);\r\n }\r\n\r\n public static Intersect(\r\n a: LineSegment2D,\r\n b: LineSegment2D,\r\n tolerance = 0\r\n ): Vector2 | undefined {\r\n // See https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection\r\n const x1 = a.start.x;\r\n const y1 = a.start.y;\r\n const x2 = a.end.x;\r\n const y2 = a.end.y;\r\n const x3 = b.start.x;\r\n const y3 = b.start.y;\r\n const x4 = b.end.x;\r\n const y4 = b.end.y;\r\n\r\n const denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);\r\n if (denominator === 0) {\r\n return undefined;\r\n }\r\n\r\n const tNumerator = (x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4);\r\n const t = tNumerator / denominator;\r\n\r\n const tTolearnce = tolerance / a.length;\r\n if (t < -tTolearnce || t > 1 + tTolearnce) {\r\n return undefined;\r\n }\r\n\r\n const uNumerator = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);\r\n const u = uNumerator / denominator;\r\n\r\n const uTolearnce = tolerance / b.length;\r\n if (u < -uTolearnce || u > 1 + uTolearnce) return undefined;\r\n\r\n const px = x1 + t * (x2 - x1);\r\n const py = y1 + t * (y2 - y1);\r\n\r\n return new Vector2(px, py);\r\n }\r\n\r\n public static ClosestPointOnLine(\r\n line: LineSegment2D,\r\n point: Vector2\r\n ): Vector2 {\r\n // see https://monkeyproofsolutions.nl/wordpress/how-to-calculate-the-shortest-distance-between-a-point-and-a-line/\r\n let direction = Vector2.Subtract(line.end, line.start);\r\n const pointToStart = Vector2.Subtract(point, line.start);\r\n const tNumerator = Vector2.Dot(direction, pointToStart);\r\n const tDenominator = Vector2.Dot(direction, direction);\r\n const t = tNumerator / tDenominator;\r\n\r\n if (t < 0) {\r\n return line.start;\r\n } else if (t > 1) {\r\n return line.end;\r\n } else {\r\n const length = t * direction.magnitued;\r\n direction = Vector2.NewVectorOfLength(direction, length);\r\n return Vector2.Add(line.start, direction);\r\n }\r\n }\r\n\r\n readonly start: Vector2;\r\n readonly end: Vector2;\r\n\r\n public get length(): number {\r\n return Vector2.Subtract(this.start, this.end).magnitued;\r\n }\r\n\r\n public get direction(): Vector2 {\r\n return Vector2.Subtract(this.end, this.start).unit;\r\n }\r\n\r\n constructor(start: Vector2, end: Vector2) {\r\n this.start = start;\r\n this.end = end;\r\n }\r\n}\r\n"]}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Vector2_1 = require("./Vector2");
|
|
4
|
-
const LineSegment2D_1 = require("./LineSegment2D");
|
|
5
|
-
test("Construction stores the start and end pos", () => {
|
|
6
|
-
const start = new Vector2_1.Vector2(2, 3);
|
|
7
|
-
const end = new Vector2_1.Vector2(4, 5);
|
|
8
|
-
const seg = new LineSegment2D_1.LineSegment2D(start, end);
|
|
9
|
-
expect(seg.end.x).toEqual(4);
|
|
10
|
-
expect(seg.end.y).toEqual(5);
|
|
11
|
-
expect(seg.start.x).toEqual(2);
|
|
12
|
-
expect(seg.start.y).toEqual(3);
|
|
13
|
-
});
|
|
14
|
-
test("Direction", () => {
|
|
15
|
-
const start = new Vector2_1.Vector2(2, 3);
|
|
16
|
-
const end = new Vector2_1.Vector2(2, 5);
|
|
17
|
-
const seg = new LineSegment2D_1.LineSegment2D(start, end);
|
|
18
|
-
expect(seg.direction.x).toEqual(0);
|
|
19
|
-
expect(seg.direction.y).toEqual(1);
|
|
20
|
-
});
|
|
21
|
-
test("Direction", () => {
|
|
22
|
-
const start = new Vector2_1.Vector2(2, 3);
|
|
23
|
-
const end = new Vector2_1.Vector2(-10, 3);
|
|
24
|
-
const seg = new LineSegment2D_1.LineSegment2D(start, end);
|
|
25
|
-
expect(seg.direction.x).toEqual(-1);
|
|
26
|
-
expect(seg.direction.y).toEqual(0);
|
|
27
|
-
});
|
|
28
|
-
test("Length", () => {
|
|
29
|
-
const start = new Vector2_1.Vector2(0, 0);
|
|
30
|
-
const end = new Vector2_1.Vector2(10, 0);
|
|
31
|
-
const seg = new LineSegment2D_1.LineSegment2D(start, end);
|
|
32
|
-
expect(seg.length).toEqual(10);
|
|
33
|
-
});
|
|
34
|
-
test("Position at percent", () => {
|
|
35
|
-
const start = new Vector2_1.Vector2(0, 0);
|
|
36
|
-
const end = new Vector2_1.Vector2(10, 0);
|
|
37
|
-
const seg = new LineSegment2D_1.LineSegment2D(start, end);
|
|
38
|
-
const zero = LineSegment2D_1.LineSegment2D.GetPositionAtPercent(seg, 0);
|
|
39
|
-
expect(zero.x).toEqual(0);
|
|
40
|
-
expect(zero.y).toEqual(0);
|
|
41
|
-
const one = LineSegment2D_1.LineSegment2D.GetPositionAtPercent(seg, 1);
|
|
42
|
-
expect(one.x).toEqual(10);
|
|
43
|
-
expect(one.y).toEqual(0);
|
|
44
|
-
});
|
|
45
|
-
test("Intersect", () => {
|
|
46
|
-
const lineA = new LineSegment2D_1.LineSegment2D(new Vector2_1.Vector2(1, 1), new Vector2_1.Vector2(15, 1));
|
|
47
|
-
const lineB = new LineSegment2D_1.LineSegment2D(new Vector2_1.Vector2(10, -2), new Vector2_1.Vector2(10, 2));
|
|
48
|
-
const intersection = LineSegment2D_1.LineSegment2D.Intersect(lineA, lineB);
|
|
49
|
-
expect(intersection?.x).toEqual(10);
|
|
50
|
-
expect(intersection?.y).toEqual(1);
|
|
51
|
-
});
|
|
52
|
-
test("Intersect with tolerance", () => {
|
|
53
|
-
const lineA = new LineSegment2D_1.LineSegment2D(new Vector2_1.Vector2(1, 1), new Vector2_1.Vector2(9.5, 1));
|
|
54
|
-
const lineB = new LineSegment2D_1.LineSegment2D(new Vector2_1.Vector2(10, -2), new Vector2_1.Vector2(10, 2));
|
|
55
|
-
const intersection1 = LineSegment2D_1.LineSegment2D.Intersect(lineA, lineB, 0.2);
|
|
56
|
-
expect(intersection1).toBeUndefined();
|
|
57
|
-
const intersection2 = LineSegment2D_1.LineSegment2D.Intersect(lineA, lineB, 0.5);
|
|
58
|
-
expect(intersection2?.x).toEqual(10);
|
|
59
|
-
expect(intersection2?.y).toEqual(1);
|
|
60
|
-
});
|
|
61
|
-
test("Parallel line should not intersect", () => {
|
|
62
|
-
const lineA = new LineSegment2D_1.LineSegment2D(new Vector2_1.Vector2(1, 0), new Vector2_1.Vector2(15, 0));
|
|
63
|
-
const lineB = new LineSegment2D_1.LineSegment2D(new Vector2_1.Vector2(0, 0), new Vector2_1.Vector2(10, 0));
|
|
64
|
-
const intersection = LineSegment2D_1.LineSegment2D.Intersect(lineA, lineB);
|
|
65
|
-
expect(intersection).toBeUndefined();
|
|
66
|
-
});
|
|
67
|
-
test("Short segments should not intersect", () => {
|
|
68
|
-
const lineA = new LineSegment2D_1.LineSegment2D(new Vector2_1.Vector2(1, 1), new Vector2_1.Vector2(9, 1));
|
|
69
|
-
const lineB = new LineSegment2D_1.LineSegment2D(new Vector2_1.Vector2(10, -2), new Vector2_1.Vector2(10, 2));
|
|
70
|
-
const intersection = LineSegment2D_1.LineSegment2D.Intersect(lineA, lineB);
|
|
71
|
-
expect(intersection).toBeUndefined();
|
|
72
|
-
});
|
|
73
|
-
test("Equality", () => {
|
|
74
|
-
const lineA = new LineSegment2D_1.LineSegment2D(new Vector2_1.Vector2(1, 0), new Vector2_1.Vector2(15, 0));
|
|
75
|
-
const lineB = new LineSegment2D_1.LineSegment2D(new Vector2_1.Vector2(1, 0), new Vector2_1.Vector2(15, 0));
|
|
76
|
-
expect(lineA).toEqual(lineB);
|
|
77
|
-
});
|
|
78
|
-
test("Closest point", () => {
|
|
79
|
-
const startPosition = new Vector2_1.Vector2(-9, 2);
|
|
80
|
-
const endPosition = new Vector2_1.Vector2(3, 2);
|
|
81
|
-
const line = new LineSegment2D_1.LineSegment2D(startPosition, endPosition);
|
|
82
|
-
const closestPoint = LineSegment2D_1.LineSegment2D.ClosestPointOnLine(line, new Vector2_1.Vector2(1, 1));
|
|
83
|
-
expect(closestPoint.x).toEqual(1);
|
|
84
|
-
expect(closestPoint.y).toEqual(2);
|
|
85
|
-
});
|
|
86
|
-
test("Closest point should be clamped to the start", () => {
|
|
87
|
-
const startPosition = new Vector2_1.Vector2(-9, 2);
|
|
88
|
-
const endPosition = new Vector2_1.Vector2(3, 2);
|
|
89
|
-
const line = new LineSegment2D_1.LineSegment2D(startPosition, endPosition);
|
|
90
|
-
const closestPoint = LineSegment2D_1.LineSegment2D.ClosestPointOnLine(line, new Vector2_1.Vector2(-12, 2));
|
|
91
|
-
expect(closestPoint.x).toEqual(-9);
|
|
92
|
-
expect(closestPoint.y).toEqual(2);
|
|
93
|
-
});
|
|
94
|
-
test("Closest point should be clamped to the end", () => {
|
|
95
|
-
const startPosition = new Vector2_1.Vector2(-9, 2);
|
|
96
|
-
const endPosition = new Vector2_1.Vector2(3, 2);
|
|
97
|
-
const line = new LineSegment2D_1.LineSegment2D(startPosition, endPosition);
|
|
98
|
-
const closestPoint = LineSegment2D_1.LineSegment2D.ClosestPointOnLine(line, new Vector2_1.Vector2(5, 2));
|
|
99
|
-
expect(closestPoint.x).toEqual(3);
|
|
100
|
-
expect(closestPoint.y).toEqual(2);
|
|
101
|
-
});
|
|
102
|
-
//# sourceMappingURL=LineSegment2D.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LineSegment2D.test.js","sourceRoot":"","sources":["../../../src/ValueObjects/LineSegment2D.test.ts"],"names":[],"mappings":";;AAAA,uCAAoC;AACpC,mDAAgD;AAEhD,IAAI,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACrD,MAAM,KAAK,GAAG,IAAI,iBAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,iBAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAI,6BAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAE1C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE7B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;IACrB,MAAM,KAAK,GAAG,IAAI,iBAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,iBAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC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,6BAAa,CAAC,kBAAkB,CACnD,IAAI,EACJ,IAAI,iBAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAClB,CAAC;IAEF,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC","sourcesContent":["import { Vector2 } from \"./Vector2\";\r\nimport { LineSegment2D } from \"./LineSegment2D\";\r\n\r\ntest(\"Construction stores the start and end pos\", () => {\r\n const start = new Vector2(2, 3);\r\n const end = new Vector2(4, 5);\r\n const seg = new LineSegment2D(start, end);\r\n\r\n expect(seg.end.x).toEqual(4);\r\n expect(seg.end.y).toEqual(5);\r\n\r\n expect(seg.start.x).toEqual(2);\r\n expect(seg.start.y).toEqual(3);\r\n});\r\n\r\ntest(\"Direction\", () => {\r\n const start = new Vector2(2, 3);\r\n const end = new Vector2(2, 5);\r\n const seg = new LineSegment2D(start, end);\r\n\r\n expect(seg.direction.x).toEqual(0);\r\n expect(seg.direction.y).toEqual(1);\r\n});\r\n\r\ntest(\"Direction\", () => {\r\n const start = new Vector2(2, 3);\r\n const end = new Vector2(-10, 3);\r\n const seg = new LineSegment2D(start, end);\r\n\r\n expect(seg.direction.x).toEqual(-1);\r\n expect(seg.direction.y).toEqual(0);\r\n});\r\n\r\ntest(\"Length\", () => {\r\n const start = new Vector2(0, 0);\r\n const end = new Vector2(10, 0);\r\n const seg = new LineSegment2D(start, end);\r\n\r\n expect(seg.length).toEqual(10);\r\n});\r\n\r\ntest(\"Position at percent\", () => {\r\n const start = new Vector2(0, 0);\r\n const end = new Vector2(10, 0);\r\n const seg = new LineSegment2D(start, end);\r\n\r\n const zero = LineSegment2D.GetPositionAtPercent(seg, 0);\r\n expect(zero.x).toEqual(0);\r\n expect(zero.y).toEqual(0);\r\n\r\n const one = LineSegment2D.GetPositionAtPercent(seg, 1);\r\n expect(one.x).toEqual(10);\r\n expect(one.y).toEqual(0);\r\n});\r\n\r\ntest(\"Intersect\", () => {\r\n const lineA = new LineSegment2D(new Vector2(1, 1), new Vector2(15, 1));\r\n const lineB = new LineSegment2D(new Vector2(10, -2), new Vector2(10, 2));\r\n\r\n const intersection = LineSegment2D.Intersect(lineA, lineB);\r\n\r\n expect(intersection?.x).toEqual(10);\r\n expect(intersection?.y).toEqual(1);\r\n});\r\n\r\ntest(\"Intersect with tolerance\", () => {\r\n const lineA = new LineSegment2D(new Vector2(1, 1), new Vector2(9.5, 1));\r\n const lineB = new LineSegment2D(new Vector2(10, -2), new Vector2(10, 2));\r\n\r\n const intersection1 = LineSegment2D.Intersect(lineA, lineB, 0.2);\r\n expect(intersection1).toBeUndefined();\r\n\r\n const intersection2 = LineSegment2D.Intersect(lineA, lineB, 0.5);\r\n\r\n expect(intersection2?.x).toEqual(10);\r\n expect(intersection2?.y).toEqual(1);\r\n});\r\n\r\ntest(\"Parallel line should not intersect\", () => {\r\n const lineA = new LineSegment2D(new Vector2(1, 0), new Vector2(15, 0));\r\n const lineB = new LineSegment2D(new Vector2(0, 0), new Vector2(10, 0));\r\n\r\n const intersection = LineSegment2D.Intersect(lineA, lineB);\r\n\r\n expect(intersection).toBeUndefined();\r\n});\r\n\r\ntest(\"Short segments should not intersect\", () => {\r\n const lineA = new LineSegment2D(new Vector2(1, 1), new Vector2(9, 1));\r\n const lineB = new LineSegment2D(new Vector2(10, -2), new Vector2(10, 2));\r\n\r\n const intersection = LineSegment2D.Intersect(lineA, lineB);\r\n\r\n expect(intersection).toBeUndefined();\r\n});\r\n\r\ntest(\"Equality\", () => {\r\n const lineA = new LineSegment2D(new Vector2(1, 0), new Vector2(15, 0));\r\n const lineB = new LineSegment2D(new Vector2(1, 0), new Vector2(15, 0));\r\n\r\n expect(lineA).toEqual(lineB);\r\n});\r\n\r\ntest(\"Closest point\", () => {\r\n const startPosition = new Vector2(-9, 2);\r\n const endPosition = new Vector2(3, 2);\r\n const line = new LineSegment2D(startPosition, endPosition);\r\n\r\n const closestPoint = LineSegment2D.ClosestPointOnLine(\r\n line,\r\n new Vector2(1, 1)\r\n );\r\n\r\n expect(closestPoint.x).toEqual(1);\r\n expect(closestPoint.y).toEqual(2);\r\n});\r\n\r\ntest(\"Closest point should be clamped to the start\", () => {\r\n const startPosition = new Vector2(-9, 2);\r\n const endPosition = new Vector2(3, 2);\r\n const line = new LineSegment2D(startPosition, endPosition);\r\n\r\n const closestPoint = LineSegment2D.ClosestPointOnLine(\r\n line,\r\n new Vector2(-12, 2)\r\n );\r\n\r\n expect(closestPoint.x).toEqual(-9);\r\n expect(closestPoint.y).toEqual(2);\r\n});\r\n\r\ntest(\"Closest point should be clamped to the end\", () => {\r\n const startPosition = new Vector2(-9, 2);\r\n const endPosition = new Vector2(3, 2);\r\n const line = new LineSegment2D(startPosition, endPosition);\r\n\r\n const closestPoint = LineSegment2D.ClosestPointOnLine(\r\n line,\r\n new Vector2(5, 2)\r\n );\r\n\r\n expect(closestPoint.x).toEqual(3);\r\n expect(closestPoint.y).toEqual(2);\r\n});\r\n"]}
|