@stemy/ngx-utils 19.8.2 → 19.8.3
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/fesm2022/stemy-ngx-utils.mjs +88 -30
- package/fesm2022/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/common-types.d.ts +2 -1
- package/ngx-utils/ngx-utils.imports.d.ts +1 -1
- package/ngx-utils/utils/geometry/index.d.ts +1 -1
- package/ngx-utils/utils/geometry/shapes.d.ts +11 -4
- package/package.json +1 -1
- package/public_api.d.ts +1 -1
|
@@ -1836,12 +1836,9 @@ class ExclusionsRenderer {
|
|
|
1836
1836
|
async [Invokable.call](renderCanvas) {
|
|
1837
1837
|
const ctx = renderCanvas.ctx;
|
|
1838
1838
|
renderCanvas.excludedAreas?.forEach(shape => {
|
|
1839
|
-
ctx.save();
|
|
1840
|
-
ctx.translate(shape.x, shape.y);
|
|
1841
1839
|
ctx.fillStyle = "rgba(128,128,128,0.55)";
|
|
1842
|
-
shape.
|
|
1843
|
-
ctx.fill();
|
|
1844
|
-
ctx.restore();
|
|
1840
|
+
const path = shape.getPath(shape.x, shape.y, 1);
|
|
1841
|
+
ctx.fill(path);
|
|
1845
1842
|
});
|
|
1846
1843
|
}
|
|
1847
1844
|
}
|
|
@@ -2100,6 +2097,16 @@ function gjkDistance(A, B) {
|
|
|
2100
2097
|
// Boolean GJK (robust)
|
|
2101
2098
|
// =========================
|
|
2102
2099
|
function gjkIntersection(A, B) {
|
|
2100
|
+
for (const AA of getShapes(A)) {
|
|
2101
|
+
for (const BB of getShapes(B)) {
|
|
2102
|
+
const int = gjkIntersectionSingle(AA, BB);
|
|
2103
|
+
if (int.hit)
|
|
2104
|
+
return int;
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
return { hit: false };
|
|
2108
|
+
}
|
|
2109
|
+
function gjkIntersectionSingle(A, B) {
|
|
2103
2110
|
const MAX = 64, EPS = 1e-12;
|
|
2104
2111
|
const sup = (dir) => {
|
|
2105
2112
|
const a = ensurePoint(A.support(dir), A.center);
|
|
@@ -2143,6 +2150,22 @@ function gjkIntersection(A, B) {
|
|
|
2143
2150
|
// Max iterations without resolution → disjoint
|
|
2144
2151
|
return { hit: false };
|
|
2145
2152
|
}
|
|
2153
|
+
function* getShapes(shape, worldX = 0, worldY = 0) {
|
|
2154
|
+
if (!shape)
|
|
2155
|
+
return;
|
|
2156
|
+
// Calculate this specific shape's actual world position
|
|
2157
|
+
const currentWorldX = worldX + shape.x;
|
|
2158
|
+
const currentWorldY = worldY + shape.y;
|
|
2159
|
+
if (!shape.subShapes || shape.subShapes.length === 0) {
|
|
2160
|
+
// Yield a temporary 'leaf' shape moved to the correct world coordinate
|
|
2161
|
+
yield shape.move({ x: currentWorldX, y: currentWorldY });
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
// Recurse into children, passing down the current world position
|
|
2165
|
+
for (const sub of shape.subShapes) {
|
|
2166
|
+
yield* getShapes(sub, currentWorldX, currentWorldY);
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2146
2169
|
function doSimplexBoolean(simplex, d) {
|
|
2147
2170
|
const last = simplex[simplex.length - 1];
|
|
2148
2171
|
const AO = { x: -last.p.x, y: -last.p.y };
|
|
@@ -2264,10 +2287,10 @@ class Point extends Shape {
|
|
|
2264
2287
|
const x = Number(xOrP);
|
|
2265
2288
|
this.pt = isPoint(xOrP) ? xOrP : { x: isNaN(x) ? 0 : xOrP, y };
|
|
2266
2289
|
}
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2290
|
+
getPath(x, y) {
|
|
2291
|
+
const path = new Path2D();
|
|
2292
|
+
path.ellipse(x, y, 1.5, 1.5, 0, 0, Math.PI * 2);
|
|
2293
|
+
return path;
|
|
2271
2294
|
}
|
|
2272
2295
|
support() {
|
|
2273
2296
|
return this.center;
|
|
@@ -2341,16 +2364,21 @@ class Rect extends Shape {
|
|
|
2341
2364
|
this.height = height;
|
|
2342
2365
|
this.rotation = rotation;
|
|
2343
2366
|
}
|
|
2344
|
-
|
|
2367
|
+
getPath(x, y, ratio) {
|
|
2345
2368
|
ratio = ratio ?? 1;
|
|
2346
2369
|
const w = this.width * ratio;
|
|
2347
2370
|
const h = this.height * ratio;
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2371
|
+
// 1. Create the local path for the rectangle (centered at 0,0)
|
|
2372
|
+
const rectPath = new Path2D();
|
|
2373
|
+
rectPath.rect(-w / 2, -h / 2, w, h);
|
|
2374
|
+
// 2. Create a DOMMatrix to handle the rotation
|
|
2375
|
+
const matrix = new DOMMatrix()
|
|
2376
|
+
.translate(x, y) // Move to position
|
|
2377
|
+
.rotate(this.rotation); // Apply rotation (in degrees)
|
|
2378
|
+
// 3. Create the final path and apply the matrix
|
|
2379
|
+
const finalPath = new Path2D();
|
|
2380
|
+
finalPath.addPath(rectPath, matrix);
|
|
2381
|
+
return finalPath;
|
|
2354
2382
|
}
|
|
2355
2383
|
support(dir) {
|
|
2356
2384
|
const ang = this.rotation ?? 0;
|
|
@@ -2373,16 +2401,24 @@ class Oval extends Shape {
|
|
|
2373
2401
|
this.height = height;
|
|
2374
2402
|
this.rotation = rotation;
|
|
2375
2403
|
}
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
const
|
|
2379
|
-
const
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2404
|
+
getPath(x, y, ratio = 1) {
|
|
2405
|
+
// 1. Calculate radii based on ratio
|
|
2406
|
+
const radiusX = (this.width * ratio) / 2;
|
|
2407
|
+
const radiusY = (this.height * ratio) / 2;
|
|
2408
|
+
// 2. Create the local ellipse at (0,0)
|
|
2409
|
+
const ovalPath = new Path2D();
|
|
2410
|
+
// Parameters: x, y, radiusX, radiusY, rotation, startAngle, endAngle
|
|
2411
|
+
ovalPath.ellipse(0, 0, radiusX, radiusY, 0, 0, Math.PI * 2);
|
|
2412
|
+
ovalPath.closePath();
|
|
2413
|
+
// 3. Create the transformation matrix
|
|
2414
|
+
// Note: We use the passed in x and y here
|
|
2415
|
+
const matrix = new DOMMatrix()
|
|
2416
|
+
.translate(x, y)
|
|
2417
|
+
.rotate(this.rotation);
|
|
2418
|
+
// 4. Combine them
|
|
2419
|
+
const path = new Path2D();
|
|
2420
|
+
path.addPath(ovalPath, matrix);
|
|
2421
|
+
return path;
|
|
2386
2422
|
}
|
|
2387
2423
|
support(dir) {
|
|
2388
2424
|
const ang = this.rotation ?? 0;
|
|
@@ -2407,6 +2443,28 @@ class Circle extends Oval {
|
|
|
2407
2443
|
return new Circle(pos.x, pos.y, this.radius, this.rotation);
|
|
2408
2444
|
}
|
|
2409
2445
|
}
|
|
2446
|
+
class ShapeGroup extends Shape {
|
|
2447
|
+
constructor(x, y, subShapes) {
|
|
2448
|
+
super(x, y);
|
|
2449
|
+
this.subShapes = subShapes;
|
|
2450
|
+
}
|
|
2451
|
+
getPath(x, y, ratio = 1) {
|
|
2452
|
+
const groupPath = new Path2D();
|
|
2453
|
+
for (const shape of this.subShapes) {
|
|
2454
|
+
// Calculate child's position relative to the Group's (x, y)
|
|
2455
|
+
const childPath = shape.getPath(x + shape.x, y + shape.y, ratio);
|
|
2456
|
+
// Add it to our master group path
|
|
2457
|
+
groupPath.addPath(childPath);
|
|
2458
|
+
}
|
|
2459
|
+
return groupPath;
|
|
2460
|
+
}
|
|
2461
|
+
support() {
|
|
2462
|
+
return this.center;
|
|
2463
|
+
}
|
|
2464
|
+
move(pos) {
|
|
2465
|
+
return new ShapeGroup(pos.x, pos.y, this.subShapes);
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2410
2468
|
|
|
2411
2469
|
class Initializer {
|
|
2412
2470
|
get isInitialized() {
|
|
@@ -8215,9 +8273,9 @@ class InteractiveItemComponent {
|
|
|
8215
8273
|
this.mDistances = new Map();
|
|
8216
8274
|
}
|
|
8217
8275
|
draw(ctx, shape) {
|
|
8218
|
-
shape.
|
|
8219
|
-
ctx.fill();
|
|
8220
|
-
ctx.stroke();
|
|
8276
|
+
const path = shape.getPath(0, 0, 1);
|
|
8277
|
+
ctx.fill(path);
|
|
8278
|
+
ctx.stroke(path);
|
|
8221
8279
|
}
|
|
8222
8280
|
ngOnChanges() {
|
|
8223
8281
|
if (!this.canvas)
|
|
@@ -9596,5 +9654,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
9596
9654
|
* Generated bundle index. Do not edit.
|
|
9597
9655
|
*/
|
|
9598
9656
|
|
|
9599
|
-
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AsyncMethodTargetDirective, AuthGuard, BASE_CONFIG, BUTTON_TYPE, BackgroundDirective, BaseDialogService, BaseHttpClient, BaseHttpService, BaseToasterService, BtnComponent, BtnDefaultComponent, CONFIG_SERVICE, CacheService, CanvasColor, CanvasUtils, ChipsComponent, ChunkPipe, Circle, CloseBtnComponent, ComponentLoaderDirective, ComponentLoaderService, ConfigService, DIALOG_SERVICE, DateUtils, DragDropEventPlugin, DropListComponent, DropdownBoxComponent, DropdownContentDirective, DropdownDirective, DropdownToggleDirective, DynamicTableComponent, DynamicTableTemplateDirective, EPSILON, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExclusionsRenderer, ExtraItemPropertiesPipe, FactoryDependencies, FakeModuleComponent, FileSystemEntry, FileUtils, FilterPipe, FindPipe, ForbiddenZone, FormatNumberPipe, FormatterService, GenericValue, GetOffsetPipe, GetTypePipe, GetValuePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, ICON_MAP, ICON_SERVICE, ICON_TYPE, IConfiguration, IconComponent, IconDefaultComponent, IconDirective, IconService, IncludesPipe, Initializer, InteractiveCanvasComponent, InteractiveCircleComponent, InteractiveItemComponent, InteractiveRectComponent, IsTypePipe, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, OPTIONS_TOKEN, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, Oval, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, RequestBag, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, RulerCanvasRenderer, SCHEMA_SELECTOR, SCRIPT_PARAMS, STATIC_SCHEMAS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SocketClient, SocketService, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, SyncAsyncPipe, TOASTER_SERVICE, TabsComponent, TabsItemDirective, TabsTemplateDirective, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UploadComponent, ValuedPromise, ValuesPipe, WysiwygComponent, addPts, cachedFactory, cancelablePromise, checkTransitions, clamp, computedPrevious, createTypedProvider, cssStyles, cssVariables, distance, distanceSq, dividePts, dotProduct, ensurePoint, getComponentDef, getCssVariables, getRoot, gjkDistance, gjkIntersection, impatientPromise, injectOptions, isBrowser, isPoint, lengthOfPt, lerpPts, md5, multiplyPts, negatePt, normalizePt, normalizeRange, overflow, parseSelector, perpendicular, provideEntryComponents, provideOptions, provideWithOptions, rotateDeg, rotateRad, selectorMatchesList, stringify, subPts, svgToDataUri, switchClass, toDegrees, toRadians, tripleProduct };
|
|
9657
|
+
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AsyncMethodTargetDirective, AuthGuard, BASE_CONFIG, BUTTON_TYPE, BackgroundDirective, BaseDialogService, BaseHttpClient, BaseHttpService, BaseToasterService, BtnComponent, BtnDefaultComponent, CONFIG_SERVICE, CacheService, CanvasColor, CanvasUtils, ChipsComponent, ChunkPipe, Circle, CloseBtnComponent, ComponentLoaderDirective, ComponentLoaderService, ConfigService, DIALOG_SERVICE, DateUtils, DragDropEventPlugin, DropListComponent, DropdownBoxComponent, DropdownContentDirective, DropdownDirective, DropdownToggleDirective, DynamicTableComponent, DynamicTableTemplateDirective, EPSILON, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExclusionsRenderer, ExtraItemPropertiesPipe, FactoryDependencies, FakeModuleComponent, FileSystemEntry, FileUtils, FilterPipe, FindPipe, ForbiddenZone, FormatNumberPipe, FormatterService, GenericValue, GetOffsetPipe, GetTypePipe, GetValuePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, ICON_MAP, ICON_SERVICE, ICON_TYPE, IConfiguration, IconComponent, IconDefaultComponent, IconDirective, IconService, IncludesPipe, Initializer, InteractiveCanvasComponent, InteractiveCircleComponent, InteractiveItemComponent, InteractiveRectComponent, IsTypePipe, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, OPTIONS_TOKEN, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, Oval, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, RequestBag, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, RulerCanvasRenderer, SCHEMA_SELECTOR, SCRIPT_PARAMS, STATIC_SCHEMAS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShapeGroup, ShiftPipe, SocketClient, SocketService, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, SyncAsyncPipe, TOASTER_SERVICE, TabsComponent, TabsItemDirective, TabsTemplateDirective, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UploadComponent, ValuedPromise, ValuesPipe, WysiwygComponent, addPts, cachedFactory, cancelablePromise, checkTransitions, clamp, computedPrevious, createTypedProvider, cssStyles, cssVariables, distance, distanceSq, dividePts, dotProduct, ensurePoint, getComponentDef, getCssVariables, getRoot, gjkDistance, gjkIntersection, impatientPromise, injectOptions, isBrowser, isPoint, lengthOfPt, lerpPts, md5, multiplyPts, negatePt, normalizePt, normalizeRange, overflow, parseSelector, perpendicular, provideEntryComponents, provideOptions, provideWithOptions, rotateDeg, rotateRad, selectorMatchesList, stringify, subPts, svgToDataUri, switchClass, toDegrees, toRadians, tripleProduct };
|
|
9600
9658
|
//# sourceMappingURL=stemy-ngx-utils.mjs.map
|