@visactor/vrender-kits 0.21.14 → 0.22.0-vstory.10
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/cjs/canvas/contributions/browser/context.js +5 -4
- package/cjs/canvas/contributions/browser/context.js.map +1 -1
- package/cjs/canvas/contributions/harmony/context.js +3 -3
- package/cjs/canvas/contributions/harmony/context.js.map +1 -1
- package/cjs/canvas/contributions/lynx/context.js +4 -10
- package/cjs/canvas/contributions/lynx/context.js.map +1 -1
- package/cjs/canvas/contributions/taro/context.js +3 -2
- package/cjs/canvas/contributions/taro/context.js.map +1 -1
- package/cjs/env/contributions/browser-contribution.d.ts +3 -0
- package/cjs/env/contributions/browser-contribution.js +12 -2
- package/cjs/env/contributions/browser-contribution.js.map +1 -1
- package/cjs/env/contributions/canvas-wrap.js +2 -1
- package/cjs/env/contributions/feishu-contribution.js +1 -3
- package/cjs/env/contributions/feishu-contribution.js.map +1 -1
- package/cjs/env/contributions/tt-contribution.js +2 -2
- package/cjs/env/contributions/tt-contribution.js.map +1 -1
- package/cjs/env/contributions/wx-contribution.js +3 -3
- package/cjs/env/contributions/wx-contribution.js.map +1 -1
- package/cjs/graphic/Lottie.d.ts +49 -0
- package/cjs/graphic/Lottie.js +62 -0
- package/cjs/graphic/Lottie.js.map +1 -0
- package/cjs/graphic/constants.d.ts +1 -1
- package/cjs/graphic/constants.js +2 -3
- package/cjs/graphic/constants.js.map +1 -1
- package/cjs/graphic/interface/lottie.d.ts +10 -0
- package/cjs/{interface/gif-image.js → graphic/interface/lottie.js} +1 -1
- package/cjs/graphic/interface/lottie.js.map +1 -0
- package/cjs/index.d.ts +3 -3
- package/cjs/index.js +11 -11
- package/cjs/index.js.map +1 -1
- package/cjs/jsx/jsx-classic.js +3 -9
- package/cjs/jsx/jsx-classic.js.map +1 -1
- package/cjs/picker/canvas-picker-service.d.ts +3 -2
- package/cjs/picker/canvas-picker-service.js +7 -4
- package/cjs/picker/canvas-picker-service.js.map +1 -1
- package/cjs/picker/contributions/canvas-picker/lottie-module.d.ts +2 -0
- package/cjs/picker/contributions/canvas-picker/lottie-module.js +15 -0
- package/cjs/picker/contributions/canvas-picker/lottie-module.js.map +1 -0
- package/cjs/picker/contributions/canvas-picker/lottie-picker.d.ts +6 -0
- package/cjs/picker/contributions/canvas-picker/lottie-picker.js +30 -0
- package/cjs/picker/contributions/canvas-picker/lottie-picker.js.map +1 -0
- package/cjs/picker/contributions/common/base.d.ts +1 -1
- package/cjs/picker/contributions/common/base.js +0 -1
- package/cjs/picker/contributions/common/base.js.map +1 -1
- package/cjs/picker/contributions/constants.d.ts +1 -1
- package/cjs/picker/contributions/constants.js +3 -3
- package/cjs/picker/contributions/constants.js.map +1 -1
- package/cjs/picker/math-picker-service.d.ts +3 -2
- package/cjs/picker/math-picker-service.js +5 -3
- package/cjs/picker/math-picker-service.js.map +1 -1
- package/cjs/register/register-group.js +2 -1
- package/cjs/register/register-image.js +1 -2
- package/cjs/render/contributions/canvas/{gif-image-module.d.ts → lottie-module.d.ts} +1 -1
- package/cjs/render/contributions/canvas/lottie-module.js +15 -0
- package/cjs/render/contributions/canvas/lottie-module.js.map +1 -0
- package/cjs/render/contributions/canvas/lottie-render.d.ts +9 -0
- package/cjs/render/contributions/canvas/lottie-render.js +40 -0
- package/cjs/render/contributions/canvas/lottie-render.js.map +1 -0
- package/dist/index.es.js +844 -843
- package/es/canvas/contributions/browser/context.js +5 -3
- package/es/canvas/contributions/browser/context.js.map +1 -1
- package/es/canvas/contributions/harmony/context.js +3 -3
- package/es/canvas/contributions/harmony/context.js.map +1 -1
- package/es/canvas/contributions/lynx/context.js +4 -10
- package/es/canvas/contributions/lynx/context.js.map +1 -1
- package/es/canvas/contributions/taro/context.js +3 -2
- package/es/canvas/contributions/taro/context.js.map +1 -1
- package/es/env/contributions/browser-contribution.d.ts +3 -0
- package/es/env/contributions/browser-contribution.js +13 -2
- package/es/env/contributions/browser-contribution.js.map +1 -1
- package/es/env/contributions/canvas-wrap.js +2 -1
- package/es/env/contributions/feishu-contribution.js +1 -3
- package/es/env/contributions/feishu-contribution.js.map +1 -1
- package/es/env/contributions/tt-contribution.js +2 -2
- package/es/env/contributions/tt-contribution.js.map +1 -1
- package/es/env/contributions/wx-contribution.js +3 -3
- package/es/env/contributions/wx-contribution.js.map +1 -1
- package/es/graphic/Lottie.d.ts +49 -0
- package/es/graphic/Lottie.js +53 -0
- package/es/graphic/Lottie.js.map +1 -0
- package/es/graphic/constants.d.ts +1 -1
- package/es/graphic/constants.js +1 -2
- package/es/graphic/constants.js.map +1 -1
- package/es/graphic/interface/lottie.d.ts +10 -0
- package/es/graphic/interface/lottie.js +2 -0
- package/es/graphic/interface/lottie.js.map +1 -0
- package/es/index.d.ts +3 -3
- package/es/index.js +3 -3
- package/es/index.js.map +1 -1
- package/es/jsx/jsx-classic.js +3 -9
- package/es/jsx/jsx-classic.js.map +1 -1
- package/es/picker/canvas-picker-service.d.ts +3 -2
- package/es/picker/canvas-picker-service.js +7 -5
- package/es/picker/canvas-picker-service.js.map +1 -1
- package/es/picker/contributions/canvas-picker/lottie-module.d.ts +2 -0
- package/es/picker/contributions/canvas-picker/lottie-module.js +13 -0
- package/es/picker/contributions/canvas-picker/lottie-module.js.map +1 -0
- package/es/picker/contributions/canvas-picker/lottie-picker.d.ts +6 -0
- package/es/picker/contributions/canvas-picker/lottie-picker.js +26 -0
- package/es/picker/contributions/canvas-picker/lottie-picker.js.map +1 -0
- package/es/picker/contributions/common/base.d.ts +1 -1
- package/es/picker/contributions/common/base.js +0 -1
- package/es/picker/contributions/common/base.js.map +1 -1
- package/es/picker/contributions/constants.d.ts +1 -1
- package/es/picker/contributions/constants.js +2 -2
- package/es/picker/contributions/constants.js.map +1 -1
- package/es/picker/math-picker-service.d.ts +3 -2
- package/es/picker/math-picker-service.js +5 -4
- package/es/picker/math-picker-service.js.map +1 -1
- package/es/register/register-group.js +2 -1
- package/es/register/register-image.js +1 -2
- package/es/render/contributions/canvas/{gif-image-module.d.ts → lottie-module.d.ts} +1 -1
- package/es/render/contributions/canvas/lottie-module.js +11 -0
- package/es/render/contributions/canvas/lottie-module.js.map +1 -0
- package/es/render/contributions/canvas/lottie-render.d.ts +9 -0
- package/es/render/contributions/canvas/lottie-render.js +36 -0
- package/es/render/contributions/canvas/lottie-render.js.map +1 -0
- package/package.json +4 -4
- package/cjs/graphic/gif-image.d.ts +0 -26
- package/cjs/graphic/gif-image.js +0 -63
- package/cjs/graphic/gif-image.js.map +0 -1
- package/cjs/interface/gif-image.d.ts +0 -17
- package/cjs/interface/gif-image.js.map +0 -1
- package/cjs/picker/contributions/canvas-picker/gif-image-module.d.ts +0 -2
- package/cjs/picker/contributions/canvas-picker/gif-image-module.js +0 -15
- package/cjs/picker/contributions/canvas-picker/gif-image-module.js.map +0 -1
- package/cjs/picker/contributions/canvas-picker/gif-image-picker.d.ts +0 -8
- package/cjs/picker/contributions/canvas-picker/gif-image-picker.js +0 -27
- package/cjs/picker/contributions/canvas-picker/gif-image-picker.js.map +0 -1
- package/cjs/render/contributions/canvas/gif-image-module.js +0 -15
- package/cjs/render/contributions/canvas/gif-image-module.js.map +0 -1
- package/cjs/render/contributions/canvas/gif-image-render.d.ts +0 -18
- package/cjs/render/contributions/canvas/gif-image-render.js +0 -63
- package/cjs/render/contributions/canvas/gif-image-render.js.map +0 -1
- package/es/graphic/gif-image.d.ts +0 -26
- package/es/graphic/gif-image.js +0 -61
- package/es/graphic/gif-image.js.map +0 -1
- package/es/interface/gif-image.d.ts +0 -17
- package/es/interface/gif-image.js +0 -2
- package/es/interface/gif-image.js.map +0 -1
- package/es/picker/contributions/canvas-picker/gif-image-module.d.ts +0 -2
- package/es/picker/contributions/canvas-picker/gif-image-module.js +0 -13
- package/es/picker/contributions/canvas-picker/gif-image-module.js.map +0 -1
- package/es/picker/contributions/canvas-picker/gif-image-picker.d.ts +0 -8
- package/es/picker/contributions/canvas-picker/gif-image-picker.js +0 -24
- package/es/picker/contributions/canvas-picker/gif-image-picker.js.map +0 -1
- package/es/render/contributions/canvas/gif-image-module.js +0 -11
- package/es/render/contributions/canvas/gif-image-module.js.map +0 -1
- package/es/render/contributions/canvas/gif-image-render.d.ts +0 -18
- package/es/render/contributions/canvas/gif-image-render.js +0 -59
- package/es/render/contributions/canvas/gif-image-render.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/gif-image.ts"],"names":[],"mappings":";;;AACA,yDAA4E;AAE5E,6CAA4C;AAE5C,yCAAuD;AAEvD,2CAAmD;AAEnD,MAAa,QAAS,SAAQ,oBAAK;IAcjC,YAAY,MAAiC;QAC3C,KAAK,CAAC,MAAM,CAAC,CAAC;QAdhB,SAAI,GAAQ,WAAW,CAAC;QAetB,IAAI,CAAC,UAAU,GAAG,gCAAoB,CAAC;QACvC,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,OAAO;QACL,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;YACrC,6BAAc,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC;iBAC3D,IAAI,CAAC,CAAC,GAAgB,EAAE,EAAE;gBACzB,MAAM,GAAG,GAAG,IAAA,oBAAQ,EAAC,GAAG,CAAC,CAAC;gBAC1B,MAAM,MAAM,GAAG,IAAA,4BAAgB,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;gBAC3C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACzB,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,CAAC,EAAE;gBACT,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;SACN;aAAM,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,YAAY,WAAW,EAAE;YACzD,MAAM,GAAG,GAAG,IAAA,oBAAQ,EAAC,IAAI,CAAC,SAAS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AI,CAAC,OAAO,EAAE,CAAC;SAChB;IACH,CAAC;CACF;AA9ID,4BA8IC;AAED,SAAgB,cAAc,CAAC,UAAqC;IAClE,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC;AAFD,wCAEC","file":"gif-image.js","sourcesContent":["import type { IImageGraphicAttribute, ISetAttributeContext } from '@visactor/vrender-core';\nimport { application, Image, ResourceLoader } from '@visactor/vrender-core';\nimport type { ITimeline } from '@visactor/vrender-core';\nimport { isString } from '@visactor/vutils';\nimport type { ParsedFrame } from 'gifuct-js';\nimport { decompressFrames, parseGIF } from 'gifuct-js';\nimport type { IGifImage, IGifImageGraphicAttribute } from '../interface/gif-image';\nimport { GIFIMAGE_NUMBER_TYPE } from './constants';\n\nexport class GifImage extends Image implements IGifImage {\n type: any = 'gif-image';\n declare attribute: IGifImageGraphicAttribute;\n\n frameImageData?: ImageData;\n tempCanvas?: HTMLCanvasElement;\n tempCtx?: CanvasRenderingContext2D;\n gifCanvas?: HTMLCanvasElement;\n gifCtx?: CanvasRenderingContext2D;\n loadedFrames?: ParsedFrame[];\n frameIndex?: number;\n playing?: boolean;\n lastTime?: number;\n\n constructor(params: IGifImageGraphicAttribute) {\n super(params);\n this.numberType = GIFIMAGE_NUMBER_TYPE;\n this.loadGif();\n }\n\n loadGif() {\n if (isString(this.attribute.gifImage)) {\n ResourceLoader.GetFile(this.attribute.gifImage, 'arrayBuffer')\n .then((res: ArrayBuffer) => {\n const gif = parseGIF(res);\n const frames = decompressFrames(gif, true);\n this.renderGIF(frames);\n })\n .catch(e => {\n console.error('Gif load error: ', e);\n });\n } else if (this.attribute.gifImage instanceof ArrayBuffer) {\n const gif = parseGIF(this.attribute.gifImage);\n const frames = decompressFrames(gif, true);\n this.renderGIF(frames);\n }\n }\n\n renderGIF(frames: ParsedFrame[]) {\n this.loadedFrames = frames;\n this.frameIndex = 0;\n\n if (!this.tempCanvas) {\n this.tempCanvas = application.global.createCanvas({});\n this.tempCtx = this.tempCanvas.getContext('2d');\n }\n\n if (!this.gifCanvas) {\n this.gifCanvas = application.global.createCanvas({});\n this.gifCtx = this.gifCanvas.getContext('2d');\n }\n\n this.gifCanvas.width = frames[0].dims.width;\n this.gifCanvas.height = frames[0].dims.height;\n\n this.playing = true;\n this.lastTime = new Date().getTime();\n const animation = this.animate();\n if (this.attribute.timeline) {\n animation.setTimeline(this.attribute.timeline);\n }\n animation.to({}, 1000, 'linear').loop(Infinity);\n }\n\n renderFrame(context: CanvasRenderingContext2D, x: number, y: number) {\n // get the frame\n const frame = this.loadedFrames[this.frameIndex || 0];\n\n if (frame.disposalType === 2) {\n this.gifCtx.clearRect(0, 0, this.gifCanvas.width, this.gifCanvas.height);\n }\n\n // draw image into gifCanvas\n this.drawPatch(frame);\n\n // draw gifCanvas into stage\n this.manipulate(context, x, y);\n\n // update the frame index\n const diff = new Date().getTime() - this.lastTime;\n if (frame.delay < diff) {\n this.frameIndex++;\n this.lastTime = new Date().getTime();\n }\n if (this.frameIndex >= this.loadedFrames.length) {\n this.frameIndex = 0;\n }\n }\n\n drawPatch(frame: ParsedFrame) {\n const dims = frame.dims;\n\n if (\n !this.frameImageData ||\n dims.width !== this.frameImageData.width ||\n dims.height !== this.frameImageData.height\n ) {\n this.tempCanvas.width = dims.width;\n this.tempCanvas.height = dims.height;\n this.frameImageData = this.tempCtx.createImageData(dims.width, dims.height);\n }\n\n // set the patch data as an override\n this.frameImageData.data.set(frame.patch);\n\n // draw the patch back over the canvas\n this.tempCtx.putImageData(this.frameImageData, 0, 0);\n\n this.gifCtx.drawImage(this.tempCanvas, dims.left, dims.top);\n }\n\n manipulate(context: CanvasRenderingContext2D, x: number, y: number) {\n context.drawImage(\n this.gifCanvas,\n 0,\n 0,\n this.gifCanvas.width,\n this.gifCanvas.height,\n x,\n y,\n this.attribute.width,\n this.attribute.height\n );\n }\n\n setAttribute(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext): void {\n super.setAttribute(key, value, forceUpdateTag, context);\n if (key === 'gifImage') {\n this.loadGif();\n }\n }\n\n setAttributes(\n params: Partial<IGifImageGraphicAttribute>,\n forceUpdateTag?: boolean,\n context?: ISetAttributeContext\n ): void {\n super.setAttributes(params, forceUpdateTag, context);\n if (params.gifImage) {\n this.loadGif();\n }\n }\n}\n\nexport function createGifImage(attributes: IGifImageGraphicAttribute): IGifImage {\n return new GifImage(attributes);\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { IGraphic, IImageGraphicAttribute, ITimeline } from '@visactor/vrender-core';
|
|
2
|
-
import type { ParsedFrame } from 'gifuct-js';
|
|
3
|
-
export interface IGifImageGraphicAttribute extends IImageGraphicAttribute {
|
|
4
|
-
timeline?: ITimeline;
|
|
5
|
-
gifImage?: string | ArrayBuffer;
|
|
6
|
-
}
|
|
7
|
-
export interface IGifImage extends IGraphic<IGifImageGraphicAttribute> {
|
|
8
|
-
frameImageData?: ImageData;
|
|
9
|
-
tempCanvas?: HTMLCanvasElement;
|
|
10
|
-
tempCtx?: CanvasRenderingContext2D;
|
|
11
|
-
gifCanvas?: HTMLCanvasElement;
|
|
12
|
-
gifCtx?: CanvasRenderingContext2D;
|
|
13
|
-
loadedFrames?: ParsedFrame[];
|
|
14
|
-
frameIndex?: number;
|
|
15
|
-
playing?: boolean;
|
|
16
|
-
lastTime?: number;
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/gif-image.ts"],"names":[],"mappings":"","file":"gif-image.js","sourcesContent":["import type { IGraphic, IImageGraphicAttribute, ITimeline } from '@visactor/vrender-core';\nimport type { ParsedFrame } from 'gifuct-js';\n\nexport interface IGifImageGraphicAttribute extends IImageGraphicAttribute {\n timeline?: ITimeline;\n gifImage?: string | ArrayBuffer;\n}\n\nexport interface IGifImage extends IGraphic<IGifImageGraphicAttribute> {\n frameImageData?: ImageData;\n tempCanvas?: HTMLCanvasElement;\n tempCtx?: CanvasRenderingContext2D;\n gifCanvas?: HTMLCanvasElement;\n gifCtx?: CanvasRenderingContext2D;\n loadedFrames?: ParsedFrame[];\n frameIndex?: number;\n playing?: boolean;\n lastTime?: number;\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: !0
|
|
5
|
-
}), exports.gifImageCanvasPickModule = void 0;
|
|
6
|
-
|
|
7
|
-
const vrender_core_1 = require("@visactor/vrender-core"), constants_1 = require("../constants"), gif_image_picker_1 = require("./gif-image-picker");
|
|
8
|
-
|
|
9
|
-
let loadGifImagePick = !1;
|
|
10
|
-
|
|
11
|
-
exports.gifImageCanvasPickModule = new vrender_core_1.ContainerModule(((bind, unbind, isBound, rebind) => {
|
|
12
|
-
loadGifImagePick || (loadGifImagePick = !0, bind(constants_1.CanvasGifImagePicker).to(gif_image_picker_1.DefaultCanvasGifImagePicker).inSingletonScope(),
|
|
13
|
-
bind(constants_1.CanvasPickerContribution).toService(constants_1.CanvasGifImagePicker));
|
|
14
|
-
}));
|
|
15
|
-
//# sourceMappingURL=gif-image-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/picker/contributions/canvas-picker/gif-image-module.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,4CAA8E;AAC9E,yDAAiE;AAEjE,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAChB,QAAA,wBAAwB,GAAG,IAAI,8BAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IAC5F,IAAI,gBAAgB,EAAE;QACpB,OAAO;KACR;IACD,gBAAgB,GAAG,IAAI,CAAC;IAExB,IAAI,CAAC,gCAAoB,CAAC,CAAC,EAAE,CAAC,8CAA2B,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC9E,IAAI,CAAC,oCAAwB,CAAC,CAAC,SAAS,CAAC,gCAAoB,CAAC,CAAC;AACjE,CAAC,CAAC,CAAC","file":"gif-image-module.js","sourcesContent":["import { ContainerModule } from '@visactor/vrender-core';\nimport { CanvasGifImagePicker, CanvasPickerContribution } from '../constants';\nimport { DefaultCanvasGifImagePicker } from './gif-image-picker';\n\nlet loadGifImagePick = false;\nexport const gifImageCanvasPickModule = new ContainerModule((bind, unbind, isBound, rebind) => {\n if (loadGifImagePick) {\n return;\n }\n loadGifImagePick = true;\n // gifGifImage picker\n bind(CanvasGifImagePicker).to(DefaultCanvasGifImagePicker).inSingletonScope();\n bind(CanvasPickerContribution).toService(CanvasGifImagePicker);\n});\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { IPoint } from '@visactor/vutils';
|
|
2
|
-
import type { IGraphicPicker, IPickParams } from '@visactor/vrender-core';
|
|
3
|
-
import type { IGifImage } from '../../../interface/gif-image';
|
|
4
|
-
export declare class DefaultCanvasGifImagePicker implements IGraphicPicker {
|
|
5
|
-
type: string;
|
|
6
|
-
numberType: number;
|
|
7
|
-
contains(gifImage: IGifImage, point: IPoint, params?: IPickParams): boolean;
|
|
8
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
4
|
-
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "__esModule", {
|
|
10
|
-
value: !0
|
|
11
|
-
}), exports.DefaultCanvasGifImagePicker = void 0;
|
|
12
|
-
|
|
13
|
-
const vrender_core_1 = require("@visactor/vrender-core"), constants_1 = require("../../../graphic/constants");
|
|
14
|
-
|
|
15
|
-
let DefaultCanvasGifImagePicker = class {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.type = "gif-image", this.numberType = constants_1.GIFIMAGE_NUMBER_TYPE;
|
|
18
|
-
}
|
|
19
|
-
contains(gifImage, point, params) {
|
|
20
|
-
const {pickContext: pickContext} = null != params ? params : {};
|
|
21
|
-
return !!pickContext && !!gifImage.AABBBounds.containsPoint(point);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
DefaultCanvasGifImagePicker = __decorate([ (0, vrender_core_1.injectable)() ], DefaultCanvasGifImagePicker),
|
|
26
|
-
exports.DefaultCanvasGifImagePicker = DefaultCanvasGifImagePicker;
|
|
27
|
-
//# sourceMappingURL=gif-image-picker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/picker/contributions/canvas-picker/gif-image-picker.ts"],"names":[],"mappings":";;;;;;;;;AACA,yDAAoD;AAGpD,0DAAkE;AAG3D,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAAjC;QACL,SAAI,GAAW,WAAW,CAAC;QAC3B,eAAU,GAAW,gCAAoB,CAAC;IAqB5C,CAAC;IAnBC,QAAQ,CAAC,QAAmB,EAAE,KAAa,EAAE,MAAoB;QAO/D,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC;QACrC,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;YAC7C,OAAO,KAAK,CAAC;SACd;QAGD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAvBY,2BAA2B;IADvC,IAAA,yBAAU,GAAE;GACA,2BAA2B,CAuBvC;AAvBY,kEAA2B","file":"gif-image-picker.js","sourcesContent":["import type { IPoint } from '@visactor/vutils';\nimport { injectable } from '@visactor/vrender-core';\nimport type { IGraphicPicker, IPickParams } from '@visactor/vrender-core';\nimport type { IGifImage } from '../../../interface/gif-image';\nimport { GIFIMAGE_NUMBER_TYPE } from '../../../graphic/constants';\n\n@injectable()\nexport class DefaultCanvasGifImagePicker implements IGraphicPicker {\n type: string = 'gif-image';\n numberType: number = GIFIMAGE_NUMBER_TYPE;\n\n contains(gifImage: IGifImage, point: IPoint, params?: IPickParams): boolean {\n // const { gifImageAttribute } = graphicService.themeService.getCurrentTheme();\n // const {\n // x = gifImageAttribute.x,\n // y = gifImageAttribute.y,\n // } = gifImage.attribute;\n\n const { pickContext } = params ?? {};\n if (!pickContext) {\n return false;\n }\n\n if (!gifImage.AABBBounds.containsPoint(point)) {\n return false;\n }\n\n // TODO: 详细形状判断\n return true;\n }\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: !0
|
|
5
|
-
}), exports.gifImageModule = void 0;
|
|
6
|
-
|
|
7
|
-
const vrender_core_1 = require("@visactor/vrender-core"), gif_image_render_1 = require("./gif-image-render");
|
|
8
|
-
|
|
9
|
-
let loadGifImageModule = !1;
|
|
10
|
-
|
|
11
|
-
exports.gifImageModule = new vrender_core_1.ContainerModule((bind => {
|
|
12
|
-
loadGifImageModule || (loadGifImageModule = !0, bind(gif_image_render_1.DefaultCanvasGifImageRender).toSelf().inSingletonScope(),
|
|
13
|
-
bind(vrender_core_1.GraphicRender).toService(gif_image_render_1.DefaultCanvasGifImageRender));
|
|
14
|
-
}));
|
|
15
|
-
//# sourceMappingURL=gif-image-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/canvas/gif-image-module.ts"],"names":[],"mappings":";;;AAAA,yDAAwE;AACxE,yDAAiE;AAEjE,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAClB,QAAA,cAAc,GAAG,IAAI,8BAAe,CAAC,IAAI,CAAC,EAAE;IACvD,IAAI,kBAAkB,EAAE;QACtB,OAAO;KACR;IACD,kBAAkB,GAAG,IAAI,CAAC;IAE1B,IAAI,CAAC,8CAA2B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC9D,IAAI,CAAC,4BAAa,CAAC,CAAC,SAAS,CAAC,8CAA2B,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC","file":"gif-image-module.js","sourcesContent":["import { ContainerModule, GraphicRender } from '@visactor/vrender-core';\nimport { DefaultCanvasGifImageRender } from './gif-image-render';\n\nlet loadGifImageModule = false;\nexport const gifImageModule = new ContainerModule(bind => {\n if (loadGifImageModule) {\n return;\n }\n loadGifImageModule = true;\n // gifImage渲染器\n bind(DefaultCanvasGifImageRender).toSelf().inSingletonScope();\n bind(GraphicRender).toService(DefaultCanvasGifImageRender);\n});\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { IContext2d, IContributionProvider, IDrawContext, IGraphicAttribute, IGraphicRender, IGraphicRenderDrawParams, IImageRenderContribution, IMarkAttribute, IRenderService, IThemeAttribute } from '@visactor/vrender-core';
|
|
2
|
-
import { BaseRenderContributionTime, DefaultCanvasImageRender, DefaultRectRenderContribution } from '@visactor/vrender-core';
|
|
3
|
-
import type { IGifImage } from '../../../interface/gif-image';
|
|
4
|
-
export declare class DefaultCanvasGifImageRender extends DefaultCanvasImageRender implements IGraphicRender {
|
|
5
|
-
protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>;
|
|
6
|
-
type: 'image';
|
|
7
|
-
numberType: number;
|
|
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;
|
|
10
|
-
draw(image: IGifImage, renderService: IRenderService, drawContext: IDrawContext): void;
|
|
11
|
-
}
|
|
12
|
-
export declare class DefaultGifImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {
|
|
13
|
-
time: BaseRenderContributionTime;
|
|
14
|
-
useStyle: boolean;
|
|
15
|
-
order: number;
|
|
16
|
-
drawShape(image: any, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, rectAttribute: any, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
17
|
-
}
|
|
18
|
-
export declare const defaultGifImageRenderContribution: DefaultGifImageRenderContribution;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
4
|
-
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
}, __metadata = this && this.__metadata || function(k, v) {
|
|
8
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
9
|
-
}, __param = this && this.__param || function(paramIndex, decorator) {
|
|
10
|
-
return function(target, key) {
|
|
11
|
-
decorator(target, key, paramIndex);
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(exports, "__esModule", {
|
|
16
|
-
value: !0
|
|
17
|
-
}), exports.defaultGifImageRenderContribution = exports.DefaultGifImageRenderContribution = exports.DefaultCanvasGifImageRender = void 0;
|
|
18
|
-
|
|
19
|
-
const vrender_core_1 = require("@visactor/vrender-core"), constants_1 = require("../../../graphic/constants");
|
|
20
|
-
|
|
21
|
-
let DefaultCanvasGifImageRender = class extends vrender_core_1.DefaultCanvasImageRender {
|
|
22
|
-
constructor(imageRenderContribitions) {
|
|
23
|
-
super(imageRenderContribitions), this.imageRenderContribitions = imageRenderContribitions,
|
|
24
|
-
this.numberType = constants_1.GIFIMAGE_NUMBER_TYPE, this._renderContribitions = void 0,
|
|
25
|
-
this.builtinContributions = [ exports.defaultGifImageRenderContribution ], this.init(imageRenderContribitions);
|
|
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
|
-
}
|
|
40
|
-
draw(image, renderService, drawContext) {
|
|
41
|
-
const {context: context} = renderService.drawParams;
|
|
42
|
-
if (!context) return;
|
|
43
|
-
const imageAttribute = (0, vrender_core_1.getTheme)(image).image;
|
|
44
|
-
this._draw(image, imageAttribute, !1, drawContext);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
DefaultCanvasGifImageRender = __decorate([ (0, vrender_core_1.injectable)(), __param(0, (0,
|
|
49
|
-
vrender_core_1.inject)(vrender_core_1.ContributionProvider)), __param(0, (0, vrender_core_1.named)(vrender_core_1.ImageRenderContribution)), __metadata("design:paramtypes", [ Object ]) ], DefaultCanvasGifImageRender),
|
|
50
|
-
exports.DefaultCanvasGifImageRender = DefaultCanvasGifImageRender;
|
|
51
|
-
|
|
52
|
-
class DefaultGifImageRenderContribution extends vrender_core_1.DefaultRectRenderContribution {
|
|
53
|
-
constructor() {
|
|
54
|
-
super(...arguments), this.time = vrender_core_1.BaseRenderContributionTime.afterFillStroke,
|
|
55
|
-
this.useStyle = !0, this.order = 0;
|
|
56
|
-
}
|
|
57
|
-
drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
|
|
58
|
-
image.renderFrame && image.playing && image.renderFrame(context, x, y);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
exports.DefaultGifImageRenderContribution = DefaultGifImageRenderContribution, exports.defaultGifImageRenderContribution = new DefaultGifImageRenderContribution;
|
|
63
|
-
//# sourceMappingURL=gif-image-render.js.map
|
|
@@ -1 +0,0 @@
|
|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AAC;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"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ISetAttributeContext } from '@visactor/vrender-core';
|
|
2
|
-
import { Image } from '@visactor/vrender-core';
|
|
3
|
-
import type { ParsedFrame } from 'gifuct-js';
|
|
4
|
-
import type { IGifImage, IGifImageGraphicAttribute } from '../interface/gif-image';
|
|
5
|
-
export declare class GifImage extends Image implements IGifImage {
|
|
6
|
-
type: any;
|
|
7
|
-
attribute: IGifImageGraphicAttribute;
|
|
8
|
-
frameImageData?: ImageData;
|
|
9
|
-
tempCanvas?: HTMLCanvasElement;
|
|
10
|
-
tempCtx?: CanvasRenderingContext2D;
|
|
11
|
-
gifCanvas?: HTMLCanvasElement;
|
|
12
|
-
gifCtx?: CanvasRenderingContext2D;
|
|
13
|
-
loadedFrames?: ParsedFrame[];
|
|
14
|
-
frameIndex?: number;
|
|
15
|
-
playing?: boolean;
|
|
16
|
-
lastTime?: number;
|
|
17
|
-
constructor(params: IGifImageGraphicAttribute);
|
|
18
|
-
loadGif(): void;
|
|
19
|
-
renderGIF(frames: ParsedFrame[]): void;
|
|
20
|
-
renderFrame(context: CanvasRenderingContext2D, x: number, y: number): void;
|
|
21
|
-
drawPatch(frame: ParsedFrame): void;
|
|
22
|
-
manipulate(context: CanvasRenderingContext2D, x: number, y: number): void;
|
|
23
|
-
setAttribute(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
|
|
24
|
-
setAttributes(params: Partial<IGifImageGraphicAttribute>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
|
|
25
|
-
}
|
|
26
|
-
export declare function createGifImage(attributes: IGifImageGraphicAttribute): IGifImage;
|
package/es/graphic/gif-image.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { application, Image, ResourceLoader } from "@visactor/vrender-core";
|
|
2
|
-
|
|
3
|
-
import { isString } from "@visactor/vutils";
|
|
4
|
-
|
|
5
|
-
import { decompressFrames, parseGIF } from "gifuct-js";
|
|
6
|
-
|
|
7
|
-
import { GIFIMAGE_NUMBER_TYPE } from "./constants";
|
|
8
|
-
|
|
9
|
-
export class GifImage extends Image {
|
|
10
|
-
constructor(params) {
|
|
11
|
-
super(params), this.type = "gif-image", this.numberType = GIFIMAGE_NUMBER_TYPE,
|
|
12
|
-
this.loadGif();
|
|
13
|
-
}
|
|
14
|
-
loadGif() {
|
|
15
|
-
if (isString(this.attribute.gifImage)) ResourceLoader.GetFile(this.attribute.gifImage, "arrayBuffer").then((res => {
|
|
16
|
-
const gif = parseGIF(res), frames = decompressFrames(gif, !0);
|
|
17
|
-
this.renderGIF(frames);
|
|
18
|
-
})).catch((e => {
|
|
19
|
-
console.error("Gif load error: ", e);
|
|
20
|
-
})); else if (this.attribute.gifImage instanceof ArrayBuffer) {
|
|
21
|
-
const gif = parseGIF(this.attribute.gifImage), frames = decompressFrames(gif, !0);
|
|
22
|
-
this.renderGIF(frames);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
renderGIF(frames) {
|
|
26
|
-
this.loadedFrames = frames, this.frameIndex = 0, this.tempCanvas || (this.tempCanvas = application.global.createCanvas({}),
|
|
27
|
-
this.tempCtx = this.tempCanvas.getContext("2d")), this.gifCanvas || (this.gifCanvas = application.global.createCanvas({}),
|
|
28
|
-
this.gifCtx = this.gifCanvas.getContext("2d")), this.gifCanvas.width = frames[0].dims.width,
|
|
29
|
-
this.gifCanvas.height = frames[0].dims.height, this.playing = !0, this.lastTime = (new Date).getTime();
|
|
30
|
-
const animation = this.animate();
|
|
31
|
-
this.attribute.timeline && animation.setTimeline(this.attribute.timeline), animation.to({}, 1e3, "linear").loop(1 / 0);
|
|
32
|
-
}
|
|
33
|
-
renderFrame(context, x, y) {
|
|
34
|
-
const frame = this.loadedFrames[this.frameIndex || 0];
|
|
35
|
-
2 === frame.disposalType && this.gifCtx.clearRect(0, 0, this.gifCanvas.width, this.gifCanvas.height),
|
|
36
|
-
this.drawPatch(frame), this.manipulate(context, x, y);
|
|
37
|
-
const diff = (new Date).getTime() - this.lastTime;
|
|
38
|
-
frame.delay < diff && (this.frameIndex++, this.lastTime = (new Date).getTime()),
|
|
39
|
-
this.frameIndex >= this.loadedFrames.length && (this.frameIndex = 0);
|
|
40
|
-
}
|
|
41
|
-
drawPatch(frame) {
|
|
42
|
-
const dims = frame.dims;
|
|
43
|
-
this.frameImageData && dims.width === this.frameImageData.width && dims.height === this.frameImageData.height || (this.tempCanvas.width = dims.width,
|
|
44
|
-
this.tempCanvas.height = dims.height, this.frameImageData = this.tempCtx.createImageData(dims.width, dims.height)),
|
|
45
|
-
this.frameImageData.data.set(frame.patch), this.tempCtx.putImageData(this.frameImageData, 0, 0),
|
|
46
|
-
this.gifCtx.drawImage(this.tempCanvas, dims.left, dims.top);
|
|
47
|
-
}
|
|
48
|
-
manipulate(context, x, y) {
|
|
49
|
-
context.drawImage(this.gifCanvas, 0, 0, this.gifCanvas.width, this.gifCanvas.height, x, y, this.attribute.width, this.attribute.height);
|
|
50
|
-
}
|
|
51
|
-
setAttribute(key, value, forceUpdateTag, context) {
|
|
52
|
-
super.setAttribute(key, value, forceUpdateTag, context), "gifImage" === key && this.loadGif();
|
|
53
|
-
}
|
|
54
|
-
setAttributes(params, forceUpdateTag, context) {
|
|
55
|
-
super.setAttributes(params, forceUpdateTag, context), params.gifImage && this.loadGif();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function createGifImage(attributes) {
|
|
60
|
-
return new GifImage(attributes);
|
|
61
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/gif-image.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AA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ender-core';\nimport { application, Image, ResourceLoader } from '@visactor/vrender-core';\nimport type { ITimeline } from '@visactor/vrender-core';\nimport { isString } from '@visactor/vutils';\nimport type { ParsedFrame } from 'gifuct-js';\nimport { decompressFrames, parseGIF } from 'gifuct-js';\nimport type { IGifImage, IGifImageGraphicAttribute } from '../interface/gif-image';\nimport { GIFIMAGE_NUMBER_TYPE } from './constants';\n\nexport class GifImage extends Image implements IGifImage {\n type: any = 'gif-image';\n declare attribute: IGifImageGraphicAttribute;\n\n frameImageData?: ImageData;\n tempCanvas?: HTMLCanvasElement;\n tempCtx?: CanvasRenderingContext2D;\n gifCanvas?: HTMLCanvasElement;\n gifCtx?: CanvasRenderingContext2D;\n loadedFrames?: ParsedFrame[];\n frameIndex?: number;\n playing?: boolean;\n lastTime?: number;\n\n constructor(params: IGifImageGraphicAttribute) {\n super(params);\n this.numberType = GIFIMAGE_NUMBER_TYPE;\n this.loadGif();\n }\n\n loadGif() {\n if (isString(this.attribute.gifImage)) {\n ResourceLoader.GetFile(this.attribute.gifImage, 'arrayBuffer')\n .then((res: ArrayBuffer) => {\n const gif = parseGIF(res);\n const frames = decompressFrames(gif, true);\n this.renderGIF(frames);\n })\n .catch(e => {\n console.error('Gif load error: ', e);\n });\n } else if (this.attribute.gifImage instanceof ArrayBuffer) {\n const gif = parseGIF(this.attribute.gifImage);\n const frames = decompressFrames(gif, true);\n this.renderGIF(frames);\n }\n }\n\n renderGIF(frames: ParsedFrame[]) {\n this.loadedFrames = frames;\n this.frameIndex = 0;\n\n if (!this.tempCanvas) {\n this.tempCanvas = application.global.createCanvas({});\n this.tempCtx = this.tempCanvas.getContext('2d');\n }\n\n if (!this.gifCanvas) {\n this.gifCanvas = application.global.createCanvas({});\n this.gifCtx = this.gifCanvas.getContext('2d');\n }\n\n this.gifCanvas.width = frames[0].dims.width;\n this.gifCanvas.height = frames[0].dims.height;\n\n this.playing = true;\n this.lastTime = new Date().getTime();\n const animation = this.animate();\n if (this.attribute.timeline) {\n animation.setTimeline(this.attribute.timeline);\n }\n animation.to({}, 1000, 'linear').loop(Infinity);\n }\n\n renderFrame(context: CanvasRenderingContext2D, x: number, y: number) {\n // get the frame\n const frame = this.loadedFrames[this.frameIndex || 0];\n\n if (frame.disposalType === 2) {\n this.gifCtx.clearRect(0, 0, this.gifCanvas.width, this.gifCanvas.height);\n }\n\n // draw image into gifCanvas\n this.drawPatch(frame);\n\n // draw gifCanvas into stage\n this.manipulate(context, x, y);\n\n // update the frame index\n const diff = new Date().getTime() - this.lastTime;\n if (frame.delay < diff) {\n this.frameIndex++;\n this.lastTime = new Date().getTime();\n }\n if (this.frameIndex >= this.loadedFrames.length) {\n this.frameIndex = 0;\n }\n }\n\n drawPatch(frame: ParsedFrame) {\n const dims = frame.dims;\n\n if (\n !this.frameImageData ||\n dims.width !== this.frameImageData.width ||\n dims.height !== this.frameImageData.height\n ) {\n this.tempCanvas.width = dims.width;\n this.tempCanvas.height = dims.height;\n this.frameImageData = this.tempCtx.createImageData(dims.width, dims.height);\n }\n\n // set the patch data as an override\n this.frameImageData.data.set(frame.patch);\n\n // draw the patch back over the canvas\n this.tempCtx.putImageData(this.frameImageData, 0, 0);\n\n this.gifCtx.drawImage(this.tempCanvas, dims.left, dims.top);\n }\n\n manipulate(context: CanvasRenderingContext2D, x: number, y: number) {\n context.drawImage(\n this.gifCanvas,\n 0,\n 0,\n this.gifCanvas.width,\n this.gifCanvas.height,\n x,\n y,\n this.attribute.width,\n this.attribute.height\n );\n }\n\n setAttribute(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext): void {\n super.setAttribute(key, value, forceUpdateTag, context);\n if (key === 'gifImage') {\n this.loadGif();\n }\n }\n\n setAttributes(\n params: Partial<IGifImageGraphicAttribute>,\n forceUpdateTag?: boolean,\n context?: ISetAttributeContext\n ): void {\n super.setAttributes(params, forceUpdateTag, context);\n if (params.gifImage) {\n this.loadGif();\n }\n }\n}\n\nexport function createGifImage(attributes: IGifImageGraphicAttribute): IGifImage {\n return new GifImage(attributes);\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { IGraphic, IImageGraphicAttribute, ITimeline } from '@visactor/vrender-core';
|
|
2
|
-
import type { ParsedFrame } from 'gifuct-js';
|
|
3
|
-
export interface IGifImageGraphicAttribute extends IImageGraphicAttribute {
|
|
4
|
-
timeline?: ITimeline;
|
|
5
|
-
gifImage?: string | ArrayBuffer;
|
|
6
|
-
}
|
|
7
|
-
export interface IGifImage extends IGraphic<IGifImageGraphicAttribute> {
|
|
8
|
-
frameImageData?: ImageData;
|
|
9
|
-
tempCanvas?: HTMLCanvasElement;
|
|
10
|
-
tempCtx?: CanvasRenderingContext2D;
|
|
11
|
-
gifCanvas?: HTMLCanvasElement;
|
|
12
|
-
gifCtx?: CanvasRenderingContext2D;
|
|
13
|
-
loadedFrames?: ParsedFrame[];
|
|
14
|
-
frameIndex?: number;
|
|
15
|
-
playing?: boolean;
|
|
16
|
-
lastTime?: number;
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/gif-image.ts"],"names":[],"mappings":"","file":"gif-image.js","sourcesContent":["import type { IGraphic, IImageGraphicAttribute, ITimeline } from '@visactor/vrender-core';\nimport type { ParsedFrame } from 'gifuct-js';\n\nexport interface IGifImageGraphicAttribute extends IImageGraphicAttribute {\n timeline?: ITimeline;\n gifImage?: string | ArrayBuffer;\n}\n\nexport interface IGifImage extends IGraphic<IGifImageGraphicAttribute> {\n frameImageData?: ImageData;\n tempCanvas?: HTMLCanvasElement;\n tempCtx?: CanvasRenderingContext2D;\n gifCanvas?: HTMLCanvasElement;\n gifCtx?: CanvasRenderingContext2D;\n loadedFrames?: ParsedFrame[];\n frameIndex?: number;\n playing?: boolean;\n lastTime?: number;\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ContainerModule } from "@visactor/vrender-core";
|
|
2
|
-
|
|
3
|
-
import { CanvasGifImagePicker, CanvasPickerContribution } from "../constants";
|
|
4
|
-
|
|
5
|
-
import { DefaultCanvasGifImagePicker } from "./gif-image-picker";
|
|
6
|
-
|
|
7
|
-
let loadGifImagePick = !1;
|
|
8
|
-
|
|
9
|
-
export const gifImageCanvasPickModule = new ContainerModule(((bind, unbind, isBound, rebind) => {
|
|
10
|
-
loadGifImagePick || (loadGifImagePick = !0, bind(CanvasGifImagePicker).to(DefaultCanvasGifImagePicker).inSingletonScope(),
|
|
11
|
-
bind(CanvasPickerContribution).toService(CanvasGifImagePicker));
|
|
12
|
-
}));
|
|
13
|
-
//# sourceMappingURL=gif-image-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/picker/contributions/canvas-picker/gif-image-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEjE,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAC7B,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,eAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IAC5F,IAAI,gBAAgB,EAAE;QACpB,OAAO;KACR;IACD,gBAAgB,GAAG,IAAI,CAAC;IAExB,IAAI,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC9E,IAAI,CAAC,wBAAwB,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;AACjE,CAAC,CAAC,CAAC","file":"gif-image-module.js","sourcesContent":["import { ContainerModule } from '@visactor/vrender-core';\nimport { CanvasGifImagePicker, CanvasPickerContribution } from '../constants';\nimport { DefaultCanvasGifImagePicker } from './gif-image-picker';\n\nlet loadGifImagePick = false;\nexport const gifImageCanvasPickModule = new ContainerModule((bind, unbind, isBound, rebind) => {\n if (loadGifImagePick) {\n return;\n }\n loadGifImagePick = true;\n // gifGifImage picker\n bind(CanvasGifImagePicker).to(DefaultCanvasGifImagePicker).inSingletonScope();\n bind(CanvasPickerContribution).toService(CanvasGifImagePicker);\n});\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { IPoint } from '@visactor/vutils';
|
|
2
|
-
import type { IGraphicPicker, IPickParams } from '@visactor/vrender-core';
|
|
3
|
-
import type { IGifImage } from '../../../interface/gif-image';
|
|
4
|
-
export declare class DefaultCanvasGifImagePicker implements IGraphicPicker {
|
|
5
|
-
type: string;
|
|
6
|
-
numberType: number;
|
|
7
|
-
contains(gifImage: IGifImage, point: IPoint, params?: IPickParams): boolean;
|
|
8
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
2
|
-
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
3
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
4
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
import { injectable } from "@visactor/vrender-core";
|
|
8
|
-
|
|
9
|
-
import { GIFIMAGE_NUMBER_TYPE } from "../../../graphic/constants";
|
|
10
|
-
|
|
11
|
-
let DefaultCanvasGifImagePicker = class {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.type = "gif-image", this.numberType = GIFIMAGE_NUMBER_TYPE;
|
|
14
|
-
}
|
|
15
|
-
contains(gifImage, point, params) {
|
|
16
|
-
const {pickContext: pickContext} = null != params ? params : {};
|
|
17
|
-
return !!pickContext && !!gifImage.AABBBounds.containsPoint(point);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
DefaultCanvasGifImagePicker = __decorate([ injectable() ], DefaultCanvasGifImagePicker);
|
|
22
|
-
|
|
23
|
-
export { DefaultCanvasGifImagePicker };
|
|
24
|
-
//# sourceMappingURL=gif-image-picker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/picker/contributions/canvas-picker/gif-image-picker.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAG3D,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAAjC;QACL,SAAI,GAAW,WAAW,CAAC;QAC3B,eAAU,GAAW,oBAAoB,CAAC;IAqB5C,CAAC;IAnBC,QAAQ,CAAC,QAAmB,EAAE,KAAa,EAAE,MAAoB;QAO/D,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC;QACrC,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;YAC7C,OAAO,KAAK,CAAC;SACd;QAGD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAvBY,2BAA2B;IADvC,UAAU,EAAE;GACA,2BAA2B,CAuBvC;SAvBY,2BAA2B","file":"gif-image-picker.js","sourcesContent":["import type { IPoint } from '@visactor/vutils';\nimport { injectable } from '@visactor/vrender-core';\nimport type { IGraphicPicker, IPickParams } from '@visactor/vrender-core';\nimport type { IGifImage } from '../../../interface/gif-image';\nimport { GIFIMAGE_NUMBER_TYPE } from '../../../graphic/constants';\n\n@injectable()\nexport class DefaultCanvasGifImagePicker implements IGraphicPicker {\n type: string = 'gif-image';\n numberType: number = GIFIMAGE_NUMBER_TYPE;\n\n contains(gifImage: IGifImage, point: IPoint, params?: IPickParams): boolean {\n // const { gifImageAttribute } = graphicService.themeService.getCurrentTheme();\n // const {\n // x = gifImageAttribute.x,\n // y = gifImageAttribute.y,\n // } = gifImage.attribute;\n\n const { pickContext } = params ?? {};\n if (!pickContext) {\n return false;\n }\n\n if (!gifImage.AABBBounds.containsPoint(point)) {\n return false;\n }\n\n // TODO: 详细形状判断\n return true;\n }\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ContainerModule, GraphicRender } from "@visactor/vrender-core";
|
|
2
|
-
|
|
3
|
-
import { DefaultCanvasGifImageRender } from "./gif-image-render";
|
|
4
|
-
|
|
5
|
-
let loadGifImageModule = !1;
|
|
6
|
-
|
|
7
|
-
export const gifImageModule = new ContainerModule((bind => {
|
|
8
|
-
loadGifImageModule || (loadGifImageModule = !0, bind(DefaultCanvasGifImageRender).toSelf().inSingletonScope(),
|
|
9
|
-
bind(GraphicRender).toService(DefaultCanvasGifImageRender));
|
|
10
|
-
}));
|
|
11
|
-
//# sourceMappingURL=gif-image-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/canvas/gif-image-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEjE,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAC/B,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;IACvD,IAAI,kBAAkB,EAAE;QACtB,OAAO;KACR;IACD,kBAAkB,GAAG,IAAI,CAAC;IAE1B,IAAI,CAAC,2BAA2B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC9D,IAAI,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC","file":"gif-image-module.js","sourcesContent":["import { ContainerModule, GraphicRender } from '@visactor/vrender-core';\nimport { DefaultCanvasGifImageRender } from './gif-image-render';\n\nlet loadGifImageModule = false;\nexport const gifImageModule = new ContainerModule(bind => {\n if (loadGifImageModule) {\n return;\n }\n loadGifImageModule = true;\n // gifImage渲染器\n bind(DefaultCanvasGifImageRender).toSelf().inSingletonScope();\n bind(GraphicRender).toService(DefaultCanvasGifImageRender);\n});\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { IContext2d, IContributionProvider, IDrawContext, IGraphicAttribute, IGraphicRender, IGraphicRenderDrawParams, IImageRenderContribution, IMarkAttribute, IRenderService, IThemeAttribute } from '@visactor/vrender-core';
|
|
2
|
-
import { BaseRenderContributionTime, DefaultCanvasImageRender, DefaultRectRenderContribution } from '@visactor/vrender-core';
|
|
3
|
-
import type { IGifImage } from '../../../interface/gif-image';
|
|
4
|
-
export declare class DefaultCanvasGifImageRender extends DefaultCanvasImageRender implements IGraphicRender {
|
|
5
|
-
protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>;
|
|
6
|
-
type: 'image';
|
|
7
|
-
numberType: number;
|
|
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;
|
|
10
|
-
draw(image: IGifImage, renderService: IRenderService, drawContext: IDrawContext): void;
|
|
11
|
-
}
|
|
12
|
-
export declare class DefaultGifImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {
|
|
13
|
-
time: BaseRenderContributionTime;
|
|
14
|
-
useStyle: boolean;
|
|
15
|
-
order: number;
|
|
16
|
-
drawShape(image: any, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, rectAttribute: any, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
17
|
-
}
|
|
18
|
-
export declare const defaultGifImageRenderContribution: DefaultGifImageRenderContribution;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
2
|
-
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
3
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
4
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5
|
-
}, __metadata = this && this.__metadata || function(k, v) {
|
|
6
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
7
|
-
}, __param = this && this.__param || function(paramIndex, decorator) {
|
|
8
|
-
return function(target, key) {
|
|
9
|
-
decorator(target, key, paramIndex);
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
import { BaseRenderContributionTime, ContributionProvider, DefaultCanvasImageRender, DefaultRectRenderContribution, getTheme, ImageRenderContribution, inject, injectable, named } from "@visactor/vrender-core";
|
|
14
|
-
|
|
15
|
-
import { GIFIMAGE_NUMBER_TYPE } from "../../../graphic/constants";
|
|
16
|
-
|
|
17
|
-
let DefaultCanvasGifImageRender = class extends DefaultCanvasImageRender {
|
|
18
|
-
constructor(imageRenderContribitions) {
|
|
19
|
-
super(imageRenderContribitions), this.imageRenderContribitions = imageRenderContribitions,
|
|
20
|
-
this.numberType = GIFIMAGE_NUMBER_TYPE, this._renderContribitions = void 0, this.builtinContributions = [ defaultGifImageRenderContribution ],
|
|
21
|
-
this.init(imageRenderContribitions);
|
|
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
|
-
}
|
|
36
|
-
draw(image, renderService, drawContext) {
|
|
37
|
-
const {context: context} = renderService.drawParams;
|
|
38
|
-
if (!context) return;
|
|
39
|
-
const imageAttribute = getTheme(image).image;
|
|
40
|
-
this._draw(image, imageAttribute, !1, drawContext);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
DefaultCanvasGifImageRender = __decorate([ injectable(), __param(0, inject(ContributionProvider)), __param(0, named(ImageRenderContribution)), __metadata("design:paramtypes", [ Object ]) ], DefaultCanvasGifImageRender);
|
|
45
|
-
|
|
46
|
-
export { DefaultCanvasGifImageRender };
|
|
47
|
-
|
|
48
|
-
export class DefaultGifImageRenderContribution extends DefaultRectRenderContribution {
|
|
49
|
-
constructor() {
|
|
50
|
-
super(...arguments), this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0,
|
|
51
|
-
this.order = 0;
|
|
52
|
-
}
|
|
53
|
-
drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
|
|
54
|
-
image.renderFrame && image.playing && image.renderFrame(context, x, y);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const defaultGifImageRenderContribution = new DefaultGifImageRenderContribution;
|
|
59
|
-
//# sourceMappingURL=gif-image-render.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,GAA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,EAAE;YACZ,OAAO;SACR;QACD,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AAzGY,2BAA2B;IADvC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,uBAAuB,CAAC,CAAA;;GANtB,2BAA2B,CAyGvC;SAzGY,2BAA2B;AA2GxC,MAAM,OAAO,iCACX,SAAQ,6BAA6B;IADvC;;QAIE,SAAI,GAA+B,0BAA0B,CAAC,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"]}
|