@visactor/vrender-core 0.21.5-alpha.1 → 0.21.5
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/animate/custom-animate.js +1 -2
- package/cjs/canvas/empty-context.js +2 -1
- package/cjs/common/3d-interceptor.js +1 -2
- package/cjs/common/color-utils.js +1 -1
- package/cjs/common/contribution-provider.js +1 -1
- package/cjs/common/custom-path2d.js +1 -1
- package/cjs/common/enums.js +1 -1
- package/cjs/common/generator.js +1 -1
- package/cjs/common/matrix.js +1 -1
- package/cjs/common/morphing-utils.js +1 -1
- package/cjs/common/path-svg.js +1 -1
- package/cjs/common/polygon.js +2 -2
- package/cjs/common/rect-utils.js +1 -1
- package/cjs/common/render-area.js +1 -1
- package/cjs/common/render-command-list.js +1 -2
- package/cjs/common/render-curve.js +1 -1
- package/cjs/common/render-utils.js +1 -1
- package/cjs/common/seg-context.js +1 -1
- package/cjs/common/simplify.js +1 -1
- package/cjs/common/sort.js +1 -1
- package/cjs/common/split-path.js +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/core/application.js +1 -1
- package/cjs/core/camera.js +1 -1
- package/cjs/core/constants.js +1 -1
- package/cjs/core/core-modules.js +1 -1
- package/cjs/core/global-module.js +2 -0
- package/cjs/core/global.js +1 -1
- package/cjs/core/graphic-utils.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/layer-service.js +1 -1
- package/cjs/core/layer.js +1 -1
- package/cjs/core/light.js +2 -1
- package/cjs/core/stage.js +1 -1
- package/cjs/core/window.js +1 -1
- package/cjs/event/constant.js +2 -1
- package/cjs/event/event-manager.js +1 -1
- package/cjs/event/event-system.js +1 -1
- package/cjs/event/event-target.js +1 -1
- package/cjs/event/index.js +1 -1
- package/cjs/event/util.js +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.d.ts +2 -6
- package/cjs/render/contributions/render/contributions/image-contribution-render.js +3 -48
- package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js +12 -12
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/dist/index.es.js +23 -113
- package/es/animate/custom-animate.js +1 -2
- package/es/canvas/empty-context.js +2 -1
- package/es/common/3d-interceptor.js +1 -2
- package/es/common/color-utils.js +1 -1
- package/es/common/contribution-provider.js +1 -1
- package/es/common/custom-path2d.js +1 -1
- package/es/common/enums.js +1 -1
- package/es/common/generator.js +1 -1
- package/es/common/matrix.js +1 -1
- package/es/common/morphing-utils.js +1 -1
- package/es/common/path-svg.js +1 -1
- package/es/common/polygon.js +1 -1
- package/es/common/rect-utils.js +1 -1
- package/es/common/render-area.js +1 -1
- package/es/common/render-command-list.js +1 -2
- package/es/common/render-curve.js +1 -1
- package/es/common/render-utils.js +1 -1
- package/es/common/seg-context.js +1 -1
- package/es/common/simplify.js +1 -1
- package/es/common/sort.js +1 -1
- package/es/common/split-path.js +1 -1
- package/es/common/store.js +1 -1
- package/es/core/application.js +1 -1
- package/es/core/camera.js +1 -1
- package/es/core/constants.js +1 -1
- package/es/core/core-modules.js +1 -1
- package/es/core/global-module.js +2 -0
- package/es/core/global.js +1 -1
- package/es/core/graphic-utils.js +1 -1
- package/es/core/index.js +1 -1
- package/es/core/layer-service.js +1 -1
- package/es/core/layer.js +1 -1
- package/es/core/light.js +2 -1
- package/es/core/stage.js +1 -1
- package/es/core/window.js +1 -1
- package/es/event/constant.js +2 -1
- package/es/event/event-manager.js +1 -1
- package/es/event/event-system.js +1 -1
- package/es/event/event-target.js +1 -1
- package/es/event/index.js +1 -1
- package/es/event/util.js +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.d.ts +2 -6
- package/es/render/contributions/render/contributions/image-contribution-render.js +2 -52
- package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/es/render/contributions/render/image-render.js +12 -12
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/package.json +3 -3
|
@@ -209,4 +209,5 @@ let EmptyContext2d = class {
|
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
EmptyContext2d = __decorate([ (0, inversify_lite_1.injectable)(), __metadata("design:paramtypes", [ Object, Number ]) ], EmptyContext2d),
|
|
212
|
-
exports.EmptyContext2d = EmptyContext2d;
|
|
212
|
+
exports.EmptyContext2d = EmptyContext2d;
|
|
213
|
+
//# sourceMappingURL=empty-context.js.map
|
|
@@ -24,4 +24,4 @@ function bindContributionProviderNoSingletonScope(bind, id) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
exports.bindContributionProvider = bindContributionProvider, exports.bindContributionProviderNoSingletonScope = bindContributionProviderNoSingletonScope;
|
|
27
|
-
//# sourceMappingURL=contribution-provider.js.map
|
|
27
|
+
//# sourceMappingURL=contribution-provider.js.map
|
|
@@ -334,4 +334,4 @@ function scale(current, sX, sY) {
|
|
|
334
334
|
temp[7] = sY * current[7]; else if ("h" === c || "H" === c) temp[1] = sX * current[1]; else if ("v" === c || "V" === c) temp[1] = sY * current[1]; else for (let i = 1, n = current.length; i < n; ++i) temp[i] = (i % 2 == 1 ? sX : sY) * current[i];
|
|
335
335
|
return temp;
|
|
336
336
|
}
|
|
337
|
-
//# sourceMappingURL=custom-path2d.js.map
|
|
337
|
+
//# sourceMappingURL=custom-path2d.js.map
|
package/cjs/common/enums.js
CHANGED
|
@@ -46,4 +46,4 @@ function(Direction) {
|
|
|
46
46
|
BaseRenderContributionTime[BaseRenderContributionTime.beforeFillStroke = 0] = "beforeFillStroke",
|
|
47
47
|
BaseRenderContributionTime[BaseRenderContributionTime.afterFillStroke = 1] = "afterFillStroke";
|
|
48
48
|
}(BaseRenderContributionTime = exports.BaseRenderContributionTime || (exports.BaseRenderContributionTime = {}));
|
|
49
|
-
//# sourceMappingURL=enums.js.map
|
|
49
|
+
//# sourceMappingURL=enums.js.map
|
package/cjs/common/generator.js
CHANGED
package/cjs/common/matrix.js
CHANGED
|
@@ -129,4 +129,4 @@ exports.identityMat4 = identityMat4, exports.rotateX = rotateX, exports.rotateY
|
|
|
129
129
|
exports.rotateZ = rotateZ, exports.translate = translate, exports.mat3Tomat4 = mat3Tomat4,
|
|
130
130
|
exports.multiplyMat4Mat3 = multiplyMat4Mat3, exports.scaleMat4 = scaleMat4, exports.multiplyMat4Mat4 = multiplyMat4Mat4,
|
|
131
131
|
exports.lookAt = lookAt, exports.ortho = ortho, exports.transformMat4 = transformMat4;
|
|
132
|
-
//# sourceMappingURL=matrix.js.map
|
|
132
|
+
//# sourceMappingURL=matrix.js.map
|
|
@@ -292,4 +292,4 @@ function bezierCurversToPath(bezierCurves) {
|
|
|
292
292
|
|
|
293
293
|
exports.pathToBezierCurves = pathToBezierCurves, exports.applyTransformOnBezierCurves = applyTransformOnBezierCurves,
|
|
294
294
|
exports.bezierCurversToPath = bezierCurversToPath;
|
|
295
|
-
//# sourceMappingURL=morphing-utils.js.map
|
|
295
|
+
//# sourceMappingURL=morphing-utils.js.map
|
package/cjs/common/path-svg.js
CHANGED
package/cjs/common/polygon.js
CHANGED
|
@@ -39,8 +39,8 @@ function getProportionPoint(point, segment, length, dx, dy) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
//# sourceMappingURL=polygon.js.map
|
|
42
43
|
Object.defineProperty(exports, "__esModule", {
|
|
43
44
|
value: !0
|
|
44
45
|
}), exports.drawRoundedPolygon = exports.drawPolygon = void 0, exports.drawPolygon = drawPolygon,
|
|
45
|
-
exports.drawRoundedPolygon = drawRoundedPolygon;
|
|
46
|
-
//# sourceMappingURL=polygon.js.map
|
|
46
|
+
exports.drawRoundedPolygon = drawRoundedPolygon;
|
package/cjs/common/rect-utils.js
CHANGED
|
@@ -99,4 +99,4 @@ function drawIncrementalAreaSegments(path, lastSeg, segments, params) {
|
|
|
99
99
|
|
|
100
100
|
exports.drawSegments = drawSegments, exports.drawIncrementalSegments = drawIncrementalSegments,
|
|
101
101
|
exports.drawIncrementalAreaSegments = drawIncrementalAreaSegments;
|
|
102
|
-
//# sourceMappingURL=render-curve.js.map
|
|
102
|
+
//# sourceMappingURL=render-curve.js.map
|
package/cjs/common/simplify.js
CHANGED
|
@@ -36,4 +36,4 @@ function flatten_simplify(points, tolerance, highestQuality) {
|
|
|
36
36
|
Object.defineProperty(exports, "__esModule", {
|
|
37
37
|
value: !0
|
|
38
38
|
}), exports.flatten_simplify = void 0, exports.flatten_simplify = flatten_simplify;
|
|
39
|
-
//# sourceMappingURL=simplify.js.map
|
|
39
|
+
//# sourceMappingURL=simplify.js.map
|
package/cjs/common/sort.js
CHANGED
|
@@ -101,4 +101,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
101
101
|
value: !0
|
|
102
102
|
}), exports.findNextGraphic = exports.foreachAsync = exports.foreach = void 0, exports.foreach = foreach,
|
|
103
103
|
exports.foreachAsync = foreachAsync, exports.findNextGraphic = findNextGraphic;
|
|
104
|
-
//# sourceMappingURL=sort.js.map
|
|
104
|
+
//# sourceMappingURL=sort.js.map
|
package/cjs/common/split-path.js
CHANGED
package/cjs/common/store.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
class StageStore {}
|
|
2
|
-
//# sourceMappingURL=store.js.map
|
|
2
|
+
//# sourceMappingURL=store.js.map
|
package/cjs/core/application.js
CHANGED
package/cjs/core/camera.js
CHANGED
package/cjs/core/constants.js
CHANGED
|
@@ -7,4 +7,4 @@ exports.TransformUtil = Symbol.for("TransformUtil"), exports.GraphicUtil = Symbo
|
|
|
7
7
|
exports.LayerService = Symbol.for("LayerService"), exports.StaticLayerHandlerContribution = Symbol.for("StaticLayerHandlerContribution"),
|
|
8
8
|
exports.DynamicLayerHandlerContribution = Symbol.for("DynamicLayerHandlerContribution"),
|
|
9
9
|
exports.VirtualLayerHandlerContribution = Symbol.for("VirtualLayerHandlerContribution");
|
|
10
|
-
//# sourceMappingURL=constants.js.map
|
|
10
|
+
//# sourceMappingURL=constants.js.map
|
package/cjs/core/core-modules.js
CHANGED
|
@@ -12,4 +12,4 @@ exports.default = new inversify_lite_1.ContainerModule((bind => {
|
|
|
12
12
|
bind(constants_1.TransformUtil).to(graphic_utils_1.DefaultTransformUtil).inSingletonScope(),
|
|
13
13
|
bind(constants_1.LayerService).to(layer_service_1.DefaultLayerService).inSingletonScope();
|
|
14
14
|
}));
|
|
15
|
-
//# sourceMappingURL=core-modules.js.map
|
|
15
|
+
//# sourceMappingURL=core-modules.js.map
|
package/cjs/core/global.js
CHANGED
|
@@ -208,4 +208,4 @@ DefaultGlobal = __decorate([ (0, inversify_lite_1.injectable)(), __param(0, (0,
|
|
|
208
208
|
inversify_lite_1.inject)(contribution_provider_1.ContributionProvider)), __param(0, (0,
|
|
209
209
|
inversify_lite_1.named)(constants_1.EnvContribution)), __metadata("design:paramtypes", [ Object ]) ], DefaultGlobal),
|
|
210
210
|
exports.DefaultGlobal = DefaultGlobal;
|
|
211
|
-
//# sourceMappingURL=global.js.map
|
|
211
|
+
//# sourceMappingURL=global.js.map
|
|
@@ -172,4 +172,4 @@ let DefaultTransformUtil = class {
|
|
|
172
172
|
|
|
173
173
|
DefaultTransformUtil = __decorate([ (0, inversify_lite_1.injectable)(), __metadata("design:paramtypes", []) ], DefaultTransformUtil),
|
|
174
174
|
exports.DefaultTransformUtil = DefaultTransformUtil;
|
|
175
|
-
//# sourceMappingURL=graphic-utils.js.map
|
|
175
|
+
//# sourceMappingURL=graphic-utils.js.map
|
package/cjs/core/index.js
CHANGED
|
@@ -22,4 +22,4 @@ __exportStar(require("./layer"), exports), __exportStar(require("./stage"), expo
|
|
|
22
22
|
__exportStar(require("./graphic-utils"), exports), __exportStar(require("./contributions"), exports),
|
|
23
23
|
__exportStar(require("./layer-service"), exports), __exportStar(require("./constants"), exports),
|
|
24
24
|
__exportStar(require("../interface/core"), exports);
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -80,4 +80,4 @@ let DefaultLayerService = DefaultLayerService_1 = class {
|
|
|
80
80
|
DefaultLayerService.idprefix = "visactor_layer", DefaultLayerService.prefix_count = 0,
|
|
81
81
|
DefaultLayerService = DefaultLayerService_1 = __decorate([ (0, inversify_lite_1.injectable)(), __metadata("design:paramtypes", []) ], DefaultLayerService),
|
|
82
82
|
exports.DefaultLayerService = DefaultLayerService;
|
|
83
|
-
//# sourceMappingURL=layer-service.js.map
|
|
83
|
+
//# sourceMappingURL=layer-service.js.map
|
package/cjs/core/layer.js
CHANGED
package/cjs/core/light.js
CHANGED
|
@@ -28,4 +28,5 @@ const registerDirectionalLight = () => {
|
|
|
28
28
|
factory_1.Factory.registerPlugin("DirectionalLight", DirectionalLight);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
exports.registerDirectionalLight = registerDirectionalLight;
|
|
31
|
+
exports.registerDirectionalLight = registerDirectionalLight;
|
|
32
|
+
//# sourceMappingURL=light.js.map
|
package/cjs/core/stage.js
CHANGED
package/cjs/core/window.js
CHANGED
|
@@ -153,4 +153,4 @@ let DefaultWindow = class {
|
|
|
153
153
|
|
|
154
154
|
DefaultWindow = __decorate([ (0, inversify_lite_1.injectable)(), __metadata("design:paramtypes", []) ], DefaultWindow),
|
|
155
155
|
exports.DefaultWindow = DefaultWindow;
|
|
156
|
-
//# sourceMappingURL=window.js.map
|
|
156
|
+
//# sourceMappingURL=window.js.map
|
package/cjs/event/constant.js
CHANGED
package/cjs/event/index.js
CHANGED
|
@@ -21,4 +21,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
21
21
|
__exportStar(require("./event-target"), exports), __exportStar(require("./event-system"), exports),
|
|
22
22
|
__exportStar(require("../interface/event"), exports), __exportStar(require("./util"), exports),
|
|
23
23
|
__exportStar(require("./constant"), exports);
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/event/util.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type { IGraphicAttribute, IContext2d,
|
|
1
|
+
import type { IGraphicAttribute, IContext2d, IThemeAttribute, IImageRenderContribution, IDrawContext, IMarkAttribute } from '../../../../interface';
|
|
2
2
|
import { DefaultBaseBackgroundRenderContribution } from './base-contribution-render';
|
|
3
3
|
import { BaseRenderContributionTime } from '../../../../common/enums';
|
|
4
4
|
import { DefaultRectRenderContribution } from './rect-contribution-render';
|
|
5
|
-
export declare class DefaultImageBackgroundRenderContribution extends DefaultBaseBackgroundRenderContribution implements IImageRenderContribution {
|
|
6
|
-
time: BaseRenderContributionTime;
|
|
7
|
-
drawShape(graphic: IImage, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, graphicAttribute: Required<IGraphicAttribute>, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
8
|
-
}
|
|
9
5
|
export declare class DefaultImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {
|
|
10
6
|
time: BaseRenderContributionTime;
|
|
11
7
|
useStyle: boolean;
|
|
@@ -13,4 +9,4 @@ export declare class DefaultImageRenderContribution extends DefaultRectRenderCon
|
|
|
13
9
|
drawShape(rect: 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;
|
|
14
10
|
}
|
|
15
11
|
export declare const defaultImageRenderContribution: DefaultImageRenderContribution;
|
|
16
|
-
export declare const defaultImageBackgroundRenderContribution:
|
|
12
|
+
export declare const defaultImageBackgroundRenderContribution: DefaultBaseBackgroundRenderContribution;
|
|
@@ -2,54 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.defaultImageBackgroundRenderContribution = exports.defaultImageRenderContribution = exports.DefaultImageRenderContribution =
|
|
5
|
+
}), exports.defaultImageBackgroundRenderContribution = exports.defaultImageRenderContribution = exports.DefaultImageRenderContribution = void 0;
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
class DefaultImageBackgroundRenderContribution extends base_contribution_render_1.DefaultBaseBackgroundRenderContribution {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments), this.time = enums_1.BaseRenderContributionTime.beforeFillStroke;
|
|
12
|
-
}
|
|
13
|
-
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
|
|
14
|
-
const {background: background, backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit, width: width, height: height} = graphic.attribute;
|
|
15
|
-
if (background) if (graphic.backgroundImg) {
|
|
16
|
-
const res = graphic.resources.get(background);
|
|
17
|
-
if ("success" !== res.state || !res.data) return;
|
|
18
|
-
if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
|
|
19
|
-
const groupAttribute = (0, theme_1.getTheme)(graphic.parent).group, {scrollX: scrollX = groupAttribute.scrollX, scrollY: scrollY = groupAttribute.scrollY} = graphic.parent.attribute;
|
|
20
|
-
context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.translate(scrollX, scrollY);
|
|
21
|
-
}
|
|
22
|
-
const b = graphic.AABBBounds;
|
|
23
|
-
this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.restore(),
|
|
24
|
-
graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
|
|
25
|
-
} else if ((0, vutils_1.isObject)(background)) {
|
|
26
|
-
const {stroke: stroke, fill: fill, lineWidth: lineWidth = 1, cornerRadius: cornerRadius = 0, expandX: expandX = 0, expandY: expandY = 0} = background;
|
|
27
|
-
if (!stroke && !fill) return;
|
|
28
|
-
context.beginPath();
|
|
29
|
-
const {x: x, y: y, width: width, height: height} = getActualPosition(graphic);
|
|
30
|
-
cornerRadius ? (0, rect_1.createRectPath)(context, x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY, cornerRadius) : context.rect(x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY),
|
|
31
|
-
context.globalAlpha = 1, fill && (context.fillStyle = fill, context.fill()), stroke && lineWidth > 0 && (context.lineWidth = lineWidth,
|
|
32
|
-
context.strokeStyle = stroke, context.stroke());
|
|
33
|
-
} else context.beginPath(), context.rect(x, y, width || 0, height || 0), context.fillStyle = background,
|
|
34
|
-
context.globalAlpha = 1, context.fill();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getActualPosition(graphic) {
|
|
39
|
-
const boundsPadding = (0, utils_1.parsePadding)(graphic.attribute.boundsPadding), bounds = graphic.AABBBounds;
|
|
40
|
-
let x = bounds.x1, y = bounds.y1, width = bounds.width(), height = bounds.height();
|
|
41
|
-
return (0, vutils_1.isNumber)(boundsPadding) ? (x += boundsPadding, y += boundsPadding,
|
|
42
|
-
width -= 2 * boundsPadding, height -= 2 * boundsPadding) : (x += boundsPadding[3],
|
|
43
|
-
y += boundsPadding[0], width -= boundsPadding[1] + boundsPadding[3], height -= boundsPadding[0] + boundsPadding[2]),
|
|
44
|
-
{
|
|
45
|
-
x: x,
|
|
46
|
-
y: y,
|
|
47
|
-
width: width,
|
|
48
|
-
height: height
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
exports.DefaultImageBackgroundRenderContribution = DefaultImageBackgroundRenderContribution;
|
|
7
|
+
const base_contribution_render_1 = require("./base-contribution-render"), enums_1 = require("../../../../common/enums"), rect_contribution_render_1 = require("./rect-contribution-render");
|
|
53
8
|
|
|
54
9
|
class DefaultImageRenderContribution extends rect_contribution_render_1.DefaultRectRenderContribution {
|
|
55
10
|
constructor() {
|
|
@@ -62,5 +17,5 @@ class DefaultImageRenderContribution extends rect_contribution_render_1.DefaultR
|
|
|
62
17
|
}
|
|
63
18
|
|
|
64
19
|
exports.DefaultImageRenderContribution = DefaultImageRenderContribution, exports.defaultImageRenderContribution = new DefaultImageRenderContribution,
|
|
65
|
-
exports.defaultImageBackgroundRenderContribution =
|
|
20
|
+
exports.defaultImageBackgroundRenderContribution = base_contribution_render_1.defaultBaseBackgroundRenderContribution;
|
|
66
21
|
//# sourceMappingURL=image-contribution-render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/contributions/image-contribution-render.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/contributions/image-contribution-render.ts"],"names":[],"mappings":";;;AAYA,yEAGoC;AACpC,oDAAsE;AAItE,yEAA2E;AA+H3E,MAAa,8BAA+B,SAAQ,wDAA6B;IAAjF;;QACE,SAAI,GAA+B,kCAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAsCpB,CAAC;IArCC,SAAS,CACP,IAAS,EACT,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,aAAkB,EAClB,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,OAAO,KAAK,CAAC,SAAS,CACpB,IAAI,EACJ,OAAO,EACP,CAAC,EACD,CAAC,EACD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,WAAW,EACX,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AAzCD,wEAyCC;AAEY,QAAA,8BAA8B,GAAG,IAAI,8BAA8B,EAAE,CAAC;AACtE,QAAA,wCAAwC,GAAG,kEAAuC,CAAC","file":"image-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IImage,\n IThemeAttribute,\n IImageRenderContribution,\n IDrawContext,\n IBackgroundConfig,\n IGraphic,\n IMarkAttribute\n} from '../../../../interface';\nimport { getTheme } from '../../../../graphic/theme';\nimport {\n defaultBaseBackgroundRenderContribution,\n DefaultBaseBackgroundRenderContribution\n} from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { isNumber, isObject } from '@visactor/vutils';\nimport { parsePadding } from '../../../../common/utils';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { DefaultRectRenderContribution } from './rect-contribution-render';\n\n// export class DefaultImageBackgroundRenderContribution\n// extends DefaultBaseBackgroundRenderContribution\n// implements IImageRenderContribution\n// {\n// time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n// drawShape(\n// graphic: IImage,\n// context: IContext2d,\n// x: number,\n// y: number,\n// doFill: boolean,\n// doStroke: boolean,\n// fVisible: boolean,\n// sVisible: boolean,\n// graphicAttribute: Required<IGraphicAttribute>,\n// drawContext: IDrawContext,\n// fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n// strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n// ) {\n// const {\n// background,\n// backgroundMode = graphicAttribute.backgroundMode,\n// backgroundFit = graphicAttribute.backgroundFit,\n// width,\n// height\n// } = graphic.attribute;\n// if (!background) {\n// return;\n// }\n\n// if (!graphic.backgroundImg) {\n// if (isObject(background)) {\n// const {\n// stroke,\n// fill,\n// lineWidth = 1,\n// cornerRadius = 0,\n// expandX = 0,\n// expandY = 0\n// } = background as IBackgroundConfig;\n\n// if (!stroke && !fill) {\n// return;\n// }\n\n// context.beginPath();\n// const { x, y, width, height } = getActualPosition(graphic);\n// if (cornerRadius) {\n// createRectPath(context, x - expandX, y - expandY, width + expandX * 2, height + expandY * 2, cornerRadius);\n// } else {\n// context.rect(x - expandX, y - expandY, width + expandX * 2, height + expandY * 2);\n// }\n\n// context.globalAlpha = 1;\n// if (fill) {\n// context.fillStyle = fill as string;\n// context.fill();\n// }\n\n// if (stroke && lineWidth > 0) {\n// context.lineWidth = lineWidth;\n// context.strokeStyle = stroke as string;\n// context.stroke();\n// }\n// } else {\n// context.beginPath();\n// // const b = graphic.AABBBounds;\n// // image的背景不包括Bounds了\n// context.rect(x, y, width || 0, height || 0);\n// context.fillStyle = background as string;\n// context.globalAlpha = 1;\n// context.fill();\n// }\n// } else {\n// const res = graphic.resources.get(background as any);\n// if (res.state !== 'success' || !res.data) {\n// return;\n// }\n// context.save();\n// if (graphic.parent && !graphic.transMatrix.onlyTranslate()) {\n// const groupAttribute = getTheme(graphic.parent).group;\n// const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = graphic.parent.attribute;\n// context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n// context.translate(scrollX, scrollY);\n// }\n// // context.clip();\n// const b = graphic.AABBBounds;\n// this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit);\n// context.restore();\n// if (!graphic.transMatrix.onlyTranslate()) {\n// context.setTransformForCurrent();\n// }\n// }\n// }\n// }\n\n// function getActualPosition(graphic: IGraphic) {\n// const boundsPadding = parsePadding(graphic.attribute.boundsPadding);\n// const bounds = graphic.AABBBounds;\n// let x = bounds.x1;\n// let y = bounds.y1;\n// let width = bounds.width();\n// let height = bounds.height();\n\n// if (isNumber(boundsPadding)) {\n// x += boundsPadding;\n// y += boundsPadding;\n// width -= boundsPadding * 2;\n// height -= boundsPadding * 2;\n// } else {\n// x += boundsPadding[3];\n// y += boundsPadding[0];\n// width -= boundsPadding[1] + boundsPadding[3];\n// height -= boundsPadding[0] + boundsPadding[2];\n// }\n\n// return {\n// x,\n// y,\n// width,\n// height\n// };\n// }\n\nexport class DefaultImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: 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 return super.drawShape(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n}\n\nexport const defaultImageRenderContribution = new DefaultImageRenderContribution();\nexport const defaultImageBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
|
|
@@ -28,17 +28,17 @@ let DefaultCanvasImageRender = class extends base_render_1.BaseRender {
|
|
|
28
28
|
const imageAttribute = (0, theme_1.getTheme)(image).image, {width: width = imageAttribute.width, height: height = imageAttribute.height, repeatX: repeatX = imageAttribute.repeatX, repeatY: repeatY = imageAttribute.repeatY, x: originX = imageAttribute.x, y: originY = imageAttribute.y, cornerRadius: cornerRadius = imageAttribute.cornerRadius, fillStrokeOrder: fillStrokeOrder = imageAttribute.fillStrokeOrder, image: url} = image.attribute, data = this.valid(image, imageAttribute, fillCb);
|
|
29
29
|
if (!data) return;
|
|
30
30
|
const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
if (!url || !image.resources) return;
|
|
32
|
+
const res = image.resources.get(url);
|
|
33
|
+
if ("success" !== res.state) return;
|
|
34
|
+
let needRestore = !1;
|
|
35
|
+
0 === cornerRadius || (0, vutils_1.isArray)(cornerRadius) && cornerRadius.every((num => 0 === num)) || (context.beginPath(),
|
|
36
|
+
(0, rect_1.createRectPath)(context, x, y, width, height, cornerRadius), context.save(),
|
|
37
|
+
context.clip(), needRestore = !0), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb),
|
|
38
|
+
context.setShadowBlendStyle && context.setShadowBlendStyle(image, image.attribute, imageAttribute);
|
|
33
39
|
const _runFill = () => {
|
|
34
40
|
if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute); else if (fVisible) {
|
|
35
|
-
|
|
36
|
-
const res = image.resources.get(url);
|
|
37
|
-
if ("success" !== res.state) return;
|
|
38
|
-
let needRestore = !1;
|
|
39
|
-
0 === cornerRadius || (0, vutils_1.isArray)(cornerRadius) && cornerRadius.every((num => 0 === num)) || (context.beginPath(),
|
|
40
|
-
(0, rect_1.createRectPath)(context, x, y, width, height, cornerRadius), context.save(),
|
|
41
|
-
context.clip(), needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
|
|
41
|
+
context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
|
|
42
42
|
let repeat = 0;
|
|
43
43
|
if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2),
|
|
44
44
|
repeat) {
|
|
@@ -46,13 +46,13 @@ let DefaultCanvasImageRender = class extends base_render_1.BaseRender {
|
|
|
46
46
|
context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height),
|
|
47
47
|
context.translate(-x, -y, !0);
|
|
48
48
|
} else context.drawImage(res.data, x, y, width, height);
|
|
49
|
-
needRestore && context.restore();
|
|
50
49
|
}
|
|
51
50
|
}, _runStroke = () => {
|
|
52
51
|
doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute),
|
|
53
|
-
context.
|
|
52
|
+
context.stroke()));
|
|
54
53
|
};
|
|
55
|
-
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb)
|
|
54
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb),
|
|
55
|
+
needRestore && context.restore();
|
|
56
56
|
}
|
|
57
57
|
draw(image, renderService, drawContext) {
|
|
58
58
|
const {image: url} = image.attribute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/image-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAE3E,iFAA6E;AAC7E,kDAAkD;AAclD,yDAAoE;AAEpE,0DAA+D;AAE/D,6CAAqD;AACrD,qDAA4D;AAC5D,+CAA2C;AAC3C,mDAA2G;AAC3G,4DAAiE;AAEjE,MAAM,SAAS,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAGlD,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,wBAAkB;IAI9D,YAGqB,wBAAyE;QAE5F,KAAK,EAAE,CAAC;QAFW,6BAAwB,GAAxB,wBAAwB,CAAiD;QAL9F,eAAU,GAAW,6BAAiB,CAAC;QAQrC,IAAI,CAAC,oBAAoB,GAAG,CAAC,8CAA8B,EAAE,wDAAwC,CAAC,CAAC;QACvG,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACtC,CAAC;IAED,SAAS,CACP,KAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAGZ,MAAM,cAAc,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QAC7C,MAAM,EACJ,KAAK,GAAG,cAAc,CAAC,KAAK,EAC5B,MAAM,GAAG,cAAc,CAAC,MAAM,EAC9B,OAAO,GAAG,cAAc,CAAC,OAAO,EAChC,OAAO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AI,IAAA,iBAAQ,EAAC,GAAG,CAAC,EAAE;YAC5C,uBAAc,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;YACxC,OAAO;SACR;aAAM,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE;YAClC,OAAO;SACR;QAED,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,UAAU,CAAC;QAC7C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QACD,MAAM,cAAc,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AA3JY,wBAAwB;IADpC,IAAA,2BAAU,GAAE;IAMR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,mCAAuB,CAAC,CAAA;;GANtB,wBAAwB,CA2JpC;AA3JY,4DAAwB","file":"image-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IImage,\n IThemeAttribute,\n IGraphicRender,\n IImageRenderContribution,\n IContributionProvider,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { ImageRenderContribution } from './contributions/constants';\nimport { fillVisible, runFill } from './utils';\nimport { IMAGE_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { isArray, isString } from '@visactor/vutils';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { BaseRender } from './base-render';\nimport { defaultImageBackgroundRenderContribution, defaultImageRenderContribution } from './contributions';\nimport { ResourceLoader } from '../../../resource-loader/loader';\n\nconst repeatStr = ['', 'repeat-x', 'repeat-y', 'repeat'];\n\n@injectable()\nexport class DefaultCanvasImageRender extends BaseRender<IImage> implements IGraphicRender {\n type: 'image';\n numberType: number = IMAGE_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(ImageRenderContribution)\n protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution];\n this.init(imageRenderContribitions);\n }\n\n drawShape(\n image: IImage,\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 width = imageAttribute.width,\n height = imageAttribute.height,\n repeatX = imageAttribute.repeatX,\n repeatY = imageAttribute.repeatY,\n x: originX = imageAttribute.x,\n y: originY = imageAttribute.y,\n cornerRadius = imageAttribute.cornerRadius,\n fillStrokeOrder = imageAttribute.fillStrokeOrder,\n image: url\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 // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(image, image.attribute, imageAttribute);\n\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n\n // context.beginPath();\n // context.image(x, y, width, height);\n\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, image.attribute, imageAttribute);\n } else if (fVisible) {\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n if (res.state !== 'success') {\n return;\n }\n\n // deal with cornerRadius\n let needRestore = false;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n } else {\n context.beginPath();\n createRectPath(context, x, y, width, height, cornerRadius);\n context.save();\n context.clip();\n needRestore = true;\n }\n\n context.setCommonStyle(image, image.attribute, x, y, imageAttribute);\n let repeat = 0;\n if (repeatX === 'repeat') {\n repeat |= 0b0001;\n }\n if (repeatY === 'repeat') {\n repeat |= 0b0010;\n }\n if (repeat) {\n const pattern = context.createPattern(res.data, repeatStr[repeat]);\n context.fillStyle = pattern;\n context.translate(x, y, true);\n context.fillRect(0, 0, width, height);\n context.translate(-x, -y, true);\n } else {\n context.drawImage(res.data, x, y, width, height);\n }\n\n if (needRestore) {\n context.restore();\n }\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.strokeRect(x, y, width, height);\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this.afterRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n }\n\n draw(image: IImage, renderService: IRenderService, drawContext: IDrawContext) {\n const { image: url } = image.attribute;\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n // if (res.state !== 'success') {\n // return;\n // }\n if (res.state === 'loading' && isString(url)) {\n ResourceLoader.improveImageLoading(url);\n return;\n } else if (res.state !== 'success') {\n return;\n }\n\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"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/image-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAE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AC;CACF,CAAA;AA1JY,wBAAwB;IADpC,IAAA,2BAAU,GAAE;IAMR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,mCAAuB,CAAC,CAAA;;GANtB,wBAAwB,CA0JpC;AA1JY,4DAAwB","file":"image-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IImage,\n IThemeAttribute,\n IGraphicRender,\n IImageRenderContribution,\n IContributionProvider,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { ImageRenderContribution } from './contributions/constants';\nimport { fillVisible, runFill } from './utils';\nimport { IMAGE_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { isArray, isString } from '@visactor/vutils';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { BaseRender } from './base-render';\nimport { defaultImageBackgroundRenderContribution, defaultImageRenderContribution } from './contributions';\nimport { ResourceLoader } from '../../../resource-loader/loader';\n\nconst repeatStr = ['', 'repeat-x', 'repeat-y', 'repeat'];\n\n@injectable()\nexport class DefaultCanvasImageRender extends BaseRender<IImage> implements IGraphicRender {\n type: 'image';\n numberType: number = IMAGE_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(ImageRenderContribution)\n protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution];\n this.init(imageRenderContribitions);\n }\n\n drawShape(\n image: IImage,\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 width = imageAttribute.width,\n height = imageAttribute.height,\n repeatX = imageAttribute.repeatX,\n repeatY = imageAttribute.repeatY,\n x: originX = imageAttribute.x,\n y: originY = imageAttribute.y,\n cornerRadius = imageAttribute.cornerRadius,\n fillStrokeOrder = imageAttribute.fillStrokeOrder,\n image: url\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 if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n if (res.state !== 'success') {\n return;\n }\n\n // deal with cornerRadius\n let needRestore = false;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n } else {\n context.beginPath();\n createRectPath(context, x, y, width, height, cornerRadius);\n context.save();\n context.clip();\n needRestore = true;\n }\n\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(image, image.attribute, imageAttribute);\n // context.beginPath();\n // context.image(x, y, width, height);\n\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, image.attribute, imageAttribute);\n } else if (fVisible) {\n context.setCommonStyle(image, image.attribute, x, y, imageAttribute);\n let repeat = 0;\n if (repeatX === 'repeat') {\n repeat |= 0b0001;\n }\n if (repeatY === 'repeat') {\n repeat |= 0b0010;\n }\n if (repeat) {\n const pattern = context.createPattern(res.data, repeatStr[repeat]);\n context.fillStyle = pattern;\n context.translate(x, y, true);\n context.fillRect(0, 0, width, height);\n context.translate(-x, -y, true);\n } else {\n context.drawImage(res.data, x, y, width, height);\n }\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 _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this.afterRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n\n if (needRestore) {\n context.restore();\n }\n }\n\n draw(image: IImage, renderService: IRenderService, drawContext: IDrawContext) {\n const { image: url } = image.attribute;\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n // if (res.state !== 'success') {\n // return;\n // }\n if (res.state === 'loading' && isString(url)) {\n ResourceLoader.improveImageLoading(url);\n return;\n } else if (res.state !== 'success') {\n return;\n }\n\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"]}
|