zrender-nightly 5.5.0-dev.20221018 → 5.5.0-dev.20221019
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/build/prepareNightly.js +12 -2
- package/dist/zrender.js +103 -43
- package/dist/zrender.js.map +1 -1
- package/dist/zrender.min.js +1 -1
- package/lib/canvas/Layer.js +6 -1
- package/lib/graphic/Gradient.d.ts +2 -0
- package/lib/svg/Painter.d.ts +4 -1
- package/lib/svg/Painter.js +51 -34
- package/lib/svg/graphic.d.ts +3 -1
- package/lib/svg/graphic.js +49 -11
- package/lib/svg/helper.js +1 -1
- package/lib/zrender.d.ts +1 -1
- package/lib/zrender.js +1 -1
- package/package.json +2 -2
- package/src/canvas/Layer.ts +9 -1
- package/src/graphic/Gradient.ts +2 -0
- package/src/svg/Painter.ts +72 -41
- package/src/svg/graphic.ts +53 -13
- package/src/svg/helper.ts +1 -1
- package/src/zrender.ts +1 -1
package/src/svg/graphic.ts
CHANGED
|
@@ -123,7 +123,7 @@ function createAttrsConvert(desc: ShapeMapDesc): ConvertShapeToAttr {
|
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
const
|
|
126
|
+
const builtinShapesDef: Record<string, [ConvertShapeToAttr, ShapeValidator?]> = {
|
|
127
127
|
circle: [createAttrsConvert(['cx', 'cy', 'r'])],
|
|
128
128
|
polyline: [convertPolyShape, validatePolyShape],
|
|
129
129
|
polygon: [convertPolyShape, validatePolyShape]
|
|
@@ -149,7 +149,7 @@ function hasShapeAnimation(el: Displayable) {
|
|
|
149
149
|
export function brushSVGPath(el: Path, scope: BrushScope) {
|
|
150
150
|
const style = el.style;
|
|
151
151
|
const shape = el.shape;
|
|
152
|
-
const builtinShpDef =
|
|
152
|
+
const builtinShpDef = builtinShapesDef[el.type];
|
|
153
153
|
const attrs: SVGVNodeAttrs = {};
|
|
154
154
|
const needsAnimate = scope.animation;
|
|
155
155
|
let svgElType = 'path';
|
|
@@ -266,8 +266,8 @@ export function brushSVGTSpan(el: TSpan, scope: BrushScope) {
|
|
|
266
266
|
// style.font has been normalized by `normalizeTextStyle`.
|
|
267
267
|
const font = style.font || DEFAULT_FONT;
|
|
268
268
|
|
|
269
|
-
// Consider different font display differently in
|
|
270
|
-
// set
|
|
269
|
+
// Consider different font display differently in vertical align, we always
|
|
270
|
+
// set verticalAlign as 'middle', and use 'y' to locate text vertically.
|
|
271
271
|
const x = style.x || 0;
|
|
272
272
|
const y = adjustTextY(style.y || 0, getLineHeight(font), style.textBaseline);
|
|
273
273
|
const textAlign = TEXT_ALIGN_TO_ANCHOR[style.textAlign as keyof typeof TEXT_ALIGN_TO_ANCHOR]
|
|
@@ -388,7 +388,7 @@ function setShadow(
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
function setGradient(
|
|
391
|
+
export function setGradient(
|
|
392
392
|
style: PathStyleProps,
|
|
393
393
|
attrs: SVGVNodeAttrs,
|
|
394
394
|
target: 'fill' | 'stroke',
|
|
@@ -467,16 +467,19 @@ function setGradient(
|
|
|
467
467
|
attrs[target] = getIdURL(gradientId);
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
function setPattern(
|
|
470
|
+
export function setPattern(
|
|
471
471
|
el: Displayable,
|
|
472
472
|
attrs: SVGVNodeAttrs,
|
|
473
473
|
target: 'fill' | 'stroke',
|
|
474
474
|
scope: BrushScope
|
|
475
475
|
) {
|
|
476
476
|
const val = el.style[target] as ImagePatternObject | SVGPatternObject;
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
477
|
+
const boundingRect = el.getBoundingRect();
|
|
478
|
+
const patternAttrs: SVGVNodeAttrs = {};
|
|
479
|
+
const repeat = (val as ImagePatternObject).repeat;
|
|
480
|
+
const noRepeat = repeat === 'no-repeat';
|
|
481
|
+
const repeatX = repeat === 'repeat-x';
|
|
482
|
+
const repeatY = repeat === 'repeat-y';
|
|
480
483
|
let child: SVGVNode;
|
|
481
484
|
if (isImagePattern(val)) {
|
|
482
485
|
let imageWidth = val.imageWidth;
|
|
@@ -503,8 +506,20 @@ function setPattern(
|
|
|
503
506
|
const setSizeToVNode = (vNode: SVGVNode, img: ImageLike) => {
|
|
504
507
|
if (vNode) {
|
|
505
508
|
const svgEl = vNode.elm as SVGElement;
|
|
506
|
-
|
|
507
|
-
|
|
509
|
+
let width = imageWidth || img.width;
|
|
510
|
+
let height = imageHeight || img.height;
|
|
511
|
+
if (vNode.tag === 'pattern') {
|
|
512
|
+
if (repeatX) {
|
|
513
|
+
height = 1;
|
|
514
|
+
width /= boundingRect.width;
|
|
515
|
+
}
|
|
516
|
+
else if (repeatY) {
|
|
517
|
+
width = 1;
|
|
518
|
+
height /= boundingRect.height;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
vNode.attrs.width = width;
|
|
522
|
+
vNode.attrs.height = height;
|
|
508
523
|
if (svgEl) {
|
|
509
524
|
svgEl.setAttribute('width', width as any);
|
|
510
525
|
svgEl.setAttribute('height', height as any);
|
|
@@ -513,7 +528,7 @@ function setPattern(
|
|
|
513
528
|
};
|
|
514
529
|
const createdImage = createOrUpdateImage(
|
|
515
530
|
imageSrc, null, el, (img) => {
|
|
516
|
-
setSizeToVNode(patternVNode, img);
|
|
531
|
+
noRepeat || setSizeToVNode(patternVNode, img);
|
|
517
532
|
setSizeToVNode(child, img);
|
|
518
533
|
}
|
|
519
534
|
);
|
|
@@ -546,7 +561,32 @@ function setPattern(
|
|
|
546
561
|
return;
|
|
547
562
|
}
|
|
548
563
|
|
|
549
|
-
|
|
564
|
+
let patternWidth;
|
|
565
|
+
let patternHeight;
|
|
566
|
+
if (noRepeat) {
|
|
567
|
+
patternWidth = patternHeight = 1;
|
|
568
|
+
}
|
|
569
|
+
else if (repeatX) {
|
|
570
|
+
patternHeight = 1;
|
|
571
|
+
patternWidth = (patternAttrs.width as number) / boundingRect.width;
|
|
572
|
+
}
|
|
573
|
+
else if (repeatY) {
|
|
574
|
+
patternWidth = 1;
|
|
575
|
+
patternHeight = (patternAttrs.height as number) / boundingRect.height;
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
patternAttrs.patternUnits = 'userSpaceOnUse';
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (patternWidth != null && !isNaN(patternWidth)) {
|
|
582
|
+
patternAttrs.width = patternWidth;
|
|
583
|
+
}
|
|
584
|
+
if (patternHeight != null && !isNaN(patternHeight)) {
|
|
585
|
+
patternAttrs.height = patternHeight;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
const patternTransform = getSRTTransformString(val);
|
|
589
|
+
patternTransform && (patternAttrs.patternTransform = patternTransform);
|
|
550
590
|
|
|
551
591
|
// Use the whole html as cache key.
|
|
552
592
|
let patternVNode = createVNode(
|
package/src/svg/helper.ts
CHANGED
|
@@ -175,7 +175,7 @@ export function getSRTTransformString(
|
|
|
175
175
|
export const encodeBase64 = (function () {
|
|
176
176
|
if (env.hasGlobalWindow && isFunction(window.btoa)) {
|
|
177
177
|
return function (str: string) {
|
|
178
|
-
return window.btoa(unescape(str));
|
|
178
|
+
return window.btoa(unescape(encodeURIComponent(str)));
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
if (typeof Buffer !== 'undefined') {
|
package/src/zrender.ts
CHANGED
|
@@ -485,7 +485,7 @@ export function registerPainter(name: string, Ctor: PainterBaseCtor) {
|
|
|
485
485
|
/**
|
|
486
486
|
* @type {string}
|
|
487
487
|
*/
|
|
488
|
-
export const version = '5.
|
|
488
|
+
export const version = '5.5.0-dev.20221019';
|
|
489
489
|
|
|
490
490
|
|
|
491
491
|
export interface ZRenderType extends ZRender {};
|