逐步完成前后端服务器
This commit is contained in:
15
frontend/node_modules/zrender/lib/svg-legacy/helper/ClippathManager.d.ts
generated
vendored
Normal file
15
frontend/node_modules/zrender/lib/svg-legacy/helper/ClippathManager.d.ts
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
import Definable from './Definable';
|
||||
import Displayable from '../../graphic/Displayable';
|
||||
import Path from '../../graphic/Path';
|
||||
export declare function hasClipPath(displayable: Displayable): boolean;
|
||||
export default class ClippathManager extends Definable {
|
||||
private _refGroups;
|
||||
private _keyDuplicateCount;
|
||||
constructor(zrId: number, svgRoot: SVGElement);
|
||||
markAllUnused(): void;
|
||||
private _getClipPathGroup;
|
||||
update(displayable: Displayable, prevDisplayable: Displayable): SVGElement;
|
||||
updateDom(parentEl: SVGElement, clipPaths: Path[]): void;
|
||||
markUsed(displayable: Displayable): void;
|
||||
removeUnused(): void;
|
||||
}
|
121
frontend/node_modules/zrender/lib/svg-legacy/helper/ClippathManager.js
generated
vendored
Normal file
121
frontend/node_modules/zrender/lib/svg-legacy/helper/ClippathManager.js
generated
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
import { __extends } from "tslib";
|
||||
import Definable from './Definable.js';
|
||||
import * as zrUtil from '../../core/util.js';
|
||||
import { path } from '../graphic.js';
|
||||
import { isClipPathChanged } from '../../canvas/helper.js';
|
||||
import { getClipPathsKey, getIdURL } from '../../svg/helper.js';
|
||||
import { createElement } from '../../svg/core.js';
|
||||
export function hasClipPath(displayable) {
|
||||
var clipPaths = displayable.__clipPaths;
|
||||
return clipPaths && clipPaths.length > 0;
|
||||
}
|
||||
var ClippathManager = (function (_super) {
|
||||
__extends(ClippathManager, _super);
|
||||
function ClippathManager(zrId, svgRoot) {
|
||||
var _this = _super.call(this, zrId, svgRoot, 'clipPath', '__clippath_in_use__') || this;
|
||||
_this._refGroups = {};
|
||||
_this._keyDuplicateCount = {};
|
||||
return _this;
|
||||
}
|
||||
ClippathManager.prototype.markAllUnused = function () {
|
||||
_super.prototype.markAllUnused.call(this);
|
||||
var refGroups = this._refGroups;
|
||||
for (var key in refGroups) {
|
||||
if (refGroups.hasOwnProperty(key)) {
|
||||
this.markDomUnused(refGroups[key]);
|
||||
}
|
||||
}
|
||||
this._keyDuplicateCount = {};
|
||||
};
|
||||
ClippathManager.prototype._getClipPathGroup = function (displayable, prevDisplayable) {
|
||||
if (!hasClipPath(displayable)) {
|
||||
return;
|
||||
}
|
||||
var clipPaths = displayable.__clipPaths;
|
||||
var keyDuplicateCount = this._keyDuplicateCount;
|
||||
var clipPathKey = getClipPathsKey(clipPaths);
|
||||
if (isClipPathChanged(clipPaths, prevDisplayable && prevDisplayable.__clipPaths)) {
|
||||
keyDuplicateCount[clipPathKey] = keyDuplicateCount[clipPathKey] || 0;
|
||||
keyDuplicateCount[clipPathKey] && (clipPathKey += '-' + keyDuplicateCount[clipPathKey]);
|
||||
keyDuplicateCount[clipPathKey]++;
|
||||
}
|
||||
return this._refGroups[clipPathKey]
|
||||
|| (this._refGroups[clipPathKey] = createElement('g'));
|
||||
};
|
||||
ClippathManager.prototype.update = function (displayable, prevDisplayable) {
|
||||
var clipGroup = this._getClipPathGroup(displayable, prevDisplayable);
|
||||
if (clipGroup) {
|
||||
this.markDomUsed(clipGroup);
|
||||
this.updateDom(clipGroup, displayable.__clipPaths);
|
||||
}
|
||||
return clipGroup;
|
||||
};
|
||||
;
|
||||
ClippathManager.prototype.updateDom = function (parentEl, clipPaths) {
|
||||
if (clipPaths && clipPaths.length > 0) {
|
||||
var defs = this.getDefs(true);
|
||||
var clipPath = clipPaths[0];
|
||||
var clipPathEl = void 0;
|
||||
var id = void 0;
|
||||
if (clipPath._dom) {
|
||||
id = clipPath._dom.getAttribute('id');
|
||||
clipPathEl = clipPath._dom;
|
||||
if (!defs.contains(clipPathEl)) {
|
||||
defs.appendChild(clipPathEl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
id = 'zr' + this._zrId + '-clip-' + this.nextId;
|
||||
++this.nextId;
|
||||
clipPathEl = createElement('clipPath');
|
||||
clipPathEl.setAttribute('id', id);
|
||||
defs.appendChild(clipPathEl);
|
||||
clipPath._dom = clipPathEl;
|
||||
}
|
||||
path.brush(clipPath);
|
||||
var pathEl = this.getSvgElement(clipPath);
|
||||
clipPathEl.innerHTML = '';
|
||||
clipPathEl.appendChild(pathEl);
|
||||
parentEl.setAttribute('clip-path', getIdURL(id));
|
||||
if (clipPaths.length > 1) {
|
||||
this.updateDom(clipPathEl, clipPaths.slice(1));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (parentEl) {
|
||||
parentEl.setAttribute('clip-path', 'none');
|
||||
}
|
||||
}
|
||||
};
|
||||
;
|
||||
ClippathManager.prototype.markUsed = function (displayable) {
|
||||
var _this = this;
|
||||
if (displayable.__clipPaths) {
|
||||
zrUtil.each(displayable.__clipPaths, function (clipPath) {
|
||||
if (clipPath._dom) {
|
||||
_super.prototype.markDomUsed.call(_this, clipPath._dom);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
;
|
||||
ClippathManager.prototype.removeUnused = function () {
|
||||
_super.prototype.removeUnused.call(this);
|
||||
var newRefGroupsMap = {};
|
||||
var refGroups = this._refGroups;
|
||||
for (var key in refGroups) {
|
||||
if (refGroups.hasOwnProperty(key)) {
|
||||
var group = refGroups[key];
|
||||
if (!this.isDomUnused(group)) {
|
||||
newRefGroupsMap[key] = group;
|
||||
}
|
||||
else if (group.parentNode) {
|
||||
group.parentNode.removeChild(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
this._refGroups = newRefGroupsMap;
|
||||
};
|
||||
return ClippathManager;
|
||||
}(Definable));
|
||||
export default ClippathManager;
|
22
frontend/node_modules/zrender/lib/svg-legacy/helper/Definable.d.ts
generated
vendored
Normal file
22
frontend/node_modules/zrender/lib/svg-legacy/helper/Definable.d.ts
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import Displayable from '../../graphic/Displayable';
|
||||
export default class Definable {
|
||||
nextId: number;
|
||||
protected _zrId: number;
|
||||
protected _svgRoot: SVGElement;
|
||||
protected _tagNames: string[];
|
||||
protected _markLabel: string;
|
||||
protected _domName: string;
|
||||
constructor(zrId: number, svgRoot: SVGElement, tagNames: string | string[], markLabel: string, domName?: string);
|
||||
getDefs(isForceCreating?: boolean): SVGDefsElement;
|
||||
doUpdate<T>(target: T, onUpdate?: (target: T) => void): void;
|
||||
add(target: any): SVGElement;
|
||||
addDom(dom: SVGElement): void;
|
||||
removeDom<T>(target: T): void;
|
||||
getDoms(): SVGElement[];
|
||||
markAllUnused(): void;
|
||||
markDomUsed(dom: SVGElement): void;
|
||||
markDomUnused(dom: SVGElement): void;
|
||||
isDomUnused(dom: SVGElement): boolean;
|
||||
removeUnused(): void;
|
||||
getSvgElement(displayable: Displayable): SVGElement;
|
||||
}
|
130
frontend/node_modules/zrender/lib/svg-legacy/helper/Definable.js
generated
vendored
Normal file
130
frontend/node_modules/zrender/lib/svg-legacy/helper/Definable.js
generated
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
import { createElement } from '../../svg/core.js';
|
||||
import * as zrUtil from '../../core/util.js';
|
||||
var MARK_UNUSED = '0';
|
||||
var MARK_USED = '1';
|
||||
var Definable = (function () {
|
||||
function Definable(zrId, svgRoot, tagNames, markLabel, domName) {
|
||||
this.nextId = 0;
|
||||
this._domName = '_dom';
|
||||
this._zrId = zrId;
|
||||
this._svgRoot = svgRoot;
|
||||
this._tagNames = typeof tagNames === 'string' ? [tagNames] : tagNames;
|
||||
this._markLabel = markLabel;
|
||||
if (domName) {
|
||||
this._domName = domName;
|
||||
}
|
||||
}
|
||||
Definable.prototype.getDefs = function (isForceCreating) {
|
||||
var svgRoot = this._svgRoot;
|
||||
var defs = this._svgRoot.getElementsByTagName('defs');
|
||||
if (defs.length === 0) {
|
||||
if (isForceCreating) {
|
||||
var defs_1 = svgRoot.insertBefore(createElement('defs'), svgRoot.firstChild);
|
||||
if (!defs_1.contains) {
|
||||
defs_1.contains = function (el) {
|
||||
var children = defs_1.children;
|
||||
if (!children) {
|
||||
return false;
|
||||
}
|
||||
for (var i = children.length - 1; i >= 0; --i) {
|
||||
if (children[i] === el) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
return defs_1;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return defs[0];
|
||||
}
|
||||
};
|
||||
Definable.prototype.doUpdate = function (target, onUpdate) {
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
var defs = this.getDefs(false);
|
||||
if (target[this._domName] && defs.contains(target[this._domName])) {
|
||||
if (typeof onUpdate === 'function') {
|
||||
onUpdate(target);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var dom = this.add(target);
|
||||
if (dom) {
|
||||
target[this._domName] = dom;
|
||||
}
|
||||
}
|
||||
};
|
||||
Definable.prototype.add = function (target) {
|
||||
return null;
|
||||
};
|
||||
Definable.prototype.addDom = function (dom) {
|
||||
var defs = this.getDefs(true);
|
||||
if (dom.parentNode !== defs) {
|
||||
defs.appendChild(dom);
|
||||
}
|
||||
};
|
||||
Definable.prototype.removeDom = function (target) {
|
||||
var defs = this.getDefs(false);
|
||||
if (defs && target[this._domName]) {
|
||||
defs.removeChild(target[this._domName]);
|
||||
target[this._domName] = null;
|
||||
}
|
||||
};
|
||||
Definable.prototype.getDoms = function () {
|
||||
var defs = this.getDefs(false);
|
||||
if (!defs) {
|
||||
return [];
|
||||
}
|
||||
var doms = [];
|
||||
zrUtil.each(this._tagNames, function (tagName) {
|
||||
var tags = defs.getElementsByTagName(tagName);
|
||||
for (var i = 0; i < tags.length; i++) {
|
||||
doms.push(tags[i]);
|
||||
}
|
||||
});
|
||||
return doms;
|
||||
};
|
||||
Definable.prototype.markAllUnused = function () {
|
||||
var doms = this.getDoms();
|
||||
var that = this;
|
||||
zrUtil.each(doms, function (dom) {
|
||||
dom[that._markLabel] = MARK_UNUSED;
|
||||
});
|
||||
};
|
||||
Definable.prototype.markDomUsed = function (dom) {
|
||||
dom && (dom[this._markLabel] = MARK_USED);
|
||||
};
|
||||
;
|
||||
Definable.prototype.markDomUnused = function (dom) {
|
||||
dom && (dom[this._markLabel] = MARK_UNUSED);
|
||||
};
|
||||
;
|
||||
Definable.prototype.isDomUnused = function (dom) {
|
||||
return dom && dom[this._markLabel] !== MARK_USED;
|
||||
};
|
||||
Definable.prototype.removeUnused = function () {
|
||||
var _this = this;
|
||||
var defs = this.getDefs(false);
|
||||
if (!defs) {
|
||||
return;
|
||||
}
|
||||
var doms = this.getDoms();
|
||||
zrUtil.each(doms, function (dom) {
|
||||
if (_this.isDomUnused(dom)) {
|
||||
defs.removeChild(dom);
|
||||
}
|
||||
});
|
||||
};
|
||||
Definable.prototype.getSvgElement = function (displayable) {
|
||||
return displayable.__svgEl;
|
||||
};
|
||||
return Definable;
|
||||
}());
|
||||
export default Definable;
|
11
frontend/node_modules/zrender/lib/svg-legacy/helper/GradientManager.d.ts
generated
vendored
Normal file
11
frontend/node_modules/zrender/lib/svg-legacy/helper/GradientManager.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import Definable from './Definable';
|
||||
import Displayable from '../../graphic/Displayable';
|
||||
import { GradientObject } from '../../graphic/Gradient';
|
||||
export default class GradientManager extends Definable {
|
||||
constructor(zrId: number, svgRoot: SVGElement);
|
||||
addWithoutUpdate(svgElement: SVGElement, displayable: Displayable): void;
|
||||
add(gradient: GradientObject): SVGElement;
|
||||
update(gradient: GradientObject | string): void;
|
||||
updateDom(gradient: GradientObject, dom: SVGElement): void;
|
||||
markUsed(displayable: Displayable): void;
|
||||
}
|
128
frontend/node_modules/zrender/lib/svg-legacy/helper/GradientManager.js
generated
vendored
Normal file
128
frontend/node_modules/zrender/lib/svg-legacy/helper/GradientManager.js
generated
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
import { __extends } from "tslib";
|
||||
import Definable from './Definable.js';
|
||||
import * as zrUtil from '../../core/util.js';
|
||||
import { getIdURL, isGradient, isLinearGradient, isRadialGradient, normalizeColor, round4 } from '../../svg/helper.js';
|
||||
import { createElement } from '../../svg/core.js';
|
||||
var GradientManager = (function (_super) {
|
||||
__extends(GradientManager, _super);
|
||||
function GradientManager(zrId, svgRoot) {
|
||||
return _super.call(this, zrId, svgRoot, ['linearGradient', 'radialGradient'], '__gradient_in_use__') || this;
|
||||
}
|
||||
GradientManager.prototype.addWithoutUpdate = function (svgElement, displayable) {
|
||||
if (displayable && displayable.style) {
|
||||
var that_1 = this;
|
||||
zrUtil.each(['fill', 'stroke'], function (fillOrStroke) {
|
||||
var value = displayable.style[fillOrStroke];
|
||||
if (isGradient(value)) {
|
||||
var gradient = value;
|
||||
var defs = that_1.getDefs(true);
|
||||
var dom = void 0;
|
||||
if (gradient.__dom) {
|
||||
dom = gradient.__dom;
|
||||
if (!defs.contains(gradient.__dom)) {
|
||||
that_1.addDom(dom);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dom = that_1.add(gradient);
|
||||
}
|
||||
that_1.markUsed(displayable);
|
||||
svgElement.setAttribute(fillOrStroke, getIdURL(dom.getAttribute('id')));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
GradientManager.prototype.add = function (gradient) {
|
||||
var dom;
|
||||
if (isLinearGradient(gradient)) {
|
||||
dom = createElement('linearGradient');
|
||||
}
|
||||
else if (isRadialGradient(gradient)) {
|
||||
dom = createElement('radialGradient');
|
||||
}
|
||||
else {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
zrUtil.logError('Illegal gradient type.');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
gradient.id = gradient.id || this.nextId++;
|
||||
dom.setAttribute('id', 'zr' + this._zrId
|
||||
+ '-gradient-' + gradient.id);
|
||||
this.updateDom(gradient, dom);
|
||||
this.addDom(dom);
|
||||
return dom;
|
||||
};
|
||||
GradientManager.prototype.update = function (gradient) {
|
||||
if (!isGradient(gradient)) {
|
||||
return;
|
||||
}
|
||||
var that = this;
|
||||
this.doUpdate(gradient, function () {
|
||||
var dom = gradient.__dom;
|
||||
if (!dom) {
|
||||
return;
|
||||
}
|
||||
var tagName = dom.tagName;
|
||||
var type = gradient.type;
|
||||
if (type === 'linear' && tagName === 'linearGradient'
|
||||
|| type === 'radial' && tagName === 'radialGradient') {
|
||||
that.updateDom(gradient, gradient.__dom);
|
||||
}
|
||||
else {
|
||||
that.removeDom(gradient);
|
||||
that.add(gradient);
|
||||
}
|
||||
});
|
||||
};
|
||||
GradientManager.prototype.updateDom = function (gradient, dom) {
|
||||
if (isLinearGradient(gradient)) {
|
||||
dom.setAttribute('x1', gradient.x);
|
||||
dom.setAttribute('y1', gradient.y);
|
||||
dom.setAttribute('x2', gradient.x2);
|
||||
dom.setAttribute('y2', gradient.y2);
|
||||
}
|
||||
else if (isRadialGradient(gradient)) {
|
||||
dom.setAttribute('cx', gradient.x);
|
||||
dom.setAttribute('cy', gradient.y);
|
||||
dom.setAttribute('r', gradient.r);
|
||||
}
|
||||
else {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
zrUtil.logError('Illegal gradient type.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
dom.setAttribute('gradientUnits', gradient.global
|
||||
? 'userSpaceOnUse'
|
||||
: 'objectBoundingBox');
|
||||
dom.innerHTML = '';
|
||||
var colors = gradient.colorStops;
|
||||
for (var i = 0, len = colors.length; i < len; ++i) {
|
||||
var stop_1 = createElement('stop');
|
||||
stop_1.setAttribute('offset', round4(colors[i].offset) * 100 + '%');
|
||||
var stopColor = colors[i].color;
|
||||
var _a = normalizeColor(stopColor), color = _a.color, opacity = _a.opacity;
|
||||
stop_1.setAttribute('stop-color', color);
|
||||
if (opacity < 1) {
|
||||
stop_1.setAttribute('stop-opacity', opacity);
|
||||
}
|
||||
dom.appendChild(stop_1);
|
||||
}
|
||||
gradient.__dom = dom;
|
||||
};
|
||||
GradientManager.prototype.markUsed = function (displayable) {
|
||||
if (displayable.style) {
|
||||
var gradient = displayable.style.fill;
|
||||
if (gradient && gradient.__dom) {
|
||||
_super.prototype.markDomUsed.call(this, gradient.__dom);
|
||||
}
|
||||
gradient = displayable.style.stroke;
|
||||
if (gradient && gradient.__dom) {
|
||||
_super.prototype.markDomUsed.call(this, gradient.__dom);
|
||||
}
|
||||
}
|
||||
};
|
||||
return GradientManager;
|
||||
}(Definable));
|
||||
export default GradientManager;
|
11
frontend/node_modules/zrender/lib/svg-legacy/helper/PatternManager.d.ts
generated
vendored
Normal file
11
frontend/node_modules/zrender/lib/svg-legacy/helper/PatternManager.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import Definable from './Definable';
|
||||
import Displayable from '../../graphic/Displayable';
|
||||
import { PatternObject } from '../../graphic/Pattern';
|
||||
export default class PatternManager extends Definable {
|
||||
constructor(zrId: number, svgRoot: SVGElement);
|
||||
addWithoutUpdate(svgElement: SVGElement, displayable: Displayable): void;
|
||||
add(pattern: PatternObject): SVGElement;
|
||||
update(pattern: PatternObject | string): void;
|
||||
updateDom(pattern: PatternObject, patternDom: SVGElement): void;
|
||||
markUsed(displayable: Displayable): void;
|
||||
}
|
127
frontend/node_modules/zrender/lib/svg-legacy/helper/PatternManager.js
generated
vendored
Normal file
127
frontend/node_modules/zrender/lib/svg-legacy/helper/PatternManager.js
generated
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
import { __extends } from "tslib";
|
||||
import Definable from './Definable.js';
|
||||
import * as zrUtil from '../../core/util.js';
|
||||
import { createOrUpdateImage } from '../../graphic/helper/image.js';
|
||||
import WeakMap from '../../core/WeakMap.js';
|
||||
import { getIdURL, isPattern, isSVGPattern } from '../../svg/helper.js';
|
||||
import { createElement } from '../../svg/core.js';
|
||||
var patternDomMap = new WeakMap();
|
||||
var PatternManager = (function (_super) {
|
||||
__extends(PatternManager, _super);
|
||||
function PatternManager(zrId, svgRoot) {
|
||||
return _super.call(this, zrId, svgRoot, ['pattern'], '__pattern_in_use__') || this;
|
||||
}
|
||||
PatternManager.prototype.addWithoutUpdate = function (svgElement, displayable) {
|
||||
if (displayable && displayable.style) {
|
||||
var that_1 = this;
|
||||
zrUtil.each(['fill', 'stroke'], function (fillOrStroke) {
|
||||
var pattern = displayable.style[fillOrStroke];
|
||||
if (isPattern(pattern)) {
|
||||
var defs = that_1.getDefs(true);
|
||||
var dom = patternDomMap.get(pattern);
|
||||
if (dom) {
|
||||
if (!defs.contains(dom)) {
|
||||
that_1.addDom(dom);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dom = that_1.add(pattern);
|
||||
}
|
||||
that_1.markUsed(displayable);
|
||||
svgElement.setAttribute(fillOrStroke, getIdURL(dom.getAttribute('id')));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
PatternManager.prototype.add = function (pattern) {
|
||||
if (!isPattern(pattern)) {
|
||||
return;
|
||||
}
|
||||
var dom = createElement('pattern');
|
||||
pattern.id = pattern.id == null ? this.nextId++ : pattern.id;
|
||||
dom.setAttribute('id', 'zr' + this._zrId
|
||||
+ '-pattern-' + pattern.id);
|
||||
dom.setAttribute('patternUnits', 'userSpaceOnUse');
|
||||
this.updateDom(pattern, dom);
|
||||
this.addDom(dom);
|
||||
return dom;
|
||||
};
|
||||
PatternManager.prototype.update = function (pattern) {
|
||||
if (!isPattern(pattern)) {
|
||||
return;
|
||||
}
|
||||
var that = this;
|
||||
this.doUpdate(pattern, function () {
|
||||
var dom = patternDomMap.get(pattern);
|
||||
that.updateDom(pattern, dom);
|
||||
});
|
||||
};
|
||||
PatternManager.prototype.updateDom = function (pattern, patternDom) {
|
||||
if (isSVGPattern(pattern)) {
|
||||
}
|
||||
else {
|
||||
var img = void 0;
|
||||
var prevImage = patternDom.getElementsByTagName('image');
|
||||
if (prevImage.length) {
|
||||
if (pattern.image) {
|
||||
img = prevImage[0];
|
||||
}
|
||||
else {
|
||||
patternDom.removeChild(prevImage[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (pattern.image) {
|
||||
img = createElement('image');
|
||||
}
|
||||
if (img) {
|
||||
var imageSrc = void 0;
|
||||
var patternImage = pattern.image;
|
||||
if (typeof patternImage === 'string') {
|
||||
imageSrc = patternImage;
|
||||
}
|
||||
else if (patternImage instanceof HTMLImageElement) {
|
||||
imageSrc = patternImage.src;
|
||||
}
|
||||
else if (patternImage instanceof HTMLCanvasElement) {
|
||||
imageSrc = patternImage.toDataURL();
|
||||
}
|
||||
if (imageSrc) {
|
||||
img.setAttribute('href', imageSrc);
|
||||
var hostEl = {
|
||||
dirty: function () { }
|
||||
};
|
||||
var updateSize = function (img) {
|
||||
patternDom.setAttribute('width', img.width);
|
||||
patternDom.setAttribute('height', img.height);
|
||||
};
|
||||
var createdImage = createOrUpdateImage(imageSrc, img, hostEl, updateSize);
|
||||
if (createdImage && createdImage.width && createdImage.height) {
|
||||
updateSize(createdImage);
|
||||
}
|
||||
patternDom.appendChild(img);
|
||||
}
|
||||
}
|
||||
}
|
||||
var x = pattern.x || 0;
|
||||
var y = pattern.y || 0;
|
||||
var rotation = (pattern.rotation || 0) / Math.PI * 180;
|
||||
var scaleX = pattern.scaleX || 1;
|
||||
var scaleY = pattern.scaleY || 1;
|
||||
var transform = "translate(" + x + ", " + y + ") rotate(" + rotation + ") scale(" + scaleX + ", " + scaleY + ")";
|
||||
patternDom.setAttribute('patternTransform', transform);
|
||||
patternDomMap.set(pattern, patternDom);
|
||||
};
|
||||
PatternManager.prototype.markUsed = function (displayable) {
|
||||
if (displayable.style) {
|
||||
if (isPattern(displayable.style.fill)) {
|
||||
_super.prototype.markDomUsed.call(this, patternDomMap.get(displayable.style.fill));
|
||||
}
|
||||
if (isPattern(displayable.style.stroke)) {
|
||||
_super.prototype.markDomUsed.call(this, patternDomMap.get(displayable.style.stroke));
|
||||
}
|
||||
}
|
||||
};
|
||||
return PatternManager;
|
||||
}(Definable));
|
||||
export default PatternManager;
|
12
frontend/node_modules/zrender/lib/svg-legacy/helper/ShadowManager.d.ts
generated
vendored
Normal file
12
frontend/node_modules/zrender/lib/svg-legacy/helper/ShadowManager.d.ts
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
import Definable from './Definable';
|
||||
import Displayable from '../../graphic/Displayable';
|
||||
export default class ShadowManager extends Definable {
|
||||
private _shadowDomMap;
|
||||
private _shadowDomPool;
|
||||
constructor(zrId: number, svgRoot: SVGElement);
|
||||
private _getFromPool;
|
||||
update(svgElement: SVGElement, displayable: Displayable): void;
|
||||
remove(svgElement: SVGElement, displayable: Displayable): void;
|
||||
updateDom(svgElement: SVGElement, displayable: Displayable, shadowDom: SVGElement): void;
|
||||
removeUnused(): void;
|
||||
}
|
89
frontend/node_modules/zrender/lib/svg-legacy/helper/ShadowManager.js
generated
vendored
Normal file
89
frontend/node_modules/zrender/lib/svg-legacy/helper/ShadowManager.js
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
import { __extends } from "tslib";
|
||||
import Definable from './Definable.js';
|
||||
import { getIdURL, getShadowKey, hasShadow, normalizeColor } from '../../svg/helper.js';
|
||||
import { createElement } from '../../svg/core.js';
|
||||
var ShadowManager = (function (_super) {
|
||||
__extends(ShadowManager, _super);
|
||||
function ShadowManager(zrId, svgRoot) {
|
||||
var _this = _super.call(this, zrId, svgRoot, ['filter'], '__filter_in_use__', '_shadowDom') || this;
|
||||
_this._shadowDomMap = {};
|
||||
_this._shadowDomPool = [];
|
||||
return _this;
|
||||
}
|
||||
ShadowManager.prototype._getFromPool = function () {
|
||||
var shadowDom = this._shadowDomPool.pop();
|
||||
if (!shadowDom) {
|
||||
shadowDom = createElement('filter');
|
||||
shadowDom.setAttribute('id', 'zr' + this._zrId + '-shadow-' + this.nextId++);
|
||||
var domChild = createElement('feDropShadow');
|
||||
shadowDom.appendChild(domChild);
|
||||
this.addDom(shadowDom);
|
||||
}
|
||||
return shadowDom;
|
||||
};
|
||||
ShadowManager.prototype.update = function (svgElement, displayable) {
|
||||
var style = displayable.style;
|
||||
if (hasShadow(style)) {
|
||||
var shadowKey = getShadowKey(displayable);
|
||||
var shadowDom = displayable._shadowDom = this._shadowDomMap[shadowKey];
|
||||
if (!shadowDom) {
|
||||
shadowDom = this._getFromPool();
|
||||
this._shadowDomMap[shadowKey] = shadowDom;
|
||||
}
|
||||
this.updateDom(svgElement, displayable, shadowDom);
|
||||
}
|
||||
else {
|
||||
this.remove(svgElement, displayable);
|
||||
}
|
||||
};
|
||||
ShadowManager.prototype.remove = function (svgElement, displayable) {
|
||||
if (displayable._shadowDom != null) {
|
||||
displayable._shadowDom = null;
|
||||
svgElement.removeAttribute('filter');
|
||||
}
|
||||
};
|
||||
ShadowManager.prototype.updateDom = function (svgElement, displayable, shadowDom) {
|
||||
var domChild = shadowDom.children[0];
|
||||
var style = displayable.style;
|
||||
var globalScale = displayable.getGlobalScale();
|
||||
var scaleX = globalScale[0];
|
||||
var scaleY = globalScale[1];
|
||||
if (!scaleX || !scaleY) {
|
||||
return;
|
||||
}
|
||||
var offsetX = style.shadowOffsetX || 0;
|
||||
var offsetY = style.shadowOffsetY || 0;
|
||||
var blur = style.shadowBlur;
|
||||
var normalizedColor = normalizeColor(style.shadowColor);
|
||||
domChild.setAttribute('dx', offsetX / scaleX + '');
|
||||
domChild.setAttribute('dy', offsetY / scaleY + '');
|
||||
domChild.setAttribute('flood-color', normalizedColor.color);
|
||||
domChild.setAttribute('flood-opacity', normalizedColor.opacity + '');
|
||||
var stdDx = blur / 2 / scaleX;
|
||||
var stdDy = blur / 2 / scaleY;
|
||||
var stdDeviation = stdDx + ' ' + stdDy;
|
||||
domChild.setAttribute('stdDeviation', stdDeviation);
|
||||
shadowDom.setAttribute('x', '-100%');
|
||||
shadowDom.setAttribute('y', '-100%');
|
||||
shadowDom.setAttribute('width', '300%');
|
||||
shadowDom.setAttribute('height', '300%');
|
||||
displayable._shadowDom = shadowDom;
|
||||
svgElement.setAttribute('filter', getIdURL(shadowDom.getAttribute('id')));
|
||||
};
|
||||
ShadowManager.prototype.removeUnused = function () {
|
||||
var defs = this.getDefs(false);
|
||||
if (!defs) {
|
||||
return;
|
||||
}
|
||||
var shadowDomsPool = this._shadowDomPool;
|
||||
var shadowDomMap = this._shadowDomMap;
|
||||
for (var key in shadowDomMap) {
|
||||
if (shadowDomMap.hasOwnProperty(key)) {
|
||||
shadowDomsPool.push(shadowDomMap[key]);
|
||||
}
|
||||
}
|
||||
this._shadowDomMap = {};
|
||||
};
|
||||
return ShadowManager;
|
||||
}(Definable));
|
||||
export default ShadowManager;
|
Reference in New Issue
Block a user