@antv/g 5.16.9 → 5.16.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/dist/index.umd.js +39 -26
- package/dist/index.umd.min.js +1 -1
- package/package.json +4 -4
package/dist/index.umd.js
CHANGED
|
@@ -7833,7 +7833,8 @@
|
|
|
7833
7833
|
// }
|
|
7834
7834
|
// return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
|
|
7835
7835
|
// });
|
|
7836
|
-
var parseLengthOrPercentage=function parseLengthOrPercentage(css){if(isNumber(css)||isFinite(Number(css))){
|
|
7836
|
+
var parseLengthOrPercentage=function parseLengthOrPercentage(css){if(isNumber(css)||isFinite(Number(css))){// Number(css) is NaN
|
|
7837
|
+
return getOrCreateUnitValue(Number(css)||0,'px');// return Number(css);
|
|
7837
7838
|
}return parseDimension(new RegExp('px|%|em|rem','g'),css);};var parseAngle=memoize(function(css){return parseDimension(new RegExp('deg|rad|grad|turn','g'),css);});/**
|
|
7838
7839
|
* merge CSSUnitValue
|
|
7839
7840
|
*
|
|
@@ -7894,7 +7895,7 @@
|
|
|
7894
7895
|
*
|
|
7895
7896
|
* @example
|
|
7896
7897
|
* points="100,10 250,150 200,110"
|
|
7897
|
-
*/function parsePoints(pointsOrStr,object){var points;if(isString(pointsOrStr)){points=pointsOrStr.split(' ').map(function(pointStr){var _pointStr$split=pointStr.split(','),x=_pointStr$split[0],y=_pointStr$split[1];return [Number(x),Number(y)];});}else {points=pointsOrStr;}var segments=[];var tempLength=0;var segmentT;var segmentL;var totalLength=polyline.length(points);points.forEach(function(p,i){if(points[i+1]){segmentT=[0,0];segmentT[0]=tempLength/totalLength;segmentL=line.length(p[0],p[1],points[i+1][0],points[i+1][1]);tempLength+=segmentL;segmentT[1]=tempLength/totalLength;segments.push(segmentT);}});var minX=Math.min.apply(Math,points.map(function(point){return point[0];}));var minY=Math.min.apply(Math,points.map(function(point){return point[1];}));if(object){object.parsedStyle.defX=minX;object.parsedStyle.defY=minY;}return {points:points,totalLength:totalLength,segments:segments};}var _=null;function cast(pattern){return function(contents){var i=0;return pattern.map(function(x){return x===_?contents[i++]:x;});};}function id(x){return x;}// type: [argTypes, convertTo3D, convertTo2D]
|
|
7898
|
+
*/function parsePoints(pointsOrStr,object){var points;if(isString(pointsOrStr)){points=pointsOrStr.split(' ').map(function(pointStr){var _pointStr$split=pointStr.split(','),x=_pointStr$split[0],y=_pointStr$split[1];return [Number(x),Number(y)];});}else {points=pointsOrStr;}var segments=[];var tempLength=0;var segmentT;var segmentL;var totalLength=polyline.length(points);points.forEach(function(p,i){if(points[i+1]){segmentT=[0,0];segmentT[0]=tempLength/totalLength;segmentL=line.length(p[0],p[1],points[i+1][0],points[i+1][1]);tempLength+=segmentL;segmentT[1]=tempLength/totalLength;segments.push(segmentT);}});var minX=Math.min.apply(Math,points.map(function(point){return point[0];}));var minY=Math.min.apply(Math,points.map(function(point){return point[1];}));if(object){object.parsedStyle.defX=minX;object.parsedStyle.defY=minY;}return {points:points,totalLength:totalLength,segments:segments};}function mergePoints(left,right){return [left.points,right.points,function(points){return points;}];}var _=null;function cast(pattern){return function(contents){var i=0;return pattern.map(function(x){return x===_?contents[i++]:x;});};}function id(x){return x;}// type: [argTypes, convertTo3D, convertTo2D]
|
|
7898
7899
|
// In the argument types string, lowercase characters represent optional arguments
|
|
7899
7900
|
var transformFunctions={// @ts-ignore
|
|
7900
7901
|
matrix:['NNNNNN',[_,_,0,0,_,_,0,0,0,0,1,0,_,_,0,1],id],matrix3d:['NNNNNNNNNNNNNNNN',id],rotate:['A'],rotatex:['A'],rotatey:['A'],rotatez:['A'],rotate3d:['NNNA'],perspective:['L'],scale:['Nn',cast([_,_,new CSSUnitValue(1)]),id],scalex:['N',cast([_,new CSSUnitValue(1),new CSSUnitValue(1)]),cast([_,new CSSUnitValue(1)])],scaley:['N',cast([new CSSUnitValue(1),_,new CSSUnitValue(1)]),cast([new CSSUnitValue(1),_])],scalez:['N',cast([new CSSUnitValue(1),new CSSUnitValue(1),_])],scale3d:['NNN',id],skew:['Aa',null,id],skewx:['A',null,cast([_,Odeg])],skewy:['A',null,cast([Odeg,_])],translate:['Tt',cast([_,_,Opx]),id],translatex:['T',cast([_,Opx,Opx]),cast([_,Opx])],translatey:['T',cast([Opx,_,Opx]),cast([Opx,_])],translatez:['L',cast([Opx,Opx,_])],translate3d:['TTL',id]};/**
|
|
@@ -8075,7 +8076,7 @@
|
|
|
8075
8076
|
set$1(this.planes[5].normal,m3+m2,m7+m6,m11+m10);this.planes[5].distance=m15+m14;this.planes.forEach(function(plane){plane.normalize();plane.updatePNVertexFlag();});};return Frustum;}();var Point=/*#__PURE__*/function(){function Point(x,y){if(x===void 0){x=0;}if(y===void 0){y=0;}this.x=0;this.y=0;this.x=x;this.y=y;}var _proto=Point.prototype;_proto.clone=function clone(){return new Point(this.x,this.y);};_proto.copyFrom=function copyFrom(p){this.x=p.x;this.y=p.y;};return Point;}();var Rectangle=/*#__PURE__*/function(){function Rectangle(x,y,width,height){this.x=void 0;this.y=void 0;this.width=void 0;this.height=void 0;this.left=void 0;this.right=void 0;this.top=void 0;this.bottom=void 0;this.x=x;this.y=y;this.width=width;this.height=height;this.left=x;this.right=x+width;this.top=y;this.bottom=y+height;}var _proto=Rectangle.prototype;_proto.toJSON=function toJSON(){};return Rectangle;}();var CSSPropertyPath=/*#__PURE__*/function(){function CSSPropertyPath(){this.parser=parsePath;this.parserWithCSSDisabled=parsePath;this.mixer=mergePaths;}var _proto=CSSPropertyPath.prototype;_proto.calculator=function calculator(name,oldParsed,parsed){// unset
|
|
8076
8077
|
if(parsed instanceof CSSKeywordValue&&parsed.value==='unset'){return {absolutePath:[],hasArc:false,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Rectangle(0,0,0,0)};}return parsed;};/**
|
|
8077
8078
|
* update local position
|
|
8078
|
-
*/_proto.postProcessor=function postProcessor(object,attributes){if(object.nodeName===exports.Shape.PATH&&attributes.indexOf('transform')===-1){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;object.setLocalPosition(defX,defY);}};return CSSPropertyPath;}();var CSSPropertyPoints=/*#__PURE__*/function(){function CSSPropertyPoints(){this.parser=parsePoints;}var _proto=CSSPropertyPoints.prototype;/**
|
|
8079
|
+
*/_proto.postProcessor=function postProcessor(object,attributes){if(object.nodeName===exports.Shape.PATH&&attributes.indexOf('transform')===-1){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;object.setLocalPosition(defX,defY);}};return CSSPropertyPath;}();var CSSPropertyPoints=/*#__PURE__*/function(){function CSSPropertyPoints(){this.parser=parsePoints;this.mixer=mergePoints;}var _proto=CSSPropertyPoints.prototype;/**
|
|
8079
8080
|
* update local position
|
|
8080
8081
|
*/_proto.postProcessor=function postProcessor(object,attributes){if((object.nodeName===exports.Shape.POLYGON||object.nodeName===exports.Shape.POLYLINE)&&attributes.indexOf('transform')===-1){var _object$parsedStyle=object.parsedStyle,defX=_object$parsedStyle.defX,defY=_object$parsedStyle.defY;object.setLocalPosition(defX,defY);}};return CSSPropertyPoints;}();var CSSPropertyShadowBlur=/*#__PURE__*/function(_CSSPropertyLengthOrP){_inheritsLoose(CSSPropertyShadowBlur,_CSSPropertyLengthOrP);function CSSPropertyShadowBlur(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_CSSPropertyLengthOrP.call.apply(_CSSPropertyLengthOrP,[this].concat(args))||this;_this.mixer=clampedMergeNumbers(0,Infinity);return _this;}return CSSPropertyShadowBlur;}(CSSPropertyLengthOrPercentage);var CSSPropertyText=/*#__PURE__*/function(){function CSSPropertyText(){}var _proto=CSSPropertyText.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){if(parsed instanceof CSSKeywordValue){if(parsed.value==='unset'){return '';}else {return parsed.value;}}// allow number as valid text content
|
|
8081
8082
|
return ""+parsed;};_proto.postProcessor=function postProcessor(object){object.nodeValue=""+object.parsedStyle.text||'';};return CSSPropertyText;}();/**
|
|
@@ -8326,7 +8327,7 @@
|
|
|
8326
8327
|
// scaling: vec3.fromValues(1, 1, 1),
|
|
8327
8328
|
// worldTransform: mat4.create(),
|
|
8328
8329
|
// origin: vec3.fromValues(0, 0, 0),
|
|
8329
|
-
localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],origin:[0,0,0]};_this.sortable={dirty:false,sorted:undefined,lastSortedIndex:undefined,renderOrder:0};_this.geometry={
|
|
8330
|
+
localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],origin:[0,0,0]};_this.sortable={dirty:false,sorted:undefined,lastSortedIndex:undefined,renderOrder:0};_this.geometry={contentBounds:undefined,renderBounds:undefined};_this.rBushNode={aabb:undefined};_this.id=void 0;_this.name=void 0;_this.namespaceURI='g';_this.scrollLeft=0;_this.scrollTop=0;_this.clientTop=0;_this.clientLeft=0;_this.destroyed=false;_this.style={};_this.computedStyle=runtime.enableCSSParsing?{anchor:unsetKeywordValue,opacity:unsetKeywordValue,fillOpacity:unsetKeywordValue,strokeOpacity:unsetKeywordValue,fill:unsetKeywordValue,stroke:unsetKeywordValue,transform:unsetKeywordValue,transformOrigin:unsetKeywordValue,visibility:unsetKeywordValue,pointerEvents:unsetKeywordValue,lineWidth:unsetKeywordValue,lineCap:unsetKeywordValue,lineJoin:unsetKeywordValue,increasedLineWidthForHitTesting:unsetKeywordValue,fontSize:unsetKeywordValue,fontFamily:unsetKeywordValue,fontStyle:unsetKeywordValue,fontWeight:unsetKeywordValue,fontVariant:unsetKeywordValue,textAlign:unsetKeywordValue,textBaseline:unsetKeywordValue,textTransform:unsetKeywordValue,zIndex:unsetKeywordValue,filter:unsetKeywordValue,shadowType:unsetKeywordValue}:null;_this.parsedStyle={// opacity: '',
|
|
8330
8331
|
// fillOpacity: '',
|
|
8331
8332
|
// strokeOpacity: '',
|
|
8332
8333
|
// transformOrigin: '',
|
|
@@ -8485,7 +8486,7 @@
|
|
|
8485
8486
|
// };
|
|
8486
8487
|
if(_this.config.visible!=null){_this.config.style.visibility=_this.config.visible===false?'hidden':'visible';}if(_this.config.interactive!=null){_this.config.style.pointerEvents=_this.config.interactive===false?'none':'auto';}// merge parsed value
|
|
8487
8488
|
Object.assign(_this.parsedStyle,runtime.enableCSSParsing?DEFAULT_PARSED_STYLE_PROPS:DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED,_this.config.initialParsedStyle);if(runtime.enableCSSParsing){Object.assign(_this.attributes,DEFAULT_STYLE_PROPS);}// start to process attributes
|
|
8488
|
-
_this.initAttributes(_this.config.style);_this.dataset=new Proxy({},{get:function get(target,name){var formattedName=""+DATASET_PREFIX+kebabize(name);if(target[formattedName]!==undefined){return target[formattedName];}return _this.getAttribute(formattedName);},set:function set(_,prop,value){_this.setAttribute(""+DATASET_PREFIX+kebabize(prop),value);return true;}});_this.style=new Proxy(// @ts-ignore
|
|
8489
|
+
_this.initAttributes(_this.config.style);var Proxy=runtime.globalThis.Proxy?runtime.globalThis.Proxy:function(){};_this.dataset=new Proxy({},{get:function get(target,name){var formattedName=""+DATASET_PREFIX+kebabize(name);if(target[formattedName]!==undefined){return target[formattedName];}return _this.getAttribute(formattedName);},set:function set(_,prop,value){_this.setAttribute(""+DATASET_PREFIX+kebabize(prop),value);return true;}});_this.style=new Proxy(// @ts-ignore
|
|
8489
8490
|
{// ...this.attributes,
|
|
8490
8491
|
setProperty:function setProperty(propertyName,value){_this.setAttribute(propertyName,value);},getPropertyValue:function getPropertyValue(propertyName){return _this.getAttribute(propertyName);},removeProperty:function removeProperty(propertyName){_this.removeAttribute(propertyName);},item:function item(){return '';}},{get:function get(target,name){if(target[name]!==undefined){// if (name in target) {
|
|
8491
8492
|
return target[name];}return _this.getAttribute(name);},set:function set(_,prop,value){_this.setAttribute(prop,value);return true;}});// insert this group into pool
|
|
@@ -8722,7 +8723,7 @@
|
|
|
8722
8723
|
// }
|
|
8723
8724
|
/**
|
|
8724
8725
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
|
|
8725
|
-
*/var _proto=Text.prototype;_proto.getComputedTextLength=function getComputedTextLength(){var _this$parsedStyle$met;
|
|
8726
|
+
*/var _proto=Text.prototype;_proto.getComputedTextLength=function getComputedTextLength(){var _this$parsedStyle$met;return ((_this$parsedStyle$met=this.parsedStyle.metrics)===null||_this$parsedStyle$met===void 0?void 0:_this$parsedStyle$met.maxLineWidth)||0;}// getEndPositionOfChar(charnum: number): DOMPoint {
|
|
8726
8727
|
// throw new Error('Method not implemented.');
|
|
8727
8728
|
// }
|
|
8728
8729
|
// getExtentOfChar(charnum: number): DOMRect {
|
|
@@ -8743,7 +8744,7 @@
|
|
|
8743
8744
|
// selectSubString(charnum: number, nchars: number): void {
|
|
8744
8745
|
// throw new Error('Method not implemented.');
|
|
8745
8746
|
// }
|
|
8746
|
-
;_proto.getLineBoundingRects=function getLineBoundingRects(){var _this$parsedStyle$met2;
|
|
8747
|
+
;_proto.getLineBoundingRects=function getLineBoundingRects(){var _this$parsedStyle$met2;return ((_this$parsedStyle$met2=this.parsedStyle.metrics)===null||_this$parsedStyle$met2===void 0?void 0:_this$parsedStyle$met2.lineMetrics)||[];};_proto.isOverflowing=function isOverflowing(){return !!this.parsedStyle.isOverflowing;};return Text;}(DisplayObject);/**
|
|
8747
8748
|
* Blink used them in code generation(css_properties.json5)
|
|
8748
8749
|
*/var BUILT_IN_PROPERTIES=[{/**
|
|
8749
8750
|
* used in CSS Layout API
|
|
@@ -8784,7 +8785,9 @@
|
|
|
8784
8785
|
*/k:['auto','fit-content','min-content','max-content'],d:'0',syntax:exports.PropertySyntax.LENGTH_PERCENTAGE},{n:'radius',int:true,l:true,d:'0',syntax:exports.PropertySyntax.LENGTH_PERCENTAGE_14},// Line
|
|
8785
8786
|
{n:'x1',int:true,l:true,syntax:exports.PropertySyntax.COORDINATE},{n:'y1',int:true,l:true,syntax:exports.PropertySyntax.COORDINATE},{n:'z1',int:true,l:true,syntax:exports.PropertySyntax.COORDINATE},{n:'x2',int:true,l:true,syntax:exports.PropertySyntax.COORDINATE},{n:'y2',int:true,l:true,syntax:exports.PropertySyntax.COORDINATE},{n:'z2',int:true,l:true,syntax:exports.PropertySyntax.COORDINATE},// Path
|
|
8786
8787
|
{n:'path',int:true,l:true,d:'',a:['d'],syntax:exports.PropertySyntax.PATH,p:50},// Polyline & Polygon
|
|
8787
|
-
{n:'points'
|
|
8788
|
+
{n:'points',/**
|
|
8789
|
+
* support interpolation
|
|
8790
|
+
*/int:true,l:true,syntax:exports.PropertySyntax.LIST_OF_POINTS,p:50},// Text
|
|
8788
8791
|
{n:'text',l:true,d:'',syntax:exports.PropertySyntax.TEXT,p:50},{n:'textTransform',l:true,inh:true,k:['capitalize','uppercase','lowercase','none'],d:'none',syntax:exports.PropertySyntax.TEXT_TRANSFORM,p:51// it must get parsed after text
|
|
8789
8792
|
},{n:'font',l:true},{n:'fontSize',int:true,inh:true,/**
|
|
8790
8793
|
* @see https://www.w3schools.com/css/css_font_size.asp
|
|
@@ -8856,7 +8859,7 @@
|
|
|
8856
8859
|
!isNil(attributes.y2)||// @ts-ignore
|
|
8857
8860
|
!isNil(attributes.z2))){runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object,_attributeNames);}if(!isNil(attributes.zIndex)){runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object,_attributeNames);}// @ts-ignore
|
|
8858
8861
|
if(attributes.path){runtime.CSSPropertySyntaxFactory['<path>'].postProcessor(object,_attributeNames);}// @ts-ignore
|
|
8859
|
-
if(attributes.points){runtime.CSSPropertySyntaxFactory['<list-of-points>'].postProcessor(object,_attributeNames);}if(!isNil(attributes.offsetDistance)){runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object,_attributeNames);}if(attributes.transform){runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object,_attributeNames);}if(_needUpdateGeometry){
|
|
8862
|
+
if(attributes.points){runtime.CSSPropertySyntaxFactory['<list-of-points>'].postProcessor(object,_attributeNames);}if(!isNil(attributes.offsetDistance)){runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object,_attributeNames);}if(attributes.transform){runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object,_attributeNames);}if(_needUpdateGeometry){this.updateGeometry(object);}return;}var _options=options,skipUpdateAttribute=_options.skipUpdateAttribute,skipParse=_options.skipParse,forceUpdateGeometry=_options.forceUpdateGeometry,usedAttributes=_options.usedAttributes;var needUpdateGeometry=forceUpdateGeometry;var attributeNames=Object.keys(attributes);attributeNames.forEach(function(attributeName){var _propertyMetadataCach;var name=formatAttributeName(attributeName);if(!skipUpdateAttribute){object.attributes[name]=attributes[attributeName];}if(!needUpdateGeometry&&((_propertyMetadataCach=propertyMetadataCache[name])===null||_propertyMetadataCach===void 0?void 0:_propertyMetadataCach.l)){needUpdateGeometry=true;}});if(!skipParse){attributeNames.forEach(function(name){object.computedStyle[name]=_this2.parseProperty(name,object.attributes[name],object);});}// let hasUnresolvedProperties = false;
|
|
8860
8863
|
// parse according to priority
|
|
8861
8864
|
// path 50
|
|
8862
8865
|
// points 50
|
|
@@ -8887,7 +8890,9 @@
|
|
|
8887
8890
|
// return;
|
|
8888
8891
|
// }
|
|
8889
8892
|
// update geometry
|
|
8890
|
-
if(needUpdateGeometry){object.geometry.dirty=true;
|
|
8893
|
+
if(needUpdateGeometry){// object.geometry.dirty = true;
|
|
8894
|
+
// runtime.sceneGraphService.dirtifyToRoot(object);
|
|
8895
|
+
this.updateGeometry(object);}attributeNames.forEach(function(name){if(name in object.parsedStyle){_this2.postProcessProperty(name,object,attributeNames);}});if(runtime.enableCSSParsing&&object.children.length){attributeNames.forEach(function(name){if(name in object.parsedStyle&&_this2.isPropertyInheritable(name)){// update children's inheritable
|
|
8891
8896
|
object.children.forEach(function(child){child.internalSetAttribute(name,null,{skipUpdateAttribute:true,skipParse:true});});}});}}/**
|
|
8892
8897
|
* string -> parsed value
|
|
8893
8898
|
*/;_proto.parseProperty=function parseProperty(name,value,object){var metadata=propertyMetadataCache[name];var computed=value;if(value===''||isNil(value)){value='unset';}if(value==='unset'||value==='initial'||value==='inherit'){// computed = new CSSKeywordValue(value);
|
|
@@ -8953,15 +8958,14 @@
|
|
|
8953
8958
|
// );
|
|
8954
8959
|
}geometry.renderBounds.update(center,halfExtents);// account for shadow, only support constant value now
|
|
8955
8960
|
if(shadowColor&&shadowType&&shadowType!=='inner'){var _geometry$renderBound=geometry.renderBounds,min=_geometry$renderBound.min,max=_geometry$renderBound.max;var shadowBlur=parsedStyle.shadowBlur,shadowOffsetX=parsedStyle.shadowOffsetX,shadowOffsetY=parsedStyle.shadowOffsetY;var shadowBlurInPixels=shadowBlur||0;var shadowOffsetXInPixels=shadowOffsetX||0;var shadowOffsetYInPixels=shadowOffsetY||0;var shadowLeft=min[0]-shadowBlurInPixels+shadowOffsetXInPixels;var shadowRight=max[0]+shadowBlurInPixels+shadowOffsetXInPixels;var shadowTop=min[1]-shadowBlurInPixels+shadowOffsetYInPixels;var shadowBottom=max[1]+shadowBlurInPixels+shadowOffsetYInPixels;min[0]=Math.min(min[0],shadowLeft);max[0]=Math.max(max[0],shadowRight);min[1]=Math.min(min[1],shadowTop);max[1]=Math.max(max[1],shadowBottom);geometry.renderBounds.setMinMax(min,max);}// account for filter, eg. blur(5px), drop-shadow()
|
|
8956
|
-
filter.forEach(function(_ref){var name=_ref.name,params=_ref.params;if(name==='blur'){var blurRadius=params[0].value;geometry.renderBounds.update(geometry.renderBounds.center,addVec3(geometry.renderBounds.halfExtents,geometry.renderBounds.halfExtents,[blurRadius,blurRadius,0]));}else if(name==='drop-shadow'){var _shadowOffsetX=params[0].value;var _shadowOffsetY=params[1].value;var _shadowBlur=params[2].value;var _geometry$renderBound2=geometry.renderBounds,_min=_geometry$renderBound2.min,_max=_geometry$renderBound2.max;var _shadowLeft=_min[0]-_shadowBlur+_shadowOffsetX;var _shadowRight=_max[0]+_shadowBlur+_shadowOffsetX;var _shadowTop=_min[1]-_shadowBlur+_shadowOffsetY;var _shadowBottom=_max[1]+_shadowBlur+_shadowOffsetY;_min[0]=Math.min(_min[0],_shadowLeft);_max[0]=Math.max(_max[0],_shadowRight);_min[1]=Math.min(_min[1],_shadowTop);_max[1]=Math.max(_max[1],_shadowBottom);geometry.renderBounds.setMinMax(_min,_max);}});anchor=parsedStyle.anchor
|
|
8961
|
+
filter.forEach(function(_ref){var name=_ref.name,params=_ref.params;if(name==='blur'){var blurRadius=params[0].value;geometry.renderBounds.update(geometry.renderBounds.center,addVec3(geometry.renderBounds.halfExtents,geometry.renderBounds.halfExtents,[blurRadius,blurRadius,0]));}else if(name==='drop-shadow'){var _shadowOffsetX=params[0].value;var _shadowOffsetY=params[1].value;var _shadowBlur=params[2].value;var _geometry$renderBound2=geometry.renderBounds,_min=_geometry$renderBound2.min,_max=_geometry$renderBound2.max;var _shadowLeft=_min[0]-_shadowBlur+_shadowOffsetX;var _shadowRight=_max[0]+_shadowBlur+_shadowOffsetX;var _shadowTop=_min[1]-_shadowBlur+_shadowOffsetY;var _shadowBottom=_max[1]+_shadowBlur+_shadowOffsetY;_min[0]=Math.min(_min[0],_shadowLeft);_max[0]=Math.max(_max[0],_shadowRight);_min[1]=Math.min(_min[1],_shadowTop);_max[1]=Math.max(_max[1],_shadowBottom);geometry.renderBounds.setMinMax(_min,_max);}});anchor=parsedStyle.anchor;// if (nodeName === Shape.RECT) {
|
|
8957
8962
|
// account for negative width / height of Rect
|
|
8958
8963
|
// @see https://github.com/antvis/g/issues/957
|
|
8959
8964
|
var flipY=width<0;var flipX=height<0;// } else {
|
|
8960
8965
|
// }
|
|
8961
8966
|
// set transform origin
|
|
8962
8967
|
var usedOriginXValue=(flipY?-1:1)*(transformOrigin?convertPercentUnit(transformOrigin[0],0,object):0);var usedOriginYValue=(flipX?-1:1)*(transformOrigin?convertPercentUnit(transformOrigin[1],1,object):0);usedOriginXValue=usedOriginXValue-(flipY?-1:1)*(anchor&&anchor[0]||0)*geometry.contentBounds.halfExtents[0]*2;usedOriginYValue=usedOriginYValue-(flipX?-1:1)*(anchor&&anchor[1]||0)*geometry.contentBounds.halfExtents[1]*2;object.setOrigin(usedOriginXValue,usedOriginYValue);// FIXME setOrigin may have already dirtified to root.
|
|
8963
|
-
|
|
8964
|
-
}};_proto.isPropertyInheritable=function isPropertyInheritable(name){var metadata=propertyMetadataCache[name];if(!metadata){return false;}return metadata.inh;};return DefaultStyleValueRegistry;}();/**
|
|
8968
|
+
runtime.sceneGraphService.dirtifyToRoot(object);}};_proto.isPropertyInheritable=function isPropertyInheritable(name){var metadata=propertyMetadataCache[name];if(!metadata){return false;}return metadata.inh;};return DefaultStyleValueRegistry;}();/**
|
|
8965
8969
|
* Different type of cameras, eg. simple camera used in 2D scene or
|
|
8966
8970
|
* advanced camera which can do actions & switch between landmarks.
|
|
8967
8971
|
*/(function(CameraType){/**
|
|
@@ -9289,7 +9293,7 @@
|
|
|
9289
9293
|
this.pendingEvents.push([element,{affectChildren:affectChildren}]);};_proto.updateDisplayObjectDependency=function updateDisplayObjectDependency(name,oldPath,newPath,object){// clear ref to old clip path
|
|
9290
9294
|
if(oldPath&&oldPath!==newPath){var oldDependencyMap=this.displayObjectDependencyMap.get(oldPath);if(oldDependencyMap&&oldDependencyMap[name]){var index=oldDependencyMap[name].indexOf(object);oldDependencyMap[name].splice(index,1);}}if(newPath){var newDependencyMap=this.displayObjectDependencyMap.get(newPath);if(!newDependencyMap){this.displayObjectDependencyMap.set(newPath,{});newDependencyMap=this.displayObjectDependencyMap.get(newPath);}if(!newDependencyMap[name]){newDependencyMap[name]=[];}newDependencyMap[name].push(object);}};_proto.informDependentDisplayObjects=function informDependentDisplayObjects(object){var _this3=this;var dependencyMap=this.displayObjectDependencyMap.get(object);if(dependencyMap){Object.keys(dependencyMap).forEach(function(name){dependencyMap[name].forEach(function(target){_this3.dirtifyToRoot(target,true);target.dispatchEvent(new MutationEvent(exports.ElementEvent.ATTR_MODIFIED,target,_this3,_this3,name,MutationEvent.MODIFICATION,_this3,_this3));if(target.isCustomElement&&target.isConnected){if(target.attributeChangedCallback){target.attributeChangedCallback(name,_this3,_this3);}}});});}};_proto.getPosition=function getPosition(element){var transform=element.transformable;return getTranslation(transform.position,this.getWorldTransform(element,transform));};_proto.getRotation=function getRotation$1(element){var transform=element.transformable;return getRotation(transform.rotation,this.getWorldTransform(element,transform));};_proto.getScale=function getScale(element){var transform=element.transformable;return getScaling(transform.scaling,this.getWorldTransform(element,transform));};_proto.getWorldTransform=function getWorldTransform(element,transform){if(transform===void 0){transform=element.transformable;}if(!transform.localDirtyFlag&&!transform.dirtyFlag){return transform.worldTransform;}if(element.parentNode&&element.parentNode.transformable){this.getWorldTransform(element.parentNode);}this.sync(element,transform);return transform.worldTransform;};_proto.getLocalPosition=function getLocalPosition(element){return element.transformable.localPosition;};_proto.getLocalRotation=function getLocalRotation(element){return element.transformable.localRotation;};_proto.getLocalScale=function getLocalScale(element){return element.transformable.localScale;};_proto.getLocalSkew=function getLocalSkew(element){return element.transformable.localSkew;};_proto.getLocalTransform=function getLocalTransform(element){var transform=element.transformable;if(transform.localDirtyFlag){this.calcLocalTransform(transform);transform.localDirtyFlag=false;}return transform.localTransform;};_proto.setLocalTransform=function setLocalTransform(element,transform){var t=getTranslation(create$2(),transform);var r=getRotation(create$4(),transform);var s=getScaling(create$2(),transform);this.setLocalScale(element,s);this.setLocalPosition(element,t);this.setLocalRotation(element,r);};_proto.resetLocalTransform=function resetLocalTransform(element){this.setLocalScale(element,[1,1,1]);this.setLocalPosition(element,[0,0,0]);this.setLocalEulerAngles(element,[0,0,0]);this.setLocalSkew(element,[0,0]);};_proto.getTransformedGeometryBounds=function getTransformedGeometryBounds(element,render,existedAABB){if(render===void 0){render=false;}var bounds=this.getGeometryBounds(element,render);if(!AABB.isEmpty(bounds)){var aabb=existedAABB||new AABB();aabb.setFromTransformedAABB(bounds,this.getWorldTransform(element));return aabb;}else {return null;}}/**
|
|
9291
9295
|
* won't account for children
|
|
9292
|
-
*/;_proto.getGeometryBounds=function getGeometryBounds(element,render){if(render===void 0){render=false;}var geometry=element.geometry;
|
|
9296
|
+
*/;_proto.getGeometryBounds=function getGeometryBounds(element,render){if(render===void 0){render=false;}var geometry=element.geometry;var bounds=render?geometry.renderBounds:geometry.contentBounds||null;// return (bounds && new AABB(bounds.center, bounds.halfExtents)) || new AABB();
|
|
9293
9297
|
return bounds||new AABB();}/**
|
|
9294
9298
|
* account for children in world space
|
|
9295
9299
|
*/;_proto.getBounds=function getBounds(element,render){var _this4=this;if(render===void 0){render=false;}var renderable=element.renderable;if(!renderable.boundsDirty&&!render&&renderable.bounds){return renderable.bounds;}if(!renderable.renderBoundsDirty&&render&&renderable.renderBounds){return renderable.renderBounds;}// reuse existed if possible
|
|
@@ -9319,9 +9323,15 @@
|
|
|
9319
9323
|
canvas.width=width;// @ts-ignore
|
|
9320
9324
|
canvas.height=height;context.fillStyle='#f00';context.fillRect(0,0,width,height);context.font=font;context.textBaseline='alphabetic';context.fillStyle='#000';context.fillText(metricsString,0,baseline);var imagedata=context.getImageData(0,0,width||1,height||1).data;var pixels=imagedata.length;var line=width*4;var i=0;var idx=0;var stop=false;// ascent. scan from top to bottom until we find a non red pixel
|
|
9321
9325
|
for(i=0;i<baseline;++i){for(var j=0;j<line;j+=4){if(imagedata[idx+j]!==255){stop=true;break;}}if(!stop){idx+=line;}else {break;}}properties.ascent=baseline-i;idx=pixels-line;stop=false;// descent. scan from bottom to top until we find a non red pixel
|
|
9322
|
-
for(i=height;i>baseline;--i){for(var _j=0;_j<line;_j+=4){if(imagedata[idx+_j]!==255){stop=true;break;}}if(!stop){idx-=line;}else {break;}}properties.descent=i-baseline;properties.fontSize=properties.ascent+properties.descent;this.fontMetricsCache[font]=properties;return properties;};_proto.measureText=function measureText(text,parsedStyle,offscreenCanvas){var fontSize=parsedStyle.fontSize,wordWrap=parsedStyle.wordWrap,strokeHeight=parsedStyle.lineHeight,lineWidth=parsedStyle.lineWidth,textBaseline=parsedStyle.textBaseline,textAlign=parsedStyle.textAlign,letterSpacing=parsedStyle.letterSpacing,textPath=parsedStyle.textPath,textPathSide=parsedStyle.textPathSide,textPathStartOffset=parsedStyle.textPathStartOffset,_parsedStyle$leading=parsedStyle.leading,leading=_parsedStyle$leading===void 0?0:_parsedStyle$leading;var font=toFontString(parsedStyle);var fontProperties
|
|
9326
|
+
for(i=height;i>baseline;--i){for(var _j=0;_j<line;_j+=4){if(imagedata[idx+_j]!==255){stop=true;break;}}if(!stop){idx-=line;}else {break;}}properties.descent=i-baseline;properties.fontSize=properties.ascent+properties.descent;this.fontMetricsCache[font]=properties;return properties;};_proto.measureText=function measureText(text,parsedStyle,offscreenCanvas){var fontSize=parsedStyle.fontSize,wordWrap=parsedStyle.wordWrap,strokeHeight=parsedStyle.lineHeight,lineWidth=parsedStyle.lineWidth,textBaseline=parsedStyle.textBaseline,textAlign=parsedStyle.textAlign,letterSpacing=parsedStyle.letterSpacing,textPath=parsedStyle.textPath,textPathSide=parsedStyle.textPathSide,textPathStartOffset=parsedStyle.textPathStartOffset,_parsedStyle$leading=parsedStyle.leading,leading=_parsedStyle$leading===void 0?0:_parsedStyle$leading;var font=toFontString(parsedStyle);var fontProperties;// if (runtime.enableCSSParsing) {
|
|
9327
|
+
fontProperties=this.measureFont(font,offscreenCanvas);// fallback in case UA disallow canvas data extraction
|
|
9323
9328
|
// (toDataURI, getImageData functions)
|
|
9324
|
-
if(fontProperties.fontSize===0){fontProperties.fontSize=fontSize;fontProperties.ascent=fontSize;}}else {
|
|
9329
|
+
if(fontProperties.fontSize===0){fontProperties.fontSize=fontSize;fontProperties.ascent=fontSize;}// } else {
|
|
9330
|
+
// fontProperties = {
|
|
9331
|
+
// fontSize,
|
|
9332
|
+
// };
|
|
9333
|
+
// }
|
|
9334
|
+
var context=this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);context.font=font;// no overflowing by default
|
|
9325
9335
|
parsedStyle.isOverflowing=false;var outputText=wordWrap?this.wordWrap(text,parsedStyle,offscreenCanvas):text;var lines=outputText.split(/(?:\r\n|\r|\n)/);var lineWidths=new Array(lines.length);var maxLineWidth=0;// account for textPath
|
|
9326
9336
|
if(textPath){var totalPathLength=textPath.getTotalLength();// const startingPoint = textPath.getPoint(0);
|
|
9327
9337
|
for(var i=0;i<lines.length;i++){var width=context.measureText(lines[i]).width+(lines[i].length-1)*letterSpacing;// for (
|
|
@@ -12473,7 +12483,7 @@
|
|
|
12473
12483
|
var localDuration = interpolation.endOffset - interpolation.startOffset;
|
|
12474
12484
|
var scaledLocalTime = localDuration === 0 ? 0 : interpolation.easingFunction(offsetFraction / localDuration);
|
|
12475
12485
|
// apply updated attribute
|
|
12476
|
-
target.
|
|
12486
|
+
target.setAttribute(interpolation.property, interpolation.interpolation(scaledLocalTime));
|
|
12477
12487
|
// if (interpolation.property === 'visibility') {
|
|
12478
12488
|
// console.log(
|
|
12479
12489
|
// scaledLocalTime,
|
|
@@ -12485,7 +12495,7 @@
|
|
|
12485
12495
|
for (var property in propertySpecificKeyframeGroups) {
|
|
12486
12496
|
if (isNotReservedWord(property)) {
|
|
12487
12497
|
// clear attribute
|
|
12488
|
-
target.
|
|
12498
|
+
target.setAttribute(property, null);
|
|
12489
12499
|
}
|
|
12490
12500
|
}
|
|
12491
12501
|
}
|
|
@@ -12616,13 +12626,14 @@
|
|
|
12616
12626
|
}
|
|
12617
12627
|
if (Array.isArray(from) && Array.isArray(to)) {
|
|
12618
12628
|
// interpolate arrays/matrix
|
|
12619
|
-
|
|
12620
|
-
|
|
12621
|
-
|
|
12622
|
-
|
|
12623
|
-
|
|
12624
|
-
|
|
12629
|
+
var fromLength = from.length;
|
|
12630
|
+
var toLength = to.length;
|
|
12631
|
+
var length = Math.max(fromLength, toLength);
|
|
12632
|
+
var r = [];
|
|
12633
|
+
for (var i = 0; i < length; i++) {
|
|
12634
|
+
r.push(interpolate(from[i < fromLength ? i : fromLength - 1], to[i < toLength ? i : toLength - 1], f));
|
|
12625
12635
|
}
|
|
12636
|
+
return r;
|
|
12626
12637
|
}
|
|
12627
12638
|
throw new Error('Mismatched interpolation arguments ' + from + ':' + to);
|
|
12628
12639
|
}
|
|
@@ -12890,7 +12901,9 @@
|
|
|
12890
12901
|
this.timing.endTime = Math.max(0, this.timing.delay + this.timing.activeDuration + this.timing.endDelay);
|
|
12891
12902
|
this.normalizedKeyframes = normalizeKeyframes(effectInput, this.timing);
|
|
12892
12903
|
this.interpolations = convertEffectInput(this.normalizedKeyframes, this.timing, this.target);
|
|
12893
|
-
|
|
12904
|
+
// 不支持 proxy 时降级成 this.timing
|
|
12905
|
+
var Proxy = runtime.globalThis.Proxy;
|
|
12906
|
+
this.computedTiming = Proxy ? new Proxy(this.timing, {
|
|
12894
12907
|
get: function get(target, prop) {
|
|
12895
12908
|
if (prop === 'duration') {
|
|
12896
12909
|
return target.duration === 'auto' ? 0 : target.duration;
|
|
@@ -12914,7 +12927,7 @@
|
|
|
12914
12927
|
set: function set() {
|
|
12915
12928
|
return true;
|
|
12916
12929
|
}
|
|
12917
|
-
});
|
|
12930
|
+
}) : this.timing;
|
|
12918
12931
|
}
|
|
12919
12932
|
var _proto = KeyframeEffect.prototype;
|
|
12920
12933
|
_proto.applyInterpolations = function applyInterpolations() {
|