@armyc2.c5isr.renderer/mil-sym-ts-web 2.2.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.
Files changed (170) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +57 -0
  3. package/buildNode.bat +2 -0
  4. package/buildWeb.bat +2 -0
  5. package/dist/C5Ren.d.ts +6970 -0
  6. package/dist/C5Ren.js +2 -0
  7. package/dist/C5Ren.js.map +1 -0
  8. package/dist/LICENSE +201 -0
  9. package/dist/README.md +57 -0
  10. package/dist/armyc2.c5isr.renderer-mil-sym-ts-web-2.2.0.tgz +0 -0
  11. package/dist/manifest.json +4 -0
  12. package/dist/package.json +16 -0
  13. package/index.ts +169 -0
  14. package/package.bak +50 -0
  15. package/package.json +40 -0
  16. package/package.node.json +43 -0
  17. package/package.pack.json +19 -0
  18. package/package.packWeb.json +16 -0
  19. package/package.web.json +40 -0
  20. package/src/main/ts/android/graphics/Bitmap.ts +7 -0
  21. package/src/main/ts/android/graphics/Paint.ts +26 -0
  22. package/src/main/ts/android/graphics/Path.ts +78 -0
  23. package/src/main/ts/android/graphics/PointF.ts +14 -0
  24. package/src/main/ts/android/graphics/Rect.ts +18 -0
  25. package/src/main/ts/android/graphics/RectF.ts +50 -0
  26. package/src/main/ts/android/graphics/Region.ts +36 -0
  27. package/src/main/ts/android/graphics/Typeface.ts +11 -0
  28. package/src/main/ts/armyc2/c5isr/JavaLineArray/BasicShapes.ts +99 -0
  29. package/src/main/ts/armyc2/c5isr/JavaLineArray/CChannelPoints2.ts +34 -0
  30. package/src/main/ts/armyc2/c5isr/JavaLineArray/CELineArray.ts +193 -0
  31. package/src/main/ts/armyc2/c5isr/JavaLineArray/Channels.ts +2971 -0
  32. package/src/main/ts/armyc2/c5isr/JavaLineArray/DISMSupport.ts +4008 -0
  33. package/src/main/ts/armyc2/c5isr/JavaLineArray/POINT2.ts +93 -0
  34. package/src/main/ts/armyc2/c5isr/JavaLineArray/Shape2.ts +89 -0
  35. package/src/main/ts/armyc2/c5isr/JavaLineArray/TacticalLines.ts +515 -0
  36. package/src/main/ts/armyc2/c5isr/JavaLineArray/arraysupport.ts +5403 -0
  37. package/src/main/ts/armyc2/c5isr/JavaLineArray/countsupport.ts +1084 -0
  38. package/src/main/ts/armyc2/c5isr/JavaLineArray/flot.ts +2173 -0
  39. package/src/main/ts/armyc2/c5isr/JavaLineArray/lineutility.ts +4934 -0
  40. package/src/main/ts/armyc2/c5isr/JavaLineArray/ref.ts +7 -0
  41. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/Modifier2.ts +5601 -0
  42. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/P1.ts +14 -0
  43. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/TGLight.ts +648 -0
  44. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsChannelUtility.ts +647 -0
  45. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsMETOC.ts +2994 -0
  46. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsUtility.ts +2663 -0
  47. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/mdlGeodesic.ts +669 -0
  48. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipPolygon2.ts +971 -0
  49. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipQuad.ts +871 -0
  50. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer.ts +3507 -0
  51. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer2.ts +500 -0
  52. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtility.ts +1089 -0
  53. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityCPOF.ts +2656 -0
  54. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityGE.ts +1419 -0
  55. package/src/main/ts/armyc2/c5isr/data/genc.json +1407 -0
  56. package/src/main/ts/armyc2/c5isr/data/msd.json +17311 -0
  57. package/src/main/ts/armyc2/c5isr/data/mse.json +18500 -0
  58. package/src/main/ts/armyc2/c5isr/data/svgd.json +31214 -0
  59. package/src/main/ts/armyc2/c5isr/data/svge.json +30558 -0
  60. package/src/main/ts/armyc2/c5isr/graphics2d/AffineTransform.ts +10 -0
  61. package/src/main/ts/armyc2/c5isr/graphics2d/Area.ts +437 -0
  62. package/src/main/ts/armyc2/c5isr/graphics2d/BasicStroke.ts +429 -0
  63. package/src/main/ts/armyc2/c5isr/graphics2d/BasicTypes.ts +7 -0
  64. package/src/main/ts/armyc2/c5isr/graphics2d/BufferedImage.ts +35 -0
  65. package/src/main/ts/armyc2/c5isr/graphics2d/Font.ts +111 -0
  66. package/src/main/ts/armyc2/c5isr/graphics2d/FontMetrics.ts +29 -0
  67. package/src/main/ts/armyc2/c5isr/graphics2d/FontRenderContext.ts +18 -0
  68. package/src/main/ts/armyc2/c5isr/graphics2d/GeneralPath.ts +211 -0
  69. package/src/main/ts/armyc2/c5isr/graphics2d/Graphics2D.ts +80 -0
  70. package/src/main/ts/armyc2/c5isr/graphics2d/IPathIterator.ts +33 -0
  71. package/src/main/ts/armyc2/c5isr/graphics2d/ImageIO.ts +16 -0
  72. package/src/main/ts/armyc2/c5isr/graphics2d/Line2D.ts +726 -0
  73. package/src/main/ts/armyc2/c5isr/graphics2d/PathIterator.ts +141 -0
  74. package/src/main/ts/armyc2/c5isr/graphics2d/Point.ts +112 -0
  75. package/src/main/ts/armyc2/c5isr/graphics2d/Point2D.ts +261 -0
  76. package/src/main/ts/armyc2/c5isr/graphics2d/Polygon.ts +391 -0
  77. package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle.ts +567 -0
  78. package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle2D.ts +445 -0
  79. package/src/main/ts/armyc2/c5isr/graphics2d/Shape.ts +31 -0
  80. package/src/main/ts/armyc2/c5isr/graphics2d/Stroke.ts +18 -0
  81. package/src/main/ts/armyc2/c5isr/graphics2d/TextLayout.ts +45 -0
  82. package/src/main/ts/armyc2/c5isr/graphics2d/TexturePaint.ts +25 -0
  83. package/src/main/ts/armyc2/c5isr/renderer/IIconRenderer.ts +15 -0
  84. package/src/main/ts/armyc2/c5isr/renderer/IconRenderer.ts +22 -0
  85. package/src/main/ts/armyc2/c5isr/renderer/MilStdIconRenderer.ts +269 -0
  86. package/src/main/ts/armyc2/c5isr/renderer/ModifierRenderer.ts +9882 -0
  87. package/src/main/ts/armyc2/c5isr/renderer/PatternFillRenderer.ts +146 -0
  88. package/src/main/ts/armyc2/c5isr/renderer/SinglePointSVGRenderer.ts +1265 -0
  89. package/src/main/ts/armyc2/c5isr/renderer/shapes/arc.ts +64 -0
  90. package/src/main/ts/armyc2/c5isr/renderer/shapes/bcurve.ts +95 -0
  91. package/src/main/ts/armyc2/c5isr/renderer/shapes/ellipse.ts +93 -0
  92. package/src/main/ts/armyc2/c5isr/renderer/shapes/line.ts +114 -0
  93. package/src/main/ts/armyc2/c5isr/renderer/shapes/path.ts +555 -0
  94. package/src/main/ts/armyc2/c5isr/renderer/shapes/pathiterator.ts +62 -0
  95. package/src/main/ts/armyc2/c5isr/renderer/shapes/point.ts +120 -0
  96. package/src/main/ts/armyc2/c5isr/renderer/shapes/rectangle.ts +431 -0
  97. package/src/main/ts/armyc2/c5isr/renderer/shapes/roundedrectangle.ts +99 -0
  98. package/src/main/ts/armyc2/c5isr/renderer/shapes/types.ts +25 -0
  99. package/src/main/ts/armyc2/c5isr/renderer/shapes/utilities.ts +203 -0
  100. package/src/main/ts/armyc2/c5isr/renderer/utilities/AffiliationColors.ts +104 -0
  101. package/src/main/ts/armyc2/c5isr/renderer/utilities/Color.ts +481 -0
  102. package/src/main/ts/armyc2/c5isr/renderer/utilities/DistanceUnit.ts +40 -0
  103. package/src/main/ts/armyc2/c5isr/renderer/utilities/DrawRules.ts +1323 -0
  104. package/src/main/ts/armyc2/c5isr/renderer/utilities/EntityCode.ts +51 -0
  105. package/src/main/ts/armyc2/c5isr/renderer/utilities/ErrorLogger.ts +736 -0
  106. package/src/main/ts/armyc2/c5isr/renderer/utilities/GENCLookup.ts +106 -0
  107. package/src/main/ts/armyc2/c5isr/renderer/utilities/GeoPixelConversion3D.ts +84 -0
  108. package/src/main/ts/armyc2/c5isr/renderer/utilities/IMultiPointRenderer.ts +87 -0
  109. package/src/main/ts/armyc2/c5isr/renderer/utilities/IPointConversion.ts +34 -0
  110. package/src/main/ts/armyc2/c5isr/renderer/utilities/ImageInfo.ts +324 -0
  111. package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUCache.ts +127 -0
  112. package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUEntry.ts +18 -0
  113. package/src/main/ts/armyc2/c5isr/renderer/utilities/LogLevel.ts +111 -0
  114. package/src/main/ts/armyc2/c5isr/renderer/utilities/MODrawRules.ts +219 -0
  115. package/src/main/ts/armyc2/c5isr/renderer/utilities/MSInfo.ts +1008 -0
  116. package/src/main/ts/armyc2/c5isr/renderer/utilities/MSLookup.ts +882 -0
  117. package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdAttributes.ts +380 -0
  118. package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdSymbol.ts +797 -0
  119. package/src/main/ts/armyc2/c5isr/renderer/utilities/Modifiers.ts +1699 -0
  120. package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversion.ts +178 -0
  121. package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversionDummy.ts +45 -0
  122. package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConverter3D.ts +126 -0
  123. package/src/main/ts/armyc2/c5isr/renderer/utilities/RectUtilities.ts +118 -0
  124. package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererException.ts +11 -0
  125. package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererSettings.ts +1201 -0
  126. package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererUtilities.ts +591 -0
  127. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGInfo.ts +29 -0
  128. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGLookup.ts +753 -0
  129. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGSymbolInfo.ts +137 -0
  130. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGTextInfo.ts +438 -0
  131. package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEvent.ts +19 -0
  132. package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEventListener.ts +10 -0
  133. package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsEventListener.ts +5 -0
  134. package/src/main/ts/armyc2/c5isr/renderer/utilities/Shape2SVG.ts +404 -0
  135. package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeInfo.ts +525 -0
  136. package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeUtilities.ts +55 -0
  137. package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolDimensionInfo.ts +36 -0
  138. package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolID.ts +1055 -0
  139. package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolUtilities.ts +2085 -0
  140. package/src/main/ts/armyc2/c5isr/renderer/utilities/TextInfo.ts +157 -0
  141. package/src/main/ts/armyc2/c5isr/web/render/GeoPixelConversion.ts +86 -0
  142. package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandler.ts +3798 -0
  143. package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandlerSVG.ts +412 -0
  144. package/src/main/ts/armyc2/c5isr/web/render/PointConverter.ts +124 -0
  145. package/src/main/ts/armyc2/c5isr/web/render/SymbolModifiers.ts +26 -0
  146. package/src/main/ts/armyc2/c5isr/web/render/WebRenderer.ts +677 -0
  147. package/src/main/ts/armyc2/c5isr/web/render/utilities/JavaRendererUtilities.ts +484 -0
  148. package/src/main/ts/armyc2/c5isr/web/render/utilities/LineInfo.ts +62 -0
  149. package/src/main/ts/armyc2/c5isr/web/render/utilities/SymbolInfo.ts +46 -0
  150. package/src/main/ts/armyc2/c5isr/web/render/utilities/TextInfo.ts +51 -0
  151. package/src/main/ts/org/gavaghan/geodesy/Angle.ts +31 -0
  152. package/src/main/ts/org/gavaghan/geodesy/Ellipsoid.ts +71 -0
  153. package/src/main/ts/org/gavaghan/geodesy/GeodeticCalculator.ts +200 -0
  154. package/src/main/ts/org/gavaghan/geodesy/GeodeticCurve.ts +55 -0
  155. package/src/main/ts/org/gavaghan/geodesy/GeodeticMeasurement.ts +68 -0
  156. package/src/main/ts/org/gavaghan/geodesy/GlobalCoordinates.ts +103 -0
  157. package/src/main/ts/org/gavaghan/geodesy/GlobalPosition.ts +90 -0
  158. package/test/ExportSPImages.js +692 -0
  159. package/test/MPWW.html +556 -0
  160. package/test/MPWorker.js +318 -0
  161. package/test/SPWorker.js +233 -0
  162. package/test/SVGWW.html +363 -0
  163. package/test/singlePointTester3.html +751 -0
  164. package/tsconfig.json +54 -0
  165. package/typedoc.json +30 -0
  166. package/updateVersion.js +21 -0
  167. package/webpack.config.js +34 -0
  168. package/webpackn.config.js +28 -0
  169. package/webpackr.config.js +47 -0
  170. package/webpackw.config.js +23 -0
@@ -0,0 +1,567 @@
1
+ /*
2
+ * To change this template, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+
6
+ import { type int, type double } from "../graphics2d/BasicTypes";
7
+
8
+ import { AffineTransform } from "../graphics2d/AffineTransform"
9
+ import { Point2D } from "../graphics2d/Point2D"
10
+ import { Rectangle2D } from "../graphics2d/Rectangle2D"
11
+ import { Shape } from "../graphics2d/Shape"
12
+ import { Point } from "./Point";
13
+ import { RectUtilities } from "../renderer/utilities/RectUtilities";
14
+
15
+ /**
16
+ *
17
+ *
18
+ */
19
+ export class Rectangle implements Shape {
20
+ public static readonly OUT_LEFT = 1;
21
+ public static readonly OUT_TOP = 2;
22
+ public static readonly OUT_RIGHT = 4;
23
+ public static readonly OUT_BOTTOM = 8;
24
+ public x: int = 0;
25
+ public y: int = 0;
26
+ public width: int = 0;
27
+ public height: int = 0;
28
+ public constructor();
29
+ public constructor(x1: int, y1: int, width1: int, height1: int);
30
+ public constructor(...args: unknown[]) {
31
+
32
+ switch (args.length) {
33
+ case 0: {
34
+
35
+ this.x = 0;
36
+ this.y = 0;
37
+ this.width = 0;
38
+ this.height = 0;
39
+
40
+ break;
41
+ }
42
+
43
+ case 4: {
44
+ const [x1, y1, width1, height1] = args as [int, int, int, int];
45
+
46
+ this.x = x1;
47
+ this.y = y1;
48
+ this.width = width1;
49
+ this.height = height1;
50
+
51
+ break;
52
+ }
53
+
54
+ default: {
55
+ throw Error(`Invalid number of arguments`);
56
+ }
57
+ }
58
+ }
59
+
60
+ public getShapeType():string
61
+ {
62
+ return "RECTANGLE";
63
+ }
64
+ public getBounds(): Rectangle {
65
+ return new Rectangle(Math.trunc(this.x),Math.trunc(this.y),Math.trunc(this.width),Math.trunc(this.height));
66
+ }
67
+ public getPathIterator(at: AffineTransform): null {
68
+ return null;
69
+ }
70
+ public intersects(rect: Rectangle2D): boolean;
71
+ public intersects(x1: double, y1: double, width1: double, height1: double): boolean;
72
+ public intersects(...args: unknown[]): boolean {
73
+ switch (args.length) {
74
+ case 1: {
75
+ const [rect] = args as [Rectangle2D];
76
+
77
+
78
+ if (this.x + this.width < rect.x) {
79
+
80
+ return false;
81
+ }
82
+
83
+ if (this.x > rect.x + rect.width) {
84
+
85
+ return false;
86
+ }
87
+
88
+ if (this.y + this.height < rect.y) {
89
+
90
+ return false;
91
+ }
92
+
93
+ if (this.y > rect.y + rect.height) {
94
+
95
+ return false;
96
+ }
97
+
98
+
99
+ return true;
100
+
101
+
102
+ break;
103
+ }
104
+
105
+ case 4: {
106
+ const [x1, y1, width1, height1] = args as [double, double, double, double];
107
+
108
+
109
+ if (this.x + this.width < x1) {
110
+
111
+ return false;
112
+ }
113
+
114
+ if (this.x > x1 + width1) {
115
+
116
+ return false;
117
+ }
118
+
119
+ if (this.y + this.height < y1) {
120
+
121
+ return false;
122
+ }
123
+
124
+ if (this.y > y1 + height1) {
125
+
126
+ return false;
127
+ }
128
+
129
+
130
+ return true;
131
+
132
+
133
+ break;
134
+ }
135
+
136
+ default: {
137
+ throw Error(`Invalid number of arguments`);
138
+ }
139
+ }
140
+ }
141
+
142
+ public contains(pt: Point2D): boolean;
143
+ public contains(x1: int, y1: int): boolean;
144
+ public contains(x1: int, y1: int, width1: int, height1: int): boolean;
145
+ public contains(...args: unknown[]): boolean {
146
+ switch (args.length) {
147
+ case 1: {
148
+ const [pt] = args as [Point2D];
149
+
150
+
151
+ if (this.x <= pt.getX() && pt.getX() <= this.x + this.width &&
152
+ this.y <= pt.getY() && pt.getY() <= this.y + this.height) {
153
+
154
+ return true;
155
+ }
156
+
157
+ else {
158
+ return false;
159
+ }
160
+
161
+
162
+
163
+ break;
164
+ }
165
+
166
+ case 2: {
167
+ const [x1, y1] = args as [int, int];
168
+
169
+
170
+ if (this.x <= x1 && x1 <= this.x + this.width &&
171
+ this.y <= y1 && y1 <= this.y + this.height) {
172
+
173
+ return true;
174
+ }
175
+
176
+ else {
177
+ return false;
178
+ }
179
+
180
+
181
+
182
+ break;
183
+ }
184
+
185
+ case 4: {
186
+ const [x1, y1, width1, height1] = args as [int, int, int, int];
187
+
188
+
189
+ if (this.contains(x1, y1) && this.contains(x1 + width1, y1 + height1)) {
190
+
191
+ return true;
192
+ }
193
+
194
+ else {
195
+ return false;
196
+ }
197
+
198
+
199
+
200
+ break;
201
+ }
202
+
203
+ default: {
204
+ throw Error(`Invalid number of arguments`);
205
+ }
206
+ }
207
+ }
208
+
209
+ public getBounds2D(): Rectangle2D {
210
+ return new Rectangle2D(this.x, this.y, this.width, this.height);
211
+ }
212
+ public getX(): double {
213
+ return this.x;
214
+ }
215
+ public getY(): int {
216
+ return this.y;
217
+ }
218
+ public getMinX(): int {
219
+ return this.x;
220
+ }
221
+ public getMinY(): int {
222
+ return this.y;
223
+ }
224
+ public getMaxX(): int {
225
+ return this.x + this.width;
226
+ }
227
+ public getMaxY(): int {
228
+ return this.y + this.height;
229
+ }
230
+ public getHeight(): int {
231
+ return this.height;
232
+ }
233
+ public getWidth(): int {
234
+ return this.width;
235
+ }
236
+ getBottom():number{
237
+ return this.y + this.height;
238
+ };
239
+
240
+ getRight():number{
241
+ return this.x + this.width;
242
+ };
243
+
244
+ getCenterX():number{
245
+ return this.x + (this.width/2);
246
+ };
247
+ /**
248
+ *
249
+ * @returns {Number}
250
+ */
251
+ getCenterY(){
252
+ return this.y + (this.height/2);
253
+ };
254
+
255
+ public grow(h: int, v: int): void {
256
+ this.x = this.x - h;
257
+ this.y = this.y - v;
258
+ this.width = this.width + (2*h);
259
+ this.height = this.height + (2*v);
260
+ }
261
+ public setRect(rect: Rectangle): void {
262
+ this.x = rect.x;
263
+ this.y = rect.y;
264
+ this.width = rect.width;
265
+ this.height = rect.height;
266
+ }
267
+ /**
268
+ * setLocation x,y (top,left) while maintaining the width and height.
269
+ * @param x
270
+ * @param y
271
+ */
272
+ public setLocation(x:number,y:number):void{
273
+ this.x = x;
274
+ this.y = y;
275
+ };
276
+ public isEmpty():boolean
277
+ {
278
+ return (this.width <= 0.0) || (this.height <= 0.0);
279
+ };
280
+
281
+ public shift(x:number,y:number):void
282
+ {
283
+ this.x += x;
284
+ this.y += y;
285
+ //height & width shouldn't change in a full shift of the rectangle.
286
+ //this.height = this.bottom - this.y;
287
+ //this.width = this.right - this.x;
288
+ };
289
+ /**
290
+ * moves top,left points leaving bottom,right intact.
291
+ * adjusts the height & width values as necessary
292
+ * @param x
293
+ * @param y
294
+ */
295
+ public shiftTL(x:number,y:number):void{
296
+ let br:Point2D = new Point2D(this.x + this.width, this.y + this.height);
297
+
298
+ this.x += x;
299
+ this.y += y;
300
+
301
+ this.height = br.getY() - this.y;
302
+ this.width = br.getX() - this.x;
303
+ };
304
+ /**
305
+ * moves bottom,right points leaving top,left intact.
306
+ * adjusts the height & width values as necessary
307
+ * @param {type} x the amount to move the right point by
308
+ * @param {type} y the amount to move the bottom point by
309
+ * @returns {_L7.Anonym$0.Rectangle.shiftTL}
310
+ */
311
+ public shiftBR(x:number,y:number):void{
312
+ this.width += x;
313
+ this.height += y;
314
+ if(this.width < 0)
315
+ this.width = 0;
316
+ if(this.height < 0)
317
+ this.height = 0;
318
+ };
319
+
320
+ /**
321
+ * Will merge the bounds of two rectangle.
322
+ * @param rect
323
+ */
324
+ public union(rect:Rectangle)
325
+ {
326
+ let br1:Point2D = new Point2D(this.x + this.width, this.y + this.height);
327
+ let br2:Point2D = new Point2D(rect.x + rect.width, rect.y + rect.height);
328
+ if(rect)
329
+ {
330
+ if(rect.y < this.y)
331
+ this.y = rect.y;
332
+ if(rect.x < this.x)
333
+ this.x = rect.x;
334
+ if(br2.getY() > br1.getY())
335
+ this.height = br2.getY() - br1.getY();
336
+ if(br2.getX() > br1.getX())
337
+ this.width = br2.getX() - br1.getX();
338
+ }
339
+
340
+ }
341
+
342
+ public unionPoint(point:Point){
343
+ if(point)
344
+ {
345
+ let tl:Point = new Point(this.x,this.y);
346
+ let br:Point = new Point(this.x + this.width, this.y + this.height);
347
+
348
+ if(point.y < tl.y)
349
+ tl.y = point.y;
350
+ if(point.x < tl.x)
351
+ tl.x = point.x;
352
+ if(point.y > br.y)
353
+ br.y = point.y;
354
+ if(point.x > br.x)
355
+ br.x = point.x;
356
+ this.x = tl.x;
357
+ this.y = tl.y;
358
+ this.width = br.x - this.x;
359
+ this.height = br.y - this.y;
360
+ }
361
+
362
+ };
363
+
364
+ /**
365
+ *
366
+ * @param point
367
+ * @returns
368
+ */
369
+ public containsPoint(point:Point):boolean
370
+ {
371
+ if(point)
372
+ {
373
+ var x = point.getX();
374
+ var y = point.getY();
375
+ var x0 = this.getX(),
376
+ y0 = this.getY();
377
+ return (x >= x0 &&
378
+ y >= y0 &&
379
+ x < x0 + this.getWidth() &&
380
+ y < y0 + this.getHeight());
381
+ }
382
+ else
383
+ return false;
384
+ };
385
+
386
+ public containsRectangle(rect:Rectangle):boolean
387
+ {
388
+ if(rect)
389
+ {
390
+ var x = rect.getX();
391
+ var y = rect.getY();
392
+ var w = rect.getWidth();
393
+ var h = rect.getHeight();
394
+ if (this.isEmpty() || w <= 0 || h <= 0)
395
+ {
396
+ return false;
397
+ }
398
+ var x0 = this.getX(),
399
+ y0 = this.getY();
400
+ return (x >= x0 &&
401
+ y >= y0 &&
402
+ (x + w) <= x0 + this.getWidth() &&
403
+ (y + h) <= y0 + this.getHeight());
404
+ }
405
+ else
406
+ return false;
407
+ };
408
+
409
+ /**
410
+ * Ported from Java
411
+ */
412
+ private outcode(x:number, y:number)
413
+ {
414
+ var out = 0;
415
+ if (this.width <= 0) {
416
+ out |= Rectangle.OUT_LEFT | Rectangle.OUT_RIGHT;
417
+ } else if (x < this.x) {
418
+ out |= Rectangle.OUT_LEFT;
419
+ } else if (x > this.x + this.width) {
420
+ out |= Rectangle.OUT_RIGHT;
421
+ }
422
+ if (this.height <= 0) {
423
+ out |= Rectangle.OUT_TOP | Rectangle.OUT_BOTTOM;
424
+ } else if (y < this.y) {
425
+ out |= Rectangle.OUT_TOP;
426
+ } else if (y > this.y + this.height) {
427
+ out |= Rectangle.OUT_BOTTOM;
428
+ }
429
+ return out;
430
+ };
431
+
432
+ /**
433
+ * Tests if the specified line segment intersects the interior of this
434
+ * <code>Rectangle</code>. Ported from java.
435
+ *
436
+ * @param x1 the X coordinate of the start point of the specified
437
+ * line segment
438
+ * @param y1 the Y coordinate of the start point of the specified
439
+ * line segment
440
+ * @param x2 the X coordinate of the end point of the specified
441
+ * line segment
442
+ * @param y2 the Y coordinate of the end point of the specified
443
+ * line segment
444
+ * @return <code>true</code> if the specified line segment intersects
445
+ * the interior of this <code>Rectangle</code>; <code>false</code>
446
+ * otherwise.
447
+ */
448
+ public intersectsLine(x1: number, y1: number, x2: number, y2: number):boolean
449
+ {
450
+ let out1: number = 0;
451
+ let out2: number = 0;
452
+ if ((out2 = this.outcode(x2, y2)) === 0) {
453
+ return true;
454
+ }
455
+ while ((out1 = this.outcode(x1, y1)) !== 0) {
456
+ if ((out1 & out2) !== 0) {
457
+ return false;
458
+ }
459
+ if ((out1 & (Rectangle.OUT_LEFT | Rectangle.OUT_RIGHT)) !== 0) {
460
+ var x = this.getX();
461
+ if ((out1 & Rectangle.OUT_RIGHT) !== 0) {
462
+ x += this.getWidth();
463
+ }
464
+ y1 = y1 + (x - x1) * (y2 - y1) / (x2 - x1);
465
+ x1 = x;
466
+ } else {
467
+ var y = this.getY();
468
+ if ((out1 & Rectangle.OUT_BOTTOM) !== 0) {
469
+ y += this.getHeight();
470
+ }
471
+ x1 = x1 + (y - y1) * (x2 - x1) / (y2 - y1);
472
+ y1 = y;
473
+ }
474
+ }
475
+ return true;
476
+ };
477
+
478
+ // </editor-fold>
479
+
480
+ public setPath(context:OffscreenCanvasRenderingContext2D)
481
+ {
482
+ var x = this.getX(),
483
+ y = this.getY(),
484
+ w = this.getWidth(),
485
+ h = this.getHeight();
486
+
487
+ //context.beginPath();
488
+ context.moveTo(x, y);
489
+ context.lineTo(x + w,y);
490
+ context.lineTo(x + w,y + h);
491
+ context.lineTo(x,y + h);
492
+ context.closePath();
493
+
494
+ };
495
+ public stroke(context:OffscreenCanvasRenderingContext2D){
496
+ context.strokeRect(this.getX(),this.getY(),this.getWidth(),this.getHeight());
497
+ };
498
+ public fill(context:OffscreenCanvasRenderingContext2D){
499
+ context.fillRect(this.getX(),this.getY(),this.getWidth(),this.getHeight());
500
+ };
501
+ public clone():Rectangle{
502
+ return new Rectangle(this.x,this.y,this.width,this.height);
503
+ };
504
+
505
+ /**
506
+ * ported from java
507
+ */
508
+ /*intersects(r:Rectangle):boolean
509
+ {
510
+ if(r)
511
+ {
512
+ var tw = this.width;
513
+ var th = this.height;
514
+ var rw = r.width;
515
+ var rh = r.height;
516
+ if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
517
+ return false;
518
+ }
519
+ var tx = this.x;
520
+ var ty = this.y;
521
+ var rx = r.x;
522
+ var ry = r.y;
523
+ rw += rx;
524
+ rh += ry;
525
+ tw += tx;
526
+ th += ty;
527
+ // overflow || intersect
528
+ return ((rw < rx || rw > tx) &&
529
+ (rh < ry || rh > ty) &&
530
+ (tw < tx || tw > rx) &&
531
+ (th < ty || th > ry));
532
+ }
533
+ else
534
+ return false;
535
+
536
+ };//*/
537
+
538
+ /**
539
+ *
540
+ * @param stroke named color or value of rgb(#,#,#)
541
+ * @param strokeWidth width of line in # of pixels
542
+ * @param fill named color or value of rgb(#,#,#)
543
+ * @returns
544
+ */
545
+ public toSVGElement(stroke:string | null, strokeWidth:number, fill:string | null):string
546
+ {
547
+ var line = '<rect x="' + this.x + '" y="' + this.y;
548
+ line += '" width="' + this.width + '" height="' + this.height + '"';
549
+
550
+ if(strokeWidth)
551
+ line += ' stroke-width="' + strokeWidth + '"';
552
+ else if(stroke)
553
+ line += ' stroke-width="2"';
554
+
555
+ if(stroke)
556
+ line += ' stroke="' + stroke + '"';
557
+
558
+ if(fill)
559
+ line += ' fill="' + fill + '"';
560
+ else
561
+ line += ' fill="none"';
562
+
563
+ line += '/>';
564
+ return line;
565
+ }
566
+
567
+ }