@visactor/vrender-kits 0.21.9-alpha.0 → 0.21.9-alpha.2

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.
@@ -1,4 +1,4 @@
1
- import type { IContext2d, IContributionProvider, IDrawContext, IGraphicAttribute, IGraphicRender, IImageRenderContribution, IMarkAttribute, IRenderService, IThemeAttribute } from '@visactor/vrender-core';
1
+ import type { IContext2d, IContributionProvider, IDrawContext, IGraphicAttribute, IGraphicRender, IGraphicRenderDrawParams, IImageRenderContribution, IMarkAttribute, IRenderService, IThemeAttribute } from '@visactor/vrender-core';
2
2
  import { BaseRenderContributionTime, DefaultCanvasImageRender, DefaultRectRenderContribution } from '@visactor/vrender-core';
3
3
  import type { IGifImage } from '../../../interface/gif-image';
4
4
  export declare class DefaultCanvasGifImageRender extends DefaultCanvasImageRender implements IGraphicRender {
@@ -6,6 +6,7 @@ export declare class DefaultCanvasGifImageRender extends DefaultCanvasImageRende
6
6
  type: 'image';
7
7
  numberType: number;
8
8
  constructor(imageRenderContribitions: IContributionProvider<IImageRenderContribution>);
9
+ drawShape(image: IGifImage, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
9
10
  draw(image: IGifImage, renderService: IRenderService, drawContext: IDrawContext): void;
10
11
  }
11
12
  export declare class DefaultGifImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {
@@ -24,6 +24,19 @@ let DefaultCanvasGifImageRender = class extends vrender_core_1.DefaultCanvasImag
24
24
  this.numberType = constants_1.GIFIMAGE_NUMBER_TYPE, this._renderContribitions = void 0,
25
25
  this.builtinContributions = [ exports.defaultGifImageRenderContribution ], this.init(imageRenderContribitions);
26
26
  }
27
+ drawShape(image, context, x, y, drawContext, params, fillCb, strokeCb) {
28
+ const imageAttribute = (0, vrender_core_1.getTheme)(image).image, {x: originX = imageAttribute.x, y: originY = imageAttribute.y, fillStrokeOrder: fillStrokeOrder = imageAttribute.fillStrokeOrder} = image.attribute, data = this.valid(image, imageAttribute, fillCb);
29
+ if (!data) return;
30
+ const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, _runFill = () => {
31
+ doFill && fillCb && fillCb(context, image.attribute, imageAttribute);
32
+ }, _runStroke = () => {
33
+ doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute),
34
+ context.stroke()));
35
+ };
36
+ fillStrokeOrder ? (_runStroke(), context.save(), context.clip(), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb),
37
+ _runFill(), context.restore()) : (context.save(), context.clip(), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb),
38
+ _runFill(), context.restore(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
39
+ }
27
40
  draw(image, renderService, drawContext) {
28
41
  const {context: context} = renderService.drawParams;
29
42
  if (!context) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/canvas/gif-image-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAWA,yDAUgC;AAChC,0DAAkE;AAI3D,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,uCAAwB;IAIvE,YAGqB,wBAAyE;QAE5F,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAFb,6BAAwB,GAAxB,wBAAwB,CAAiD;QAL9F,eAAU,GAAW,gCAAoB,CAAC;QAQxC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACtC,IAAI,CAAC,oBAAoB,GAAG,CAAC,yC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n IGraphicRender,\n IImageRenderContribution,\n IMarkAttribute,\n IRenderService,\n IThemeAttribute\n} from '@visactor/vrender-core';\nimport {\n BaseRenderContributionTime,\n ContributionProvider,\n DefaultCanvasImageRender,\n DefaultRectRenderContribution,\n getTheme,\n ImageRenderContribution,\n inject,\n injectable,\n named\n} from '@visactor/vrender-core';\nimport { GIFIMAGE_NUMBER_TYPE } from '../../../graphic/constants';\nimport type { IGifImage } from '../../../interface/gif-image';\n\n@injectable()\nexport class DefaultCanvasGifImageRender extends DefaultCanvasImageRender implements IGraphicRender {\n type: 'image';\n numberType: number = GIFIMAGE_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(ImageRenderContribution)\n protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>\n ) {\n super(imageRenderContribitions);\n this._renderContribitions = undefined;\n this.builtinContributions = [defaultGifImageRenderContribution];\n this.init(imageRenderContribitions);\n }\n\n draw(image: IGifImage, renderService: IRenderService, drawContext: IDrawContext) {\n const { context } = renderService.drawParams;\n if (!context) {\n return;\n }\n const imageAttribute = getTheme(image).image;\n this._draw(image, imageAttribute, false, drawContext);\n }\n}\n\nexport class DefaultGifImageRenderContribution\n extends DefaultRectRenderContribution\n implements IImageRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n image: any,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: any,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (image.renderFrame && image.playing) {\n image.renderFrame(context, x, y);\n }\n }\n}\n\nexport const defaultGifImageRenderContribution = new DefaultGifImageRenderContribution();\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/canvas/gif-image-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAYA,yDAUgC;AAChC,0DAAkE;AAI3D,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,uCAAwB;IAIvE,YAGqB,wBAAyE;QAE5F,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAFb,6BAAwB,GAAxB,wBAAwB,CAAiD;QAL9F,eAAU,GAAW,gCAAoB,CAAC;QAQxC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACtC,IAAI,CAAC,oBAAoB,GAAG,CAAC,yCAAiC,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACtC,CAAC;IAED,SAAS,CACP,KAAgB,EAChB,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAGZ,MAAM,cAAc,GAAG,IAAA,uBAAQ,EAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QAC7C,MAAM,EACJ,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC,EAC7B,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC,EAC7B,eAAe,GAAG,cAAc,CAAC,eAAe,EACjD,GAAG,KAAK,CAAC,SAAS,CAAC;QAEpB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,EAAE;YACT,OAAO;SACR;QACD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAGtD,MAAM,WAAW,GAAG,IAAI,CAAC;QAEzB,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,IAAI,MAAM,EAAE;gBACV,IAAI,MAAM,EAAE;oBACV,MAAM,C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EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;SAClC;IACH,CAAC;CACF;AAjCD,8EAiCC;AAEY,QAAA,iCAAiC,GAAG,IAAI,iCAAiC,EAAE,CAAC","file":"gif-image-render.js","sourcesContent":["import type {\n IContext2d,\n IContributionProvider,\n IDrawContext,\n IGraphicAttribute,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IImageRenderContribution,\n IMarkAttribute,\n IRenderService,\n IThemeAttribute\n} from '@visactor/vrender-core';\nimport {\n BaseRenderContributionTime,\n ContributionProvider,\n DefaultCanvasImageRender,\n DefaultRectRenderContribution,\n getTheme,\n ImageRenderContribution,\n inject,\n injectable,\n named\n} from '@visactor/vrender-core';\nimport { GIFIMAGE_NUMBER_TYPE } from '../../../graphic/constants';\nimport type { IGifImage } from '../../../interface/gif-image';\n\n@injectable()\nexport class DefaultCanvasGifImageRender extends DefaultCanvasImageRender implements IGraphicRender {\n type: 'image';\n numberType: number = GIFIMAGE_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(ImageRenderContribution)\n protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>\n ) {\n super(imageRenderContribitions);\n this._renderContribitions = undefined;\n this.builtinContributions = [defaultGifImageRenderContribution];\n this.init(imageRenderContribitions);\n }\n\n drawShape(\n image: IGifImage,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const imageAttribute = graphicService.themeService.getCurrentTheme().imageAttribute;\n const imageAttribute = getTheme(image).image;\n const {\n x: originX = imageAttribute.x,\n y: originY = imageAttribute.y,\n fillStrokeOrder = imageAttribute.fillStrokeOrder\n } = image.attribute;\n\n const data = this.valid(image, imageAttribute, fillCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // deal with cornerRadius\n const needRestore = true;\n\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, image.attribute, imageAttribute);\n } else if (fVisible) {\n }\n }\n };\n\n const _runStroke = () => {\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, image.attribute, imageAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n if (needRestore) {\n context.save();\n context.clip();\n }\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n _runFill();\n if (needRestore) {\n context.restore();\n }\n _runStroke();\n } else {\n _runStroke();\n if (needRestore) {\n context.save();\n context.clip();\n }\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n _runFill();\n if (needRestore) {\n context.restore();\n }\n }\n\n this.afterRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n }\n\n draw(image: IGifImage, renderService: IRenderService, drawContext: IDrawContext) {\n const { context } = renderService.drawParams;\n if (!context) {\n return;\n }\n const imageAttribute = getTheme(image).image;\n this._draw(image, imageAttribute, false, drawContext);\n }\n}\n\nexport class DefaultGifImageRenderContribution\n extends DefaultRectRenderContribution\n implements IImageRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n image: any,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: any,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (image.renderFrame && image.playing) {\n image.renderFrame(context, x, y);\n }\n }\n}\n\nexport const defaultGifImageRenderContribution = new DefaultGifImageRenderContribution();\n"]}
package/dist/index.es.js CHANGED
@@ -9086,6 +9086,58 @@ let DefaultCanvasGifImageRender = class DefaultCanvasGifImageRender extends Defa
9086
9086
  this.builtinContributions = [defaultGifImageRenderContribution];
9087
9087
  this.init(imageRenderContribitions);
9088
9088
  }
9089
+ drawShape(image, context, x, y, drawContext, params, fillCb, strokeCb) {
9090
+ const imageAttribute = getTheme(image).image;
9091
+ const { x: originX = imageAttribute.x, y: originY = imageAttribute.y, fillStrokeOrder = imageAttribute.fillStrokeOrder } = image.attribute;
9092
+ const data = this.valid(image, imageAttribute, fillCb);
9093
+ if (!data) {
9094
+ return;
9095
+ }
9096
+ const { fVisible, sVisible, doFill, doStroke } = data;
9097
+ const _runFill = () => {
9098
+ if (doFill) {
9099
+ if (fillCb) {
9100
+ fillCb(context, image.attribute, imageAttribute);
9101
+ }
9102
+ }
9103
+ };
9104
+ const _runStroke = () => {
9105
+ if (doStroke) {
9106
+ if (strokeCb) {
9107
+ strokeCb(context, image.attribute, imageAttribute);
9108
+ }
9109
+ else if (sVisible) {
9110
+ context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute);
9111
+ context.stroke();
9112
+ }
9113
+ }
9114
+ };
9115
+ if (!fillStrokeOrder) {
9116
+ {
9117
+ context.save();
9118
+ context.clip();
9119
+ }
9120
+ this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);
9121
+ _runFill();
9122
+ {
9123
+ context.restore();
9124
+ }
9125
+ _runStroke();
9126
+ }
9127
+ else {
9128
+ _runStroke();
9129
+ {
9130
+ context.save();
9131
+ context.clip();
9132
+ }
9133
+ this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);
9134
+ _runFill();
9135
+ {
9136
+ context.restore();
9137
+ }
9138
+ }
9139
+ this.afterRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);
9140
+ }
9089
9141
  draw(image, renderService, drawContext) {
9090
9142
  const { context } = renderService.drawParams;
9091
9143
  if (!context) {
@@ -1,4 +1,4 @@
1
- import type { IContext2d, IContributionProvider, IDrawContext, IGraphicAttribute, IGraphicRender, IImageRenderContribution, IMarkAttribute, IRenderService, IThemeAttribute } from '@visactor/vrender-core';
1
+ import type { IContext2d, IContributionProvider, IDrawContext, IGraphicAttribute, IGraphicRender, IGraphicRenderDrawParams, IImageRenderContribution, IMarkAttribute, IRenderService, IThemeAttribute } from '@visactor/vrender-core';
2
2
  import { BaseRenderContributionTime, DefaultCanvasImageRender, DefaultRectRenderContribution } from '@visactor/vrender-core';
3
3
  import type { IGifImage } from '../../../interface/gif-image';
4
4
  export declare class DefaultCanvasGifImageRender extends DefaultCanvasImageRender implements IGraphicRender {
@@ -6,6 +6,7 @@ export declare class DefaultCanvasGifImageRender extends DefaultCanvasImageRende
6
6
  type: 'image';
7
7
  numberType: number;
8
8
  constructor(imageRenderContribitions: IContributionProvider<IImageRenderContribution>);
9
+ drawShape(image: IGifImage, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
9
10
  draw(image: IGifImage, renderService: IRenderService, drawContext: IDrawContext): void;
10
11
  }
11
12
  export declare class DefaultGifImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {
@@ -20,6 +20,19 @@ let DefaultCanvasGifImageRender = class extends DefaultCanvasImageRender {
20
20
  this.numberType = GIFIMAGE_NUMBER_TYPE, this._renderContribitions = void 0, this.builtinContributions = [ defaultGifImageRenderContribution ],
21
21
  this.init(imageRenderContribitions);
22
22
  }
23
+ drawShape(image, context, x, y, drawContext, params, fillCb, strokeCb) {
24
+ const imageAttribute = getTheme(image).image, {x: originX = imageAttribute.x, y: originY = imageAttribute.y, fillStrokeOrder: fillStrokeOrder = imageAttribute.fillStrokeOrder} = image.attribute, data = this.valid(image, imageAttribute, fillCb);
25
+ if (!data) return;
26
+ const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, _runFill = () => {
27
+ doFill && fillCb && fillCb(context, image.attribute, imageAttribute);
28
+ }, _runStroke = () => {
29
+ doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute),
30
+ context.stroke()));
31
+ };
32
+ fillStrokeOrder ? (_runStroke(), context.save(), context.clip(), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb),
33
+ _runFill(), context.restore()) : (context.save(), context.clip(), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb),
34
+ _runFill(), context.restore(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
35
+ }
23
36
  draw(image, renderService, drawContext) {
24
37
  const {context: context} = renderService.drawParams;
25
38
  if (!context) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/canvas/gif-image-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,6BAA6B,EAC7B,QAAQ,EACR,uBAAuB,EACvB,MAAM,EACN,UAAU,EACV,KAAK,EACN,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAI3D,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,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AO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;SAClC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,iCAAiC,EAAE,CAAC","file":"gif-image-render.js","sourcesContent":["import type {\n IContext2d,\n IContributionProvider,\n IDrawContext,\n IGraphicAttribute,\n IGraphicRender,\n IImageRenderContribution,\n IMarkAttribute,\n IRenderService,\n IThemeAttribute\n} from '@visactor/vrender-core';\nimport {\n BaseRenderContributionTime,\n ContributionProvider,\n DefaultCanvasImageRender,\n DefaultRectRenderContribution,\n getTheme,\n ImageRenderContribution,\n inject,\n injectable,\n named\n} from '@visactor/vrender-core';\nimport { GIFIMAGE_NUMBER_TYPE } from '../../../graphic/constants';\nimport type { IGifImage } from '../../../interface/gif-image';\n\n@injectable()\nexport class DefaultCanvasGifImageRender extends DefaultCanvasImageRender implements IGraphicRender {\n type: 'image';\n numberType: number = GIFIMAGE_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(ImageRenderContribution)\n protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>\n ) {\n super(imageRenderContribitions);\n this._renderContribitions = undefined;\n this.builtinContributions = [defaultGifImageRenderContribution];\n this.init(imageRenderContribitions);\n }\n\n draw(image: IGifImage, renderService: IRenderService, drawContext: IDrawContext) {\n const { context } = renderService.drawParams;\n if (!context) {\n return;\n }\n const imageAttribute = getTheme(image).image;\n this._draw(image, imageAttribute, false, drawContext);\n }\n}\n\nexport class DefaultGifImageRenderContribution\n extends DefaultRectRenderContribution\n implements IImageRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n image: any,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: any,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (image.renderFrame && image.playing) {\n image.renderFrame(context, x, y);\n }\n }\n}\n\nexport const defaultGifImageRenderContribution = new DefaultGifImageRenderContribution();\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/canvas/gif-image-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAYA,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,6BAA6B,EAC7B,QAAQ,EACR,uBAAuB,EACvB,MAAM,EACN,UAAU,EACV,KAAK,EACN,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAI3D,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,wBAAwB;IAIvE,YAGqB,wBAAyE;QAE5F,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAFb,6BAAwB,GAAxB,wBAAwB,CAAiD;QAL9F,eAAU,GAAW,oBAAoB,CAAC;QAQxC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACtC,IAAI,CAAC,oBAAoB,GAAG,CAAC,iCAAiC,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACtC,CAAC;IAED,SAAS,CACP,KAAgB,EAChB,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAGZ,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QAC7C,MAAM,EACJ,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC,EAC7B,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC,EAC7B,eAAe,GAAG,cAAc,CAAC,eAAe,EACjD,GAAG,KAAK,CAAC,SA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C,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IA2BpB,CAAC;IA1BC,SAAS,CACP,KAAU,EACV,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,aAAkB,EAClB,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,OAAO,EAAE;YACtC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;SAClC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,iCAAiC,EAAE,CAAC","file":"gif-image-render.js","sourcesContent":["import type {\n IContext2d,\n IContributionProvider,\n IDrawContext,\n IGraphicAttribute,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IImageRenderContribution,\n IMarkAttribute,\n IRenderService,\n IThemeAttribute\n} from '@visactor/vrender-core';\nimport {\n BaseRenderContributionTime,\n ContributionProvider,\n DefaultCanvasImageRender,\n DefaultRectRenderContribution,\n getTheme,\n ImageRenderContribution,\n inject,\n injectable,\n named\n} from '@visactor/vrender-core';\nimport { GIFIMAGE_NUMBER_TYPE } from '../../../graphic/constants';\nimport type { IGifImage } from '../../../interface/gif-image';\n\n@injectable()\nexport class DefaultCanvasGifImageRender extends DefaultCanvasImageRender implements IGraphicRender {\n type: 'image';\n numberType: number = GIFIMAGE_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(ImageRenderContribution)\n protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>\n ) {\n super(imageRenderContribitions);\n this._renderContribitions = undefined;\n this.builtinContributions = [defaultGifImageRenderContribution];\n this.init(imageRenderContribitions);\n }\n\n drawShape(\n image: IGifImage,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const imageAttribute = graphicService.themeService.getCurrentTheme().imageAttribute;\n const imageAttribute = getTheme(image).image;\n const {\n x: originX = imageAttribute.x,\n y: originY = imageAttribute.y,\n fillStrokeOrder = imageAttribute.fillStrokeOrder\n } = image.attribute;\n\n const data = this.valid(image, imageAttribute, fillCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // deal with cornerRadius\n const needRestore = true;\n\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, image.attribute, imageAttribute);\n } else if (fVisible) {\n }\n }\n };\n\n const _runStroke = () => {\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, image.attribute, imageAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n if (needRestore) {\n context.save();\n context.clip();\n }\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n _runFill();\n if (needRestore) {\n context.restore();\n }\n _runStroke();\n } else {\n _runStroke();\n if (needRestore) {\n context.save();\n context.clip();\n }\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n _runFill();\n if (needRestore) {\n context.restore();\n }\n }\n\n this.afterRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n }\n\n draw(image: IGifImage, renderService: IRenderService, drawContext: IDrawContext) {\n const { context } = renderService.drawParams;\n if (!context) {\n return;\n }\n const imageAttribute = getTheme(image).image;\n this._draw(image, imageAttribute, false, drawContext);\n }\n}\n\nexport class DefaultGifImageRenderContribution\n extends DefaultRectRenderContribution\n implements IImageRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n image: any,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: any,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (image.renderFrame && image.playing) {\n image.renderFrame(context, x, y);\n }\n }\n}\n\nexport const defaultGifImageRenderContribution = new DefaultGifImageRenderContribution();\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-kits",
3
- "version": "0.21.9-alpha.0",
3
+ "version": "0.21.9-alpha.2",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "dependencies": {
15
15
  "@visactor/vutils": "~0.19.3",
16
- "@visactor/vrender-core": "0.21.9-alpha.0",
16
+ "@visactor/vrender-core": "0.21.9-alpha.2",
17
17
  "@resvg/resvg-js": "2.4.1",
18
18
  "roughjs": "4.5.2",
19
19
  "gifuct-js": "2.1.2"