UNPKG

@ng-web-apis/canvas

Version:
1,041 lines (1,005 loc) 48.2 kB
import * as i0 from '@angular/core'; import { InjectionToken, inject, NgZone, Injectable, ElementRef, Directive, Input, QueryList, Component, ChangeDetectionStrategy, ContentChildren, Pipe } from '@angular/core'; import { WA_ANIMATION_FRAME } from '@ng-web-apis/common'; const WA_CANVAS_2D_CONTEXT = new InjectionToken('[WA_CANVAS_2D_CONTEXT]'); /** * @deprecated: drop in v5.0, use {@link WA_CANVAS_2D_CONTEXT} */ const CANVAS_2D_CONTEXT = WA_CANVAS_2D_CONTEXT; const WA_CANVAS_PROPERTIES = new InjectionToken('[WA_CANVAS_PROPERTIES]', { factory: () => [], }); function asCanvasProperty(useExisting) { return { provide: WA_CANVAS_PROPERTIES, multi: true, useExisting, }; } /** * @deprecated: drop in v5.0, use {@link WA_CANVAS_PROPERTIES} */ const CANVAS_PROPERTIES = WA_CANVAS_PROPERTIES; class WaDrawService { subscription; constructor() { const parent = inject(CANVAS_PROPERTIES, { skipSelf: true }); const properties = inject(CANVAS_PROPERTIES); const context = inject(CANVAS_2D_CONTEXT); const animationFrame$ = inject(WA_ANIMATION_FRAME); const ngZone = inject(NgZone); this.subscription = ngZone.runOutsideAngular(() => animationFrame$.subscribe(() => { context.save(); parent.forEach((property) => property.call(context)); properties.forEach((property) => property.call(context)); this.call(context); context.restore(); })); } call = () => { }; ngOnDestroy() { this.subscription.unsubscribe(); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaDrawService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaDrawService }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaDrawService, decorators: [{ type: Injectable }], ctorParameters: function () { return []; } }); /** * @deprecated: use {@link WaDrawService} */ const DrawService = WaDrawService; class WaCanvas2d { context = inject(CANVAS_2D_CONTEXT); method = inject(WaDrawService); waOpaque = ''; waDesynchronized = ''; constructor() { this.context.strokeStyle = 'transparent'; this.method.call = (context) => { context.clearRect(0, 0, context.canvas.width, context.canvas.height); }; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvas2d, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvas2d, isStandalone: true, selector: "canvas[waCanvas2d]", inputs: { waOpaque: "waOpaque", waDesynchronized: "waDesynchronized" }, providers: [ { provide: CANVAS_2D_CONTEXT, useFactory: () => { const { nativeElement } = inject(ElementRef); const opaque = nativeElement.getAttribute('waOpaque'); const desynchronized = nativeElement.getAttribute('waDesynchronized'); const context = nativeElement.getContext('2d', { alpha: opaque === null, desynchronized: desynchronized !== null, }); if (!context) { throw new Error('Context of different type was already requested'); } return context; }, }, WaDrawService, ], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvas2d, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas[waCanvas2d]', providers: [ { provide: CANVAS_2D_CONTEXT, useFactory: () => { const { nativeElement } = inject(ElementRef); const opaque = nativeElement.getAttribute('waOpaque'); const desynchronized = nativeElement.getAttribute('waDesynchronized'); const context = nativeElement.getContext('2d', { alpha: opaque === null, desynchronized: desynchronized !== null, }); if (!context) { throw new Error('Context of different type was already requested'); } return context; }, }, WaDrawService, ], }] }], ctorParameters: function () { return []; }, propDecorators: { waOpaque: [{ type: Input }], waDesynchronized: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvas2d} */ const Canvas2dDirective = WaCanvas2d; const WA_CANVAS_METHOD = new InjectionToken('[WA_CANVAS_METHOD]'); function asCanvasMethod(useExisting) { return { provide: WA_CANVAS_METHOD, useExisting, }; } /** * @deprecated: drop in v5.0, use {@link WA_CANVAS_METHOD} */ const CANVAS_METHOD = WA_CANVAS_METHOD; class WaCanvasClipPath { pathSteps = new QueryList(); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasClipPath, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasClipPath, isStandalone: true, selector: "canvas-clip-path", queries: [{ propertyName: "pathSteps", predicate: CANVAS_METHOD }], ngImport: i0, template: ` <ng-content></ng-content> `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasClipPath, decorators: [{ type: Component, args: [{ standalone: true, selector: 'canvas-clip-path', template: ` <ng-content></ng-content> `, changeDetection: ChangeDetectionStrategy.OnPush, }] }], propDecorators: { pathSteps: [{ type: ContentChildren, args: [CANVAS_METHOD] }] } }); /** * @deprecated: use {@link WaCanvasClipPath} */ const ClipPathComponent = WaCanvasClipPath; class WaCanvasDrawImage { method = inject(WaDrawService); image; dX = 0; dY = 0; dWidth; dHeight; sX; sY; sWidth; sHeight; constructor() { this.method.call = (context) => { if (!this.image) { return; } if (this.sWidth !== undefined && this.sHeight !== undefined && this.sX !== undefined && this.sY !== undefined && this.dWidth !== undefined && this.dHeight !== undefined) { context.drawImage(this.image, this.sX, this.sY, this.sWidth, this.sHeight, this.dX, this.dY, this.dWidth, this.dHeight); } else if (this.dWidth !== undefined && this.dHeight !== undefined) { context.drawImage(this.image, this.dX, this.dY, this.dWidth, this.dHeight); } else { context.drawImage(this.image, this.dX, this.dY); } }; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasDrawImage, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasDrawImage, isStandalone: true, selector: "canvas-draw-image", inputs: { image: "image", dX: "dX", dY: "dY", dWidth: "dWidth", dHeight: "dHeight", sX: "sX", sY: "sY", sWidth: "sWidth", sHeight: "sHeight" }, providers: [WaDrawService], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasDrawImage, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-draw-image', providers: [WaDrawService], }] }], ctorParameters: function () { return []; }, propDecorators: { image: [{ type: Input }], dX: [{ type: Input }], dY: [{ type: Input }], dWidth: [{ type: Input }], dHeight: [{ type: Input }], sX: [{ type: Input }], sY: [{ type: Input }], sWidth: [{ type: Input }], sHeight: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasDrawImage} */ const DrawImageDirective = WaCanvasDrawImage; class WaCanvasPath { pathSteps = new QueryList(); method = inject(WaDrawService); closed = false; fillRule; constructor() { this.method.call = (context) => { context.beginPath(); this.pathSteps.forEach((step) => { step.call(context); }); if (this.closed) { context.closePath(); } context.stroke(); context.fill(this.fillRule); }; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPath, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasPath, isStandalone: true, selector: "canvas-path:not([path])", inputs: { closed: "closed", fillRule: "fillRule" }, providers: [WaDrawService], queries: [{ propertyName: "pathSteps", predicate: CANVAS_METHOD }], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPath, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-path:not([path])', providers: [WaDrawService], }] }], ctorParameters: function () { return []; }, propDecorators: { pathSteps: [{ type: ContentChildren, args: [CANVAS_METHOD] }], closed: [{ type: Input }], fillRule: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasPath} */ const PathDirective = WaCanvasPath; class WaCanvasPath2d { method = inject(WaDrawService); path = new Path2D(); fillRule; constructor() { this.method.call = (context) => { context.fill(this.path, this.fillRule); context.stroke(this.path); }; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPath2d, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasPath2d, isStandalone: true, selector: "canvas-path[path]", inputs: { path: "path", fillRule: "fillRule" }, providers: [WaDrawService], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPath2d, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-path[path]', providers: [WaDrawService], }] }], ctorParameters: function () { return []; }, propDecorators: { path: [{ type: Input }], fillRule: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasPath2d} */ const Path2dDirective = WaCanvasPath2d; class WaCanvasText { method = inject(WaDrawService); text = ''; x = 0; y = 0; maxWidth; constructor() { this.method.call = (context) => { context.fillText(this.text, this.x, this.y, this.maxWidth); context.strokeText(this.text, this.x, this.y, this.maxWidth); }; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasText, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasText, isStandalone: true, selector: "canvas-text", inputs: { text: "text", x: "x", y: "y", maxWidth: "maxWidth" }, providers: [WaDrawService], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasText, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-text', providers: [WaDrawService], }] }], ctorParameters: function () { return []; }, propDecorators: { text: [{ type: Input }], x: [{ type: Input }], y: [{ type: Input }], maxWidth: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasText} */ const TextDirective = WaCanvasText; class WaCanvasArc { x = 0; y = 0; radius = 0; startAngle = 0; endAngle = 0; anticlockwise = false; call(context) { context.arc(this.x, this.y, this.radius, this.startAngle, this.endAngle, this.anticlockwise); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasArc, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasArc, isStandalone: true, selector: "canvas-arc", inputs: { x: "x", y: "y", radius: "radius", startAngle: "startAngle", endAngle: "endAngle", anticlockwise: "anticlockwise" }, providers: [asCanvasMethod(WaCanvasArc)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasArc, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-arc', providers: [asCanvasMethod(WaCanvasArc)], }] }], propDecorators: { x: [{ type: Input }], y: [{ type: Input }], radius: [{ type: Input }], startAngle: [{ type: Input }], endAngle: [{ type: Input }], anticlockwise: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasArc} */ const ArcDirective = WaCanvasArc; class WaCanvasArcTo { x1 = 0; y1 = 0; x2 = 0; y2 = 0; radius = 0; call(context) { context.arcTo(this.x1, this.y1, this.x2, this.y2, this.radius); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasArcTo, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasArcTo, isStandalone: true, selector: "canvas-arc-to", inputs: { x1: "x1", y1: "y1", x2: "x2", y2: "y2", radius: "radius" }, providers: [asCanvasMethod(WaCanvasArcTo)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasArcTo, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-arc-to', providers: [asCanvasMethod(WaCanvasArcTo)], }] }], propDecorators: { x1: [{ type: Input }], y1: [{ type: Input }], x2: [{ type: Input }], y2: [{ type: Input }], radius: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasArcTo} */ const ArcToDirective = WaCanvasArcTo; class WaCanvasBezierCurveTo { cp1x = 0; cp1y = 0; cp2x = 0; cp2y = 0; x = 0; y = 0; call(context) { context.bezierCurveTo(this.cp1x, this.cp1y, this.cp2x, this.cp2y, this.x, this.y); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasBezierCurveTo, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasBezierCurveTo, isStandalone: true, selector: "canvas-bezier-curve-to", inputs: { cp1x: "cp1x", cp1y: "cp1y", cp2x: "cp2x", cp2y: "cp2y", x: "x", y: "y" }, providers: [asCanvasMethod(WaCanvasBezierCurveTo)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasBezierCurveTo, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-bezier-curve-to', providers: [asCanvasMethod(WaCanvasBezierCurveTo)], }] }], propDecorators: { cp1x: [{ type: Input }], cp1y: [{ type: Input }], cp2x: [{ type: Input }], cp2y: [{ type: Input }], x: [{ type: Input }], y: [{ type: Input }] } }); /** * @deprecated use {@link WaCanvasBezierCurveTo} */ const BezierCurveToDirective = WaCanvasBezierCurveTo; class WaCanvasEllipse { x = 0; y = 0; radiusX = 0; radiusY = 0; rotation = 0; startAngle = 0; endAngle = 0; anticlockwise = false; call(context) { context.ellipse(this.x, this.y, this.radiusX, this.radiusY, this.rotation, this.startAngle, this.endAngle, this.anticlockwise); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasEllipse, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasEllipse, isStandalone: true, selector: "canvas-ellipse", inputs: { x: "x", y: "y", radiusX: "radiusX", radiusY: "radiusY", rotation: "rotation", startAngle: "startAngle", endAngle: "endAngle", anticlockwise: "anticlockwise" }, providers: [asCanvasMethod(WaCanvasEllipse)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasEllipse, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-ellipse', providers: [asCanvasMethod(WaCanvasEllipse)], }] }], propDecorators: { x: [{ type: Input }], y: [{ type: Input }], radiusX: [{ type: Input }], radiusY: [{ type: Input }], rotation: [{ type: Input }], startAngle: [{ type: Input }], endAngle: [{ type: Input }], anticlockwise: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasEllipse} */ const EllipseDirective = WaCanvasEllipse; class WaCanvasLineTo { x = 0; y = 0; call(context) { context.lineTo(this.x, this.y); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasLineTo, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasLineTo, isStandalone: true, selector: "canvas-line-to", inputs: { x: "x", y: "y" }, providers: [asCanvasMethod(WaCanvasLineTo)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasLineTo, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-line-to', providers: [asCanvasMethod(WaCanvasLineTo)], }] }], propDecorators: { x: [{ type: Input }], y: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasLineTo} */ const LineToDirective = WaCanvasLineTo; class WaCanvasMoveTo { x = 0; y = 0; call(context) { context.moveTo(this.x, this.y); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasMoveTo, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasMoveTo, isStandalone: true, selector: "canvas-move-to", inputs: { x: "x", y: "y" }, providers: [asCanvasMethod(WaCanvasMoveTo)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasMoveTo, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-move-to', providers: [asCanvasMethod(WaCanvasMoveTo)], }] }], propDecorators: { x: [{ type: Input }], y: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasMoveTo} */ const MoveToDirective = WaCanvasMoveTo; class WaCanvasQuadraticCurveTo { cpx = 0; cpy = 0; x = 0; y = 0; call(context) { context.quadraticCurveTo(this.cpx, this.cpy, this.x, this.y); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasQuadraticCurveTo, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasQuadraticCurveTo, isStandalone: true, selector: "canvas-quadratic-curve-to", inputs: { cpx: "cpx", cpy: "cpy", x: "x", y: "y" }, providers: [asCanvasMethod(WaCanvasQuadraticCurveTo)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasQuadraticCurveTo, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-quadratic-curve-to', providers: [asCanvasMethod(WaCanvasQuadraticCurveTo)], }] }], propDecorators: { cpx: [{ type: Input }], cpy: [{ type: Input }], x: [{ type: Input }], y: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasQuadraticCurveTo} */ const QuadraticCurveToDirective = WaCanvasQuadraticCurveTo; class WaCanvasRect { x = 0; y = 0; width = 0; height = 0; call(context) { context.rect(this.x, this.y, this.width, this.height); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasRect, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasRect, isStandalone: true, selector: "canvas-rect", inputs: { x: "x", y: "y", width: "width", height: "height" }, providers: [asCanvasMethod(WaCanvasRect)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasRect, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-rect', providers: [asCanvasMethod(WaCanvasRect)], }] }], propDecorators: { x: [{ type: Input }], y: [{ type: Input }], width: [{ type: Input }], height: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasRect} */ const RectDirective = WaCanvasRect; class WaCanvasGradientPipe { context = inject(CANVAS_2D_CONTEXT); // eslint-disable-next-line @typescript-eslint/max-params transform(stops, a1, a2, a3, a4, a5, a6) { const gradient = a5 !== undefined && a6 !== undefined ? this.context.createRadialGradient(a1, a2, a3, a4, a5, a6) : this.context.createLinearGradient(a1, a2, a3, a4); Array.from(stops.keys()).forEach((stop) => gradient.addColorStop(stop, stops.get(stop) ?? '')); return gradient; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasGradientPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasGradientPipe, isStandalone: true, name: "gradient" }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasGradientPipe, decorators: [{ type: Pipe, args: [{ standalone: true, name: 'gradient', }] }] }); /** * @deprecated: use {@link WaCanvasGradientPipe} */ const GradientPipe = WaCanvasGradientPipe; class WaCanvasPathPipe { transform(path) { return new Path2D(path); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPathPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPathPipe, isStandalone: true, name: "path" }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPathPipe, decorators: [{ type: Pipe, args: [{ standalone: true, name: 'path', }] }] }); /** * @deprecated: use {@link WaCanvasPathPipe} */ const PathPipe = WaCanvasPathPipe; class WaCanvasPatternPipe { context = inject(CANVAS_2D_CONTEXT); transform(image, repetition = 'repeat') { return this.context.createPattern(image, repetition); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPatternPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPatternPipe, isStandalone: true, name: "pattern" }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPatternPipe, decorators: [{ type: Pipe, args: [{ standalone: true, name: 'pattern', }] }] }); /** * @deprecated: use {@link WaCanvasPatternPipe} */ const PatternPipe = WaCanvasPatternPipe; class WaCanvasRadPipe { transform(input) { return (input * Math.PI) / 180; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasRadPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasRadPipe, isStandalone: true, name: "rad" }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasRadPipe, decorators: [{ type: Pipe, args: [{ standalone: true, name: 'rad', }] }] }); /** * @deprecated: use {@link WaCanvasRadPipe} */ const RadPipe = WaCanvasRadPipe; class WaCanvasTransformPipe { transform(value) { return new DOMMatrix(value); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasTransformPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasTransformPipe, isStandalone: true, name: "transform" }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasTransformPipe, decorators: [{ type: Pipe, args: [{ standalone: true, name: 'transform', }] }] }); /** * @deprecated: use {@link WaCanvasTransformPipe} */ const TransformPipe = WaCanvasTransformPipe; class WaCanvasClip { clip = new Path2D(); clipFillRule; call(context) { if (this.clip instanceof WaCanvasClipPath) { context.beginPath(); this.clip.pathSteps.forEach((step) => { step.call(context); }); context.clip(this.clipFillRule); } else { context.clip(this.clip, this.clipFillRule); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasClip, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasClip, isStandalone: true, selector: "canvas-draw-image[clip],canvas-draw-image[clipFillRule],canvas-path[clip],canvas-path[clipFillRule],canvas-text[clip],canvas-text[clipFillRule]", inputs: { clip: "clip", clipFillRule: "clipFillRule" }, providers: [asCanvasProperty(WaCanvasClip)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasClip, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-draw-image[clip],canvas-draw-image[clipFillRule],' + 'canvas-path[clip],canvas-path[clipFillRule],' + 'canvas-text[clip],canvas-text[clipFillRule]', providers: [asCanvasProperty(WaCanvasClip)], }] }], propDecorators: { clip: [{ type: Input }], clipFillRule: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasClip} */ const ClipDirective = WaCanvasClip; class WaCanvasCompositing { globalAlpha = 1; globalCompositeOperation = 'source-over'; call(context) { context.globalAlpha = this.globalAlpha; context.globalCompositeOperation = this.globalCompositeOperation; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasCompositing, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasCompositing, isStandalone: true, selector: "canvas-draw-image[globalAlpha],canvas-draw-image[globalCompositeOperation],canvas-path[globalAlpha],canvas-path[globalCompositeOperation],canvas-text[globalAlpha],canvas-text[globalCompositeOperation]", inputs: { globalAlpha: "globalAlpha", globalCompositeOperation: "globalCompositeOperation" }, providers: [asCanvasProperty(WaCanvasCompositing)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasCompositing, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-draw-image[globalAlpha],canvas-draw-image[globalCompositeOperation],' + 'canvas-path[globalAlpha],canvas-path[globalCompositeOperation],' + 'canvas-text[globalAlpha],canvas-text[globalCompositeOperation]', providers: [asCanvasProperty(WaCanvasCompositing)], }] }], propDecorators: { globalAlpha: [{ type: Input }], globalCompositeOperation: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasCompositing} */ const CompositingDirective = WaCanvasCompositing; class WaCanvasFillStrokeStyles { fillStyle = 'black'; strokeStyle = 'transparent'; call(context) { context.fillStyle = this.fillStyle; context.strokeStyle = this.strokeStyle; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasFillStrokeStyles, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasFillStrokeStyles, isStandalone: true, selector: "canvas-path[fillStyle],canvas-path[strokeStyle],canvas-text[fillStyle],canvas-text[strokeStyle]", inputs: { fillStyle: "fillStyle", strokeStyle: "strokeStyle" }, providers: [asCanvasProperty(WaCanvasFillStrokeStyles)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasFillStrokeStyles, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-path[fillStyle],canvas-path[strokeStyle],' + 'canvas-text[fillStyle],canvas-text[strokeStyle]', providers: [asCanvasProperty(WaCanvasFillStrokeStyles)], }] }], propDecorators: { fillStyle: [{ type: Input }], strokeStyle: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasFillStrokeStyles} */ const FillStrokeStylesDirective = WaCanvasFillStrokeStyles; class WaCanvasFilter { filter = 'none'; call(context) { context.filter = this.filter; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasFilter, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasFilter, isStandalone: true, selector: "canvas-draw-image[filter],canvas-path[filter],canvas-text[filter]", inputs: { filter: "filter" }, providers: [asCanvasProperty(WaCanvasFilter)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasFilter, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-draw-image[filter],canvas-path[filter],canvas-text[filter]', providers: [asCanvasProperty(WaCanvasFilter)], }] }], propDecorators: { filter: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasFilter} */ const FilterDirective = WaCanvasFilter; class WaCanvasImageSmoothing { imageSmoothingEnabled = true; imageSmoothingQuality = 'low'; call(context) { context.imageSmoothingEnabled = this.imageSmoothingEnabled; context.imageSmoothingQuality = this.imageSmoothingQuality; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasImageSmoothing, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasImageSmoothing, isStandalone: true, selector: "canvas-draw-image[imageSmoothingEnabled],canvas-draw-image[imageSmoothingQuality],canvas-path[imageSmoothingEnabled],canvas-path[imageSmoothingQuality],canvas-text[imageSmoothingEnabled],canvas-text[imageSmoothingQuality]", inputs: { imageSmoothingEnabled: "imageSmoothingEnabled", imageSmoothingQuality: "imageSmoothingQuality" }, providers: [asCanvasProperty(WaCanvasImageSmoothing)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasImageSmoothing, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-draw-image[imageSmoothingEnabled],canvas-draw-image[imageSmoothingQuality],' + 'canvas-path[imageSmoothingEnabled],canvas-path[imageSmoothingQuality],' + 'canvas-text[imageSmoothingEnabled],canvas-text[imageSmoothingQuality]', providers: [asCanvasProperty(WaCanvasImageSmoothing)], }] }], propDecorators: { imageSmoothingEnabled: [{ type: Input }], imageSmoothingQuality: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasImageSmoothing} */ const ImageSmoothingDirective = WaCanvasImageSmoothing; class WaCanvasPathDrawingStyles { lineCap = 'butt'; lineDashOffset = 0; lineJoin = 'miter'; lineWidth = 1; lineDash = []; miterLimit = 10; call(context) { context.lineCap = this.lineCap; context.lineDashOffset = this.lineDashOffset; context.lineJoin = this.lineJoin; context.lineWidth = this.lineWidth; context.miterLimit = this.miterLimit; context.setLineDash(this.lineDash); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPathDrawingStyles, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasPathDrawingStyles, isStandalone: true, selector: "canvas-path[lineCap],canvas-path[lineDashOffset],canvas-path[lineJoin],canvas-path[lineWidth],canvas-path[lineDash],canvas-path[miterLimit],canvas-text[lineCap],canvas-text[lineDashOffset],canvas-text[lineJoin],canvas-text[lineWidth],canvas-text[lineDash],canvas-text[miterLimit]", inputs: { lineCap: "lineCap", lineDashOffset: "lineDashOffset", lineJoin: "lineJoin", lineWidth: "lineWidth", lineDash: "lineDash", miterLimit: "miterLimit" }, providers: [asCanvasProperty(WaCanvasPathDrawingStyles)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasPathDrawingStyles, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-path[lineCap],canvas-path[lineDashOffset],canvas-path[lineJoin],canvas-path[lineWidth],canvas-path[lineDash],canvas-path[miterLimit],' + 'canvas-text[lineCap],canvas-text[lineDashOffset],canvas-text[lineJoin],canvas-text[lineWidth],canvas-text[lineDash],canvas-text[miterLimit]', providers: [asCanvasProperty(WaCanvasPathDrawingStyles)], }] }], propDecorators: { lineCap: [{ type: Input }], lineDashOffset: [{ type: Input }], lineJoin: [{ type: Input }], lineWidth: [{ type: Input }], lineDash: [{ type: Input }], miterLimit: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasPathDrawingStyles} */ const PathDrawingStylesDirective = WaCanvasPathDrawingStyles; class WaCanvasShadowStyles { shadowBlur = 0; shadowColor = 'transparent'; shadowOffsetX = 0; shadowOffsetY = 0; call(context) { context.shadowBlur = this.shadowBlur; context.shadowColor = this.shadowColor; context.shadowOffsetX = this.shadowOffsetX; context.shadowOffsetY = this.shadowOffsetY; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasShadowStyles, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasShadowStyles, isStandalone: true, selector: "canvas-draw-image[shadowBlur],canvas-draw-image[shadowColor],canvas-draw-image[shadowOffsetX],canvas-draw-image[shadowOffsetY],canvas-path[shadowBlur],canvas-path[shadowColor],canvas-path[shadowOffsetX],canvas-path[shadowOffsetY],canvas-text[shadowBlur],canvas-text[shadowColor],canvas-text[shadowOffsetX],canvas-text[shadowOffsetY]", inputs: { shadowBlur: "shadowBlur", shadowColor: "shadowColor", shadowOffsetX: "shadowOffsetX", shadowOffsetY: "shadowOffsetY" }, providers: [asCanvasProperty(WaCanvasShadowStyles)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasShadowStyles, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-draw-image[shadowBlur],canvas-draw-image[shadowColor],canvas-draw-image[shadowOffsetX],canvas-draw-image[shadowOffsetY],' + 'canvas-path[shadowBlur],canvas-path[shadowColor],canvas-path[shadowOffsetX],canvas-path[shadowOffsetY],' + 'canvas-text[shadowBlur],canvas-text[shadowColor],canvas-text[shadowOffsetX],canvas-text[shadowOffsetY]', providers: [asCanvasProperty(WaCanvasShadowStyles)], }] }], propDecorators: { shadowBlur: [{ type: Input }], shadowColor: [{ type: Input }], shadowOffsetX: [{ type: Input }], shadowOffsetY: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasShadowStyles} */ const ShadowStylesDirective = WaCanvasShadowStyles; class WaCanvasTextDrawingStyles { direction = 'inherit'; font = '10px sans-serif'; textAlign = 'start'; fontKerning = 'auto'; textBaseline = 'alphabetic'; call(context) { context.direction = this.direction; context.font = this.font; context.textAlign = this.textAlign; context.textBaseline = this.textBaseline; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasTextDrawingStyles, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasTextDrawingStyles, isStandalone: true, selector: "canvas-text[direction],canvas-text[font],canvas-text[textAlign],canvas-text[textBaseline]", inputs: { direction: "direction", font: "font", textAlign: "textAlign", fontKerning: "fontKerning", textBaseline: "textBaseline" }, providers: [asCanvasProperty(WaCanvasTextDrawingStyles)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasTextDrawingStyles, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas-text[direction],canvas-text[font],canvas-text[textAlign],canvas-text[textBaseline]', providers: [asCanvasProperty(WaCanvasTextDrawingStyles)], }] }], propDecorators: { direction: [{ type: Input }], font: [{ type: Input }], textAlign: [{ type: Input }], fontKerning: [{ type: Input }], textBaseline: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasTextDrawingStyles} */ const TextDrawingStylesDirective = WaCanvasTextDrawingStyles; class WaCanvasTransform { parent = inject(WaCanvasTransform, { skipSelf: true, optional: true, }); transform = new DOMMatrix(); call(context) { context.setTransform(this.parent?.transform.multiply(this.transform) || this.transform); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasTransform, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: WaCanvasTransform, isStandalone: true, selector: "canvas[transform],canvas-draw-image[transform],canvas-path[transform],canvas-text[transform]", inputs: { transform: "transform" }, providers: [asCanvasProperty(WaCanvasTransform)], ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: WaCanvasTransform, decorators: [{ type: Directive, args: [{ standalone: true, selector: 'canvas[transform],canvas-draw-image[transform],canvas-path[transform],canvas-text[transform]', providers: [asCanvasProperty(WaCanvasTransform)], }] }], propDecorators: { transform: [{ type: Input }] } }); /** * @deprecated: use {@link WaCanvasTransform} */ const TransformDirective = WaCanvasTransform; const WaCanvas = [ WaCanvas2d, WaCanvasClipPath, WaCanvasDrawImage, WaCanvasPath, WaCanvasPath2d, WaCanvasText, WaCanvasArc, WaCanvasArcTo, WaCanvasBezierCurveTo, WaCanvasEllipse, WaCanvasLineTo, WaCanvasMoveTo, WaCanvasQuadraticCurveTo, WaCanvasRect, WaCanvasClip, WaCanvasCompositing, WaCanvasFillStrokeStyles, WaCanvasFilter, WaCanvasImageSmoothing, WaCanvasPathDrawingStyles, WaCanvasShadowStyles, WaCanvasTextDrawingStyles, WaCanvasGradientPipe, WaCanvasPathPipe, WaCanvasPatternPipe, WaCanvasRadPipe, WaCanvasTransform, WaCanvasTransformPipe, ]; /** * @deprecated: use {@link WaCanvas} */ const CanvasModule = WaCanvas; /** * Generated bundle index. Do not edit. */ export { ArcDirective, ArcToDirective, BezierCurveToDirective, CANVAS_2D_CONTEXT, CANVAS_METHOD, CANVAS_PROPERTIES, Canvas2dDirective, CanvasModule, ClipDirective, ClipPathComponent, CompositingDirective, DrawImageDirective, DrawService, EllipseDirective, FillStrokeStylesDirective, FilterDirective, GradientPipe, ImageSmoothingDirective, LineToDirective, MoveToDirective, Path2dDirective, PathDirective, PathDrawingStylesDirective, PathPipe, PatternPipe, QuadraticCurveToDirective, RadPipe, RectDirective, ShadowStylesDirective, TextDirective, TextDrawingStylesDirective, TransformDirective, TransformPipe, WA_CANVAS_2D_CONTEXT, WA_CANVAS_METHOD, WA_CANVAS_PROPERTIES, WaCanvas, WaCanvas2d, WaCanvasArc, WaCanvasArcTo, WaCanvasBezierCurveTo, WaCanvasClip, WaCanvasClipPath, WaCanvasCompositing, WaCanvasDrawImage, WaCanvasEllipse, WaCanvasFillStrokeStyles, WaCanvasFilter, WaCanvasGradientPipe, WaCanvasImageSmoothing, WaCanvasLineTo, WaCanvasMoveTo, WaCanvasPath, WaCanvasPath2d, WaCanvasPathDrawingStyles, WaCanvasPathPipe, WaCanvasPatternPipe, WaCanvasQuadraticCurveTo, WaCanvasRadPipe, WaCanvasRect, WaCanvasShadowStyles, WaCanvasText, WaCanvasTextDrawingStyles, WaCanvasTransform, WaCanvasTransformPipe, WaDrawService, asCanvasMethod, asCanvasProperty }; //# sourceMappingURL=ng-web-apis-canvas.mjs.map