@antv/g 3.5.0-beta.6 → 5.0.4
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/LICENSE +21 -0
- package/README.md +0 -546
- package/dist/index.umd.js +15 -0
- package/es/AbstractRenderer.d.ts +26 -0
- package/es/AbstractRenderer.js +42 -0
- package/es/Canvas.d.ts +98 -0
- package/es/Canvas.js +406 -0
- package/es/DisplayObjectPool.d.ts +7 -0
- package/es/DisplayObjectPool.js +27 -0
- package/es/camera/Camera.d.ts +279 -0
- package/es/camera/Camera.js +973 -0
- package/es/camera/Landmark.d.ts +28 -0
- package/es/camera/Landmark.js +68 -0
- package/es/camera/index.d.ts +2 -0
- package/es/camera/index.js +2 -0
- package/es/canvas-module.d.ts +1 -0
- package/es/canvas-module.js +33 -0
- package/es/components/Cullable.d.ts +14 -0
- package/es/components/Cullable.js +28 -0
- package/es/components/Geometry.d.ts +12 -0
- package/es/components/Geometry.js +10 -0
- package/es/components/Renderable.d.ts +24 -0
- package/es/components/Renderable.js +18 -0
- package/es/components/Sortable.d.ts +16 -0
- package/es/components/Sortable.js +15 -0
- package/es/components/Transform.d.ts +29 -0
- package/es/components/Transform.js +65 -0
- package/es/components/index.d.ts +5 -0
- package/es/components/index.js +5 -0
- package/es/display-objects/Circle.d.ts +12 -0
- package/es/display-objects/Circle.js +26 -0
- package/es/display-objects/CustomElement.d.ts +21 -0
- package/es/display-objects/CustomElement.js +89 -0
- package/es/display-objects/DisplayObject.d.ts +259 -0
- package/es/display-objects/DisplayObject.js +855 -0
- package/es/display-objects/Ellipse.d.ts +14 -0
- package/es/display-objects/Ellipse.js +27 -0
- package/es/display-objects/Group.d.ts +6 -0
- package/es/display-objects/Group.js +27 -0
- package/es/display-objects/HTML.d.ts +36 -0
- package/es/display-objects/HTML.js +93 -0
- package/es/display-objects/Image.d.ts +16 -0
- package/es/display-objects/Image.js +25 -0
- package/es/display-objects/Line.d.ts +23 -0
- package/es/display-objects/Line.js +56 -0
- package/es/display-objects/Path.d.ts +47 -0
- package/es/display-objects/Path.js +132 -0
- package/es/display-objects/Polygon.d.ts +12 -0
- package/es/display-objects/Polygon.js +25 -0
- package/es/display-objects/Polyline.d.ts +23 -0
- package/es/display-objects/Polyline.js +75 -0
- package/es/display-objects/Rect.d.ts +16 -0
- package/es/display-objects/Rect.js +26 -0
- package/es/display-objects/Text.d.ts +65 -0
- package/es/display-objects/Text.js +61 -0
- package/es/display-objects/index.d.ts +13 -0
- package/es/display-objects/index.js +13 -0
- package/es/dom/Animation.d.ts +132 -0
- package/es/dom/Animation.js +503 -0
- package/es/dom/AnimationEffectTiming.d.ts +58 -0
- package/es/dom/AnimationEffectTiming.js +68 -0
- package/es/dom/AnimationEvent.d.ts +11 -0
- package/es/dom/AnimationEvent.js +34 -0
- package/es/dom/AnimationTimeline.d.ts +37 -0
- package/es/dom/AnimationTimeline.js +218 -0
- package/es/dom/CustomElementRegistry.d.ts +15 -0
- package/es/dom/CustomElementRegistry.js +42 -0
- package/es/dom/CustomEvent.d.ts +16 -0
- package/es/dom/CustomEvent.js +35 -0
- package/es/dom/Document.d.ts +59 -0
- package/es/dom/Document.js +174 -0
- package/es/dom/Element.d.ts +149 -0
- package/es/dom/Element.js +494 -0
- package/es/dom/EventTarget.d.ts +40 -0
- package/es/dom/EventTarget.js +156 -0
- package/es/dom/FederatedEvent.d.ts +146 -0
- package/es/dom/FederatedEvent.js +232 -0
- package/es/dom/FederatedMouseEvent.d.ts +52 -0
- package/es/dom/FederatedMouseEvent.js +124 -0
- package/es/dom/FederatedPointerEvent.d.ts +69 -0
- package/es/dom/FederatedPointerEvent.js +53 -0
- package/es/dom/FederatedWheelEvent.d.ts +20 -0
- package/es/dom/FederatedWheelEvent.js +27 -0
- package/es/dom/KeyframeEffect.d.ts +47 -0
- package/es/dom/KeyframeEffect.js +174 -0
- package/es/dom/KeyframeList.d.ts +2 -0
- package/es/dom/KeyframeList.js +176 -0
- package/es/dom/Node.d.ts +106 -0
- package/es/dom/Node.js +220 -0
- package/es/dom/index.d.ts +17 -0
- package/es/dom/index.js +17 -0
- package/es/dom/interfaces.d.ts +324 -0
- package/es/dom/interfaces.js +32 -0
- package/es/global-module.d.ts +2 -0
- package/es/global-module.js +173 -0
- package/es/index.d.ts +15 -0
- package/es/index.js +18 -0
- package/es/plugins/CullingPlugin.d.ts +19 -0
- package/es/plugins/CullingPlugin.js +79 -0
- package/es/plugins/DirtyCheckPlugin.d.ts +10 -0
- package/es/plugins/DirtyCheckPlugin.js +52 -0
- package/es/plugins/EventPlugin.d.ts +27 -0
- package/es/plugins/EventPlugin.js +288 -0
- package/es/plugins/FrustumCullingStrategy.d.ts +20 -0
- package/es/plugins/FrustumCullingStrategy.js +98 -0
- package/es/plugins/PrepareRendererPlugin.d.ts +6 -0
- package/es/plugins/PrepareRendererPlugin.js +65 -0
- package/es/property-handlers/aabb.d.ts +2 -0
- package/es/property-handlers/aabb.js +132 -0
- package/es/property-handlers/anchor.d.ts +4 -0
- package/es/property-handlers/anchor.js +20 -0
- package/es/property-handlers/clipPath.d.ts +19 -0
- package/es/property-handlers/clipPath.js +36 -0
- package/es/property-handlers/color.d.ts +34 -0
- package/es/property-handlers/color.js +253 -0
- package/es/property-handlers/dimension.d.ts +18 -0
- package/es/property-handlers/dimension.js +123 -0
- package/es/property-handlers/filter.d.ts +8 -0
- package/es/property-handlers/filter.js +43 -0
- package/es/property-handlers/index.d.ts +18 -0
- package/es/property-handlers/index.js +18 -0
- package/es/property-handlers/interfaces.d.ts +20 -0
- package/es/property-handlers/interfaces.js +6 -0
- package/es/property-handlers/lineDash.d.ts +1 -0
- package/es/property-handlers/lineDash.js +8 -0
- package/es/property-handlers/localPosition.d.ts +2 -0
- package/es/property-handlers/localPosition.js +9 -0
- package/es/property-handlers/numeric.d.ts +5 -0
- package/es/property-handlers/numeric.js +34 -0
- package/es/property-handlers/offsetDistance.d.ts +5 -0
- package/es/property-handlers/offsetDistance.js +20 -0
- package/es/property-handlers/offsetPath.d.ts +5 -0
- package/es/property-handlers/offsetPath.js +18 -0
- package/es/property-handlers/origin.d.ts +11 -0
- package/es/property-handlers/origin.js +68 -0
- package/es/property-handlers/path.d.ts +4 -0
- package/es/property-handlers/path.js +200 -0
- package/es/property-handlers/points.d.ts +5 -0
- package/es/property-handlers/points.js +23 -0
- package/es/property-handlers/transform.d.ts +45 -0
- package/es/property-handlers/transform.js +411 -0
- package/es/property-handlers/zIndex.d.ts +2 -0
- package/es/property-handlers/zIndex.js +16 -0
- package/es/services/ContextService.d.ts +12 -0
- package/es/services/ContextService.js +5 -0
- package/es/services/EventService.d.ts +64 -0
- package/es/services/EventService.js +936 -0
- package/es/services/RenderingContext.d.ts +28 -0
- package/es/services/RenderingContext.js +13 -0
- package/es/services/RenderingService.d.ts +52 -0
- package/es/services/RenderingService.js +147 -0
- package/es/services/SceneGraphSelector.d.ts +20 -0
- package/es/services/SceneGraphSelector.js +65 -0
- package/es/services/SceneGraphService.d.ts +150 -0
- package/es/services/SceneGraphService.js +853 -0
- package/es/services/aabb/CircleUpdater.d.ts +10 -0
- package/es/services/aabb/CircleUpdater.js +35 -0
- package/es/services/aabb/EllipseUpdater.d.ts +10 -0
- package/es/services/aabb/EllipseUpdater.js +37 -0
- package/es/services/aabb/LineUpdater.d.ts +10 -0
- package/es/services/aabb/LineUpdater.js +39 -0
- package/es/services/aabb/PathUpdater.d.ts +10 -0
- package/es/services/aabb/PathUpdater.js +172 -0
- package/es/services/aabb/PolylineUpdater.d.ts +10 -0
- package/es/services/aabb/PolylineUpdater.js +48 -0
- package/es/services/aabb/RectUpdater.d.ts +10 -0
- package/es/services/aabb/RectUpdater.js +55 -0
- package/es/services/aabb/TextUpdater.d.ts +13 -0
- package/es/services/aabb/TextUpdater.js +81 -0
- package/es/services/aabb/index.d.ts +8 -0
- package/es/services/aabb/index.js +8 -0
- package/es/services/aabb/interfaces.d.ts +16 -0
- package/es/services/aabb/interfaces.js +2 -0
- package/es/services/index.d.ts +10 -0
- package/es/services/index.js +10 -0
- package/es/services/text/OffscreenCanvasCreator.d.ts +6 -0
- package/es/services/text/OffscreenCanvasCreator.js +47 -0
- package/es/services/text/index.d.ts +35 -0
- package/es/services/text/index.js +355 -0
- package/es/shapes/AABB.d.ts +34 -0
- package/es/shapes/AABB.js +217 -0
- package/es/shapes/BoundingSphere.d.ts +8 -0
- package/es/shapes/BoundingSphere.js +31 -0
- package/es/shapes/Frustum.d.ts +16 -0
- package/es/shapes/Frustum.js +79 -0
- package/es/shapes/Plane.d.ts +14 -0
- package/es/shapes/Plane.js +42 -0
- package/es/shapes/Point.d.ts +11 -0
- package/es/shapes/Point.js +31 -0
- package/es/shapes/Polygon.d.ts +9 -0
- package/es/shapes/Polygon.js +64 -0
- package/es/shapes/Ray.d.ts +24 -0
- package/es/shapes/Ray.js +138 -0
- package/es/shapes/Rect.d.ts +12 -0
- package/es/shapes/Rect.js +24 -0
- package/es/shapes/Rectangle.d.ts +12 -0
- package/es/shapes/Rectangle.js +20 -0
- package/es/shapes/index.d.ts +8 -0
- package/es/shapes/index.js +8 -0
- package/es/types.d.ts +219 -0
- package/es/types.js +17 -0
- package/es/utils/animation.d.ts +15 -0
- package/es/utils/animation.js +251 -0
- package/es/utils/bezier-easing.d.ts +20 -0
- package/es/utils/bezier-easing.js +90 -0
- package/es/utils/canvas.d.ts +5 -0
- package/es/utils/canvas.js +15 -0
- package/es/utils/custom-easing.d.ts +73 -0
- package/es/utils/custom-easing.js +333 -0
- package/es/utils/event.d.ts +11 -0
- package/es/utils/event.js +69 -0
- package/es/utils/index.d.ts +5 -0
- package/es/utils/index.js +5 -0
- package/es/utils/interpolation.d.ts +3 -0
- package/es/utils/interpolation.js +179 -0
- package/es/utils/math.d.ts +24 -0
- package/es/utils/math.js +165 -0
- package/es/utils/path.d.ts +15 -0
- package/es/utils/path.js +330 -0
- package/es/utils/raf.d.ts +3 -0
- package/es/utils/raf.js +16 -0
- package/es/utils/text.d.ts +2 -0
- package/es/utils/text.js +32 -0
- package/lib/AbstractRenderer.d.ts +26 -0
- package/lib/AbstractRenderer.js +49 -0
- package/lib/Canvas.d.ts +98 -0
- package/lib/Canvas.js +427 -0
- package/lib/DisplayObjectPool.d.ts +7 -0
- package/lib/DisplayObjectPool.js +35 -0
- package/lib/camera/Camera.d.ts +279 -0
- package/lib/camera/Camera.js +1046 -0
- package/lib/camera/Landmark.d.ts +28 -0
- package/lib/camera/Landmark.js +75 -0
- package/lib/camera/index.d.ts +2 -0
- package/lib/camera/index.js +31 -0
- package/lib/canvas-module.d.ts +1 -0
- package/lib/canvas-module.js +48 -0
- package/lib/components/Cullable.d.ts +14 -0
- package/lib/components/Cullable.js +36 -0
- package/lib/components/Geometry.d.ts +12 -0
- package/lib/components/Geometry.js +17 -0
- package/lib/components/Renderable.d.ts +24 -0
- package/lib/components/Renderable.js +25 -0
- package/lib/components/Sortable.d.ts +16 -0
- package/lib/components/Sortable.js +22 -0
- package/lib/components/Transform.d.ts +29 -0
- package/lib/components/Transform.js +72 -0
- package/lib/components/index.d.ts +5 -0
- package/lib/components/index.js +70 -0
- package/lib/display-objects/Circle.d.ts +12 -0
- package/lib/display-objects/Circle.js +34 -0
- package/lib/display-objects/CustomElement.d.ts +21 -0
- package/lib/display-objects/CustomElement.js +97 -0
- package/lib/display-objects/DisplayObject.d.ts +259 -0
- package/lib/display-objects/DisplayObject.js +877 -0
- package/lib/display-objects/Ellipse.d.ts +14 -0
- package/lib/display-objects/Ellipse.js +35 -0
- package/lib/display-objects/Group.d.ts +6 -0
- package/lib/display-objects/Group.js +36 -0
- package/lib/display-objects/HTML.d.ts +36 -0
- package/lib/display-objects/HTML.js +105 -0
- package/lib/display-objects/Image.d.ts +16 -0
- package/lib/display-objects/Image.js +33 -0
- package/lib/display-objects/Line.d.ts +23 -0
- package/lib/display-objects/Line.js +68 -0
- package/lib/display-objects/Path.d.ts +47 -0
- package/lib/display-objects/Path.js +143 -0
- package/lib/display-objects/Polygon.d.ts +12 -0
- package/lib/display-objects/Polygon.js +33 -0
- package/lib/display-objects/Polyline.d.ts +23 -0
- package/lib/display-objects/Polyline.js +85 -0
- package/lib/display-objects/Rect.d.ts +16 -0
- package/lib/display-objects/Rect.js +34 -0
- package/lib/display-objects/Text.d.ts +65 -0
- package/lib/display-objects/Text.js +69 -0
- package/lib/display-objects/index.d.ts +13 -0
- package/lib/display-objects/index.js +174 -0
- package/lib/dom/Animation.d.ts +132 -0
- package/lib/dom/Animation.js +511 -0
- package/lib/dom/AnimationEffectTiming.d.ts +58 -0
- package/lib/dom/AnimationEffectTiming.js +75 -0
- package/lib/dom/AnimationEvent.d.ts +11 -0
- package/lib/dom/AnimationEvent.js +42 -0
- package/lib/dom/AnimationTimeline.d.ts +37 -0
- package/lib/dom/AnimationTimeline.js +230 -0
- package/lib/dom/CustomElementRegistry.d.ts +15 -0
- package/lib/dom/CustomElementRegistry.js +50 -0
- package/lib/dom/CustomEvent.d.ts +16 -0
- package/lib/dom/CustomEvent.js +42 -0
- package/lib/dom/Document.d.ts +59 -0
- package/lib/dom/Document.js +184 -0
- package/lib/dom/Element.d.ts +149 -0
- package/lib/dom/Element.js +508 -0
- package/lib/dom/EventTarget.d.ts +40 -0
- package/lib/dom/EventTarget.js +170 -0
- package/lib/dom/FederatedEvent.d.ts +146 -0
- package/lib/dom/FederatedEvent.js +239 -0
- package/lib/dom/FederatedMouseEvent.d.ts +52 -0
- package/lib/dom/FederatedMouseEvent.js +133 -0
- package/lib/dom/FederatedPointerEvent.d.ts +69 -0
- package/lib/dom/FederatedPointerEvent.js +61 -0
- package/lib/dom/FederatedWheelEvent.d.ts +20 -0
- package/lib/dom/FederatedWheelEvent.js +35 -0
- package/lib/dom/KeyframeEffect.d.ts +47 -0
- package/lib/dom/KeyframeEffect.js +192 -0
- package/lib/dom/KeyframeList.d.ts +2 -0
- package/lib/dom/KeyframeList.js +183 -0
- package/lib/dom/Node.d.ts +106 -0
- package/lib/dom/Node.js +228 -0
- package/lib/dom/index.d.ts +17 -0
- package/lib/dom/index.js +226 -0
- package/lib/dom/interfaces.d.ts +324 -0
- package/lib/dom/interfaces.js +40 -0
- package/lib/global-module.d.ts +2 -0
- package/lib/global-module.js +192 -0
- package/lib/index.d.ts +14 -12
- package/lib/index.js +203 -26
- package/lib/plugins/CullingPlugin.d.ts +19 -0
- package/lib/plugins/CullingPlugin.js +90 -0
- package/lib/plugins/DirtyCheckPlugin.d.ts +10 -0
- package/lib/plugins/DirtyCheckPlugin.js +60 -0
- package/lib/plugins/EventPlugin.d.ts +27 -0
- package/lib/plugins/EventPlugin.js +297 -0
- package/lib/plugins/FrustumCullingStrategy.d.ts +20 -0
- package/lib/plugins/FrustumCullingStrategy.js +110 -0
- package/lib/plugins/PrepareRendererPlugin.d.ts +6 -0
- package/lib/plugins/PrepareRendererPlugin.js +73 -0
- package/lib/property-handlers/aabb.d.ts +2 -0
- package/lib/property-handlers/aabb.js +148 -0
- package/lib/property-handlers/anchor.d.ts +4 -0
- package/lib/property-handlers/anchor.js +32 -0
- package/lib/property-handlers/clipPath.d.ts +19 -0
- package/lib/property-handlers/clipPath.js +43 -0
- package/lib/property-handlers/color.d.ts +34 -0
- package/lib/property-handlers/color.js +274 -0
- package/lib/property-handlers/dimension.d.ts +18 -0
- package/lib/property-handlers/dimension.js +144 -0
- package/lib/property-handlers/filter.d.ts +8 -0
- package/lib/property-handlers/filter.js +56 -0
- package/lib/property-handlers/index.d.ts +18 -0
- package/lib/property-handlers/index.js +226 -0
- package/lib/property-handlers/interfaces.d.ts +20 -0
- package/lib/property-handlers/interfaces.js +18 -0
- package/lib/property-handlers/lineDash.d.ts +1 -0
- package/lib/property-handlers/lineDash.js +15 -0
- package/lib/property-handlers/localPosition.d.ts +2 -0
- package/lib/property-handlers/localPosition.js +16 -0
- package/lib/property-handlers/numeric.d.ts +5 -0
- package/lib/property-handlers/numeric.js +50 -0
- package/lib/property-handlers/offsetDistance.d.ts +5 -0
- package/lib/property-handlers/offsetDistance.js +27 -0
- package/lib/property-handlers/offsetPath.d.ts +5 -0
- package/lib/property-handlers/offsetPath.js +25 -0
- package/lib/property-handlers/origin.d.ts +11 -0
- package/lib/property-handlers/origin.js +79 -0
- package/lib/property-handlers/path.d.ts +4 -0
- package/lib/property-handlers/path.js +214 -0
- package/lib/property-handlers/points.d.ts +5 -0
- package/lib/property-handlers/points.js +33 -0
- package/lib/property-handlers/transform.d.ts +45 -0
- package/lib/property-handlers/transform.js +426 -0
- package/lib/property-handlers/zIndex.d.ts +2 -0
- package/lib/property-handlers/zIndex.js +23 -0
- package/lib/services/ContextService.d.ts +12 -0
- package/lib/services/ContextService.js +15 -0
- package/lib/services/EventService.d.ts +64 -0
- package/lib/services/EventService.js +960 -0
- package/lib/services/RenderingContext.d.ts +28 -0
- package/lib/services/RenderingContext.js +22 -0
- package/lib/services/RenderingService.d.ts +52 -0
- package/lib/services/RenderingService.js +159 -0
- package/lib/services/SceneGraphSelector.d.ts +20 -0
- package/lib/services/SceneGraphSelector.js +77 -0
- package/lib/services/SceneGraphService.d.ts +150 -0
- package/lib/services/SceneGraphService.js +902 -0
- package/lib/services/aabb/CircleUpdater.d.ts +10 -0
- package/lib/services/aabb/CircleUpdater.js +45 -0
- package/lib/services/aabb/EllipseUpdater.d.ts +10 -0
- package/lib/services/aabb/EllipseUpdater.js +47 -0
- package/lib/services/aabb/LineUpdater.d.ts +10 -0
- package/lib/services/aabb/LineUpdater.js +49 -0
- package/lib/services/aabb/PathUpdater.d.ts +10 -0
- package/lib/services/aabb/PathUpdater.js +183 -0
- package/lib/services/aabb/PolylineUpdater.d.ts +10 -0
- package/lib/services/aabb/PolylineUpdater.js +58 -0
- package/lib/services/aabb/RectUpdater.d.ts +10 -0
- package/lib/services/aabb/RectUpdater.js +66 -0
- package/lib/services/aabb/TextUpdater.d.ts +13 -0
- package/lib/services/aabb/TextUpdater.js +93 -0
- package/lib/services/aabb/index.d.ts +8 -0
- package/lib/services/aabb/index.js +84 -0
- package/lib/services/aabb/interfaces.d.ts +16 -0
- package/lib/services/aabb/interfaces.js +10 -0
- package/lib/services/index.d.ts +10 -0
- package/lib/services/index.js +122 -0
- package/lib/services/text/OffscreenCanvasCreator.d.ts +6 -0
- package/lib/services/text/OffscreenCanvasCreator.js +55 -0
- package/lib/services/text/index.d.ts +35 -0
- package/lib/services/text/index.js +364 -0
- package/lib/shapes/AABB.d.ts +34 -0
- package/lib/shapes/AABB.js +235 -0
- package/lib/shapes/BoundingSphere.d.ts +8 -0
- package/lib/shapes/BoundingSphere.js +41 -0
- package/lib/shapes/Frustum.d.ts +16 -0
- package/lib/shapes/Frustum.js +96 -0
- package/lib/shapes/Plane.d.ts +14 -0
- package/lib/shapes/Plane.js +51 -0
- package/lib/shapes/Point.d.ts +11 -0
- package/lib/shapes/Point.js +38 -0
- package/lib/shapes/Polygon.d.ts +9 -0
- package/lib/shapes/Polygon.js +71 -0
- package/lib/shapes/Ray.d.ts +24 -0
- package/lib/shapes/Ray.js +169 -0
- package/lib/shapes/Rect.d.ts +12 -0
- package/lib/shapes/Rect.js +31 -0
- package/lib/shapes/Rectangle.d.ts +12 -0
- package/lib/shapes/Rectangle.js +27 -0
- package/lib/shapes/index.d.ts +8 -13
- package/lib/shapes/index.js +108 -28
- package/lib/types.d.ts +219 -0
- package/lib/types.js +25 -0
- package/lib/utils/animation.d.ts +15 -0
- package/lib/utils/animation.js +275 -0
- package/lib/utils/bezier-easing.d.ts +20 -0
- package/lib/utils/bezier-easing.js +128 -0
- package/lib/utils/canvas.d.ts +5 -0
- package/lib/utils/canvas.js +21 -0
- package/lib/utils/custom-easing.d.ts +73 -0
- package/lib/utils/custom-easing.js +416 -0
- package/lib/utils/event.d.ts +11 -0
- package/lib/utils/event.js +88 -0
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/index.js +70 -0
- package/lib/utils/interpolation.d.ts +3 -0
- package/lib/utils/interpolation.js +194 -0
- package/lib/utils/math.d.ts +24 -0
- package/lib/utils/math.js +192 -0
- package/lib/utils/path.d.ts +15 -0
- package/lib/utils/path.js +356 -0
- package/lib/utils/raf.d.ts +3 -0
- package/lib/utils/raf.js +22 -0
- package/lib/utils/text.d.ts +2 -0
- package/lib/utils/text.js +41 -0
- package/package.json +35 -92
- package/dist/g.min.js +0 -17
- package/dist/g.min.js.map +0 -1
- package/esm/canvas.d.ts +0 -46
- package/esm/canvas.js +0 -383
- package/esm/canvas.js.map +0 -1
- package/esm/core/attribute.d.ts +0 -49
- package/esm/core/attribute.js +0 -277
- package/esm/core/attribute.js.map +0 -1
- package/esm/core/base.d.ts +0 -32
- package/esm/core/base.js +0 -190
- package/esm/core/base.js.map +0 -1
- package/esm/core/bbox.d.ts +0 -22
- package/esm/core/bbox.js +0 -34
- package/esm/core/bbox.js.map +0 -1
- package/esm/core/element.d.ts +0 -19
- package/esm/core/element.js +0 -203
- package/esm/core/element.js.map +0 -1
- package/esm/core/group.d.ts +0 -72
- package/esm/core/group.js +0 -437
- package/esm/core/group.js.map +0 -1
- package/esm/core/shape.d.ts +0 -35
- package/esm/core/shape.js +0 -158
- package/esm/core/shape.js.map +0 -1
- package/esm/core/timeline.d.ts +0 -15
- package/esm/core/timeline.js +0 -179
- package/esm/core/timeline.js.map +0 -1
- package/esm/event.d.ts +0 -25
- package/esm/event.js +0 -37
- package/esm/event.js.map +0 -1
- package/esm/index.d.ts +0 -13
- package/esm/index.js +0 -15
- package/esm/index.js.map +0 -1
- package/esm/interface.d.ts +0 -18
- package/esm/interface.js +0 -1
- package/esm/interface.js.map +0 -1
- package/esm/renderers/canvas/index.d.ts +0 -1
- package/esm/renderers/canvas/index.js +0 -2
- package/esm/renderers/canvas/index.js.map +0 -1
- package/esm/renderers/canvas/painter.d.ts +0 -17
- package/esm/renderers/canvas/painter.js +0 -157
- package/esm/renderers/canvas/painter.js.map +0 -1
- package/esm/renderers/canvas/util.d.ts +0 -2
- package/esm/renderers/canvas/util.js +0 -187
- package/esm/renderers/canvas/util.js.map +0 -1
- package/esm/renderers/index.d.ts +0 -3
- package/esm/renderers/index.js +0 -4
- package/esm/renderers/index.js.map +0 -1
- package/esm/renderers/svg/defs/arrow.d.ts +0 -15
- package/esm/renderers/svg/defs/arrow.js +0 -68
- package/esm/renderers/svg/defs/arrow.js.map +0 -1
- package/esm/renderers/svg/defs/clip.d.ts +0 -12
- package/esm/renderers/svg/defs/clip.js +0 -29
- package/esm/renderers/svg/defs/clip.js.map +0 -1
- package/esm/renderers/svg/defs/gradient.d.ts +0 -10
- package/esm/renderers/svg/defs/gradient.js +0 -117
- package/esm/renderers/svg/defs/gradient.js.map +0 -1
- package/esm/renderers/svg/defs/pattern.d.ts +0 -10
- package/esm/renderers/svg/defs/pattern.js +0 -46
- package/esm/renderers/svg/defs/pattern.js.map +0 -1
- package/esm/renderers/svg/defs/shadow.d.ts +0 -13
- package/esm/renderers/svg/defs/shadow.js +0 -62
- package/esm/renderers/svg/defs/shadow.js.map +0 -1
- package/esm/renderers/svg/defs.d.ts +0 -18
- package/esm/renderers/svg/defs.js +0 -90
- package/esm/renderers/svg/defs.js.map +0 -1
- package/esm/renderers/svg/get-shape.d.ts +0 -1
- package/esm/renderers/svg/get-shape.js +0 -28
- package/esm/renderers/svg/get-shape.js.map +0 -1
- package/esm/renderers/svg/index.d.ts +0 -2
- package/esm/renderers/svg/index.js +0 -3
- package/esm/renderers/svg/index.js.map +0 -1
- package/esm/renderers/svg/painter.d.ts +0 -32
- package/esm/renderers/svg/painter.js +0 -695
- package/esm/renderers/svg/painter.js.map +0 -1
- package/esm/shapes/arc.d.ts +0 -25
- package/esm/shapes/arc.js +0 -107
- package/esm/shapes/arc.js.map +0 -1
- package/esm/shapes/circle.d.ts +0 -17
- package/esm/shapes/circle.js +0 -62
- package/esm/shapes/circle.js.map +0 -1
- package/esm/shapes/dom.d.ts +0 -10
- package/esm/shapes/dom.js +0 -35
- package/esm/shapes/dom.js.map +0 -1
- package/esm/shapes/ellipse.d.ts +0 -18
- package/esm/shapes/ellipse.js +0 -88
- package/esm/shapes/ellipse.js.map +0 -1
- package/esm/shapes/fan.d.ts +0 -21
- package/esm/shapes/fan.js +0 -151
- package/esm/shapes/fan.js.map +0 -1
- package/esm/shapes/image.d.ts +0 -24
- package/esm/shapes/image.js +0 -154
- package/esm/shapes/image.js.map +0 -1
- package/esm/shapes/index.d.ts +0 -13
- package/esm/shapes/index.js +0 -14
- package/esm/shapes/index.js.map +0 -1
- package/esm/shapes/interface.d.ts +0 -3
- package/esm/shapes/interface.js +0 -1
- package/esm/shapes/interface.js.map +0 -1
- package/esm/shapes/line.d.ts +0 -22
- package/esm/shapes/line.js +0 -70
- package/esm/shapes/line.js.map +0 -1
- package/esm/shapes/marker/index.d.ts +0 -30
- package/esm/shapes/marker/index.js +0 -90
- package/esm/shapes/marker/index.js.map +0 -1
- package/esm/shapes/marker/symbols.d.ts +0 -14
- package/esm/shapes/marker/symbols.js +0 -39
- package/esm/shapes/marker/symbols.js.map +0 -1
- package/esm/shapes/math/arc.d.ts +0 -6
- package/esm/shapes/math/arc.js +0 -113
- package/esm/shapes/math/arc.js.map +0 -1
- package/esm/shapes/math/cubic.d.ts +0 -7
- package/esm/shapes/math/cubic.js +0 -141
- package/esm/shapes/math/cubic.js.map +0 -1
- package/esm/shapes/math/ellipse.d.ts +0 -4
- package/esm/shapes/math/ellipse.js +0 -13
- package/esm/shapes/math/ellipse.js.map +0 -1
- package/esm/shapes/math/line.d.ts +0 -5
- package/esm/shapes/math/line.js +0 -23
- package/esm/shapes/math/line.js.map +0 -1
- package/esm/shapes/math/quadratic.d.ts +0 -5
- package/esm/shapes/math/quadratic.js +0 -74
- package/esm/shapes/math/quadratic.js.map +0 -1
- package/esm/shapes/path.d.ts +0 -25
- package/esm/shapes/path.js +0 -270
- package/esm/shapes/path.js.map +0 -1
- package/esm/shapes/polygon.d.ts +0 -15
- package/esm/shapes/polygon.js +0 -103
- package/esm/shapes/polygon.js.map +0 -1
- package/esm/shapes/polyline.d.ts +0 -24
- package/esm/shapes/polyline.js +0 -171
- package/esm/shapes/polyline.js.map +0 -1
- package/esm/shapes/rect.d.ts +0 -19
- package/esm/shapes/rect.js +0 -107
- package/esm/shapes/rect.js.map +0 -1
- package/esm/shapes/text.d.ts +0 -35
- package/esm/shapes/text.js +0 -262
- package/esm/shapes/text.js.map +0 -1
- package/esm/shapes/util/arrow.d.ts +0 -3
- package/esm/shapes/util/arrow.js +0 -131
- package/esm/shapes/util/arrow.js.map +0 -1
- package/esm/shapes/util/inside.d.ts +0 -9
- package/esm/shapes/util/inside.js +0 -50
- package/esm/shapes/util/inside.js.map +0 -1
- package/esm/shapes/util/is-point-in-path-by-ctx.d.ts +0 -2
- package/esm/shapes/util/is-point-in-path-by-ctx.js +0 -14
- package/esm/shapes/util/is-point-in-path-by-ctx.js.map +0 -1
- package/esm/shapes/util/path-segment.d.ts +0 -18
- package/esm/shapes/util/path-segment.js +0 -594
- package/esm/shapes/util/path-segment.js.map +0 -1
- package/esm/util/format.d.ts +0 -7
- package/esm/util/format.js +0 -60
- package/esm/util/format.js.map +0 -1
- package/esm/util/path.d.ts +0 -11
- package/esm/util/path.js +0 -1327
- package/esm/util/path.js.map +0 -1
- package/lib/canvas.d.ts +0 -46
- package/lib/canvas.js +0 -385
- package/lib/canvas.js.map +0 -1
- package/lib/core/attribute.d.ts +0 -49
- package/lib/core/attribute.js +0 -279
- package/lib/core/attribute.js.map +0 -1
- package/lib/core/base.d.ts +0 -32
- package/lib/core/base.js +0 -192
- package/lib/core/base.js.map +0 -1
- package/lib/core/bbox.d.ts +0 -22
- package/lib/core/bbox.js +0 -36
- package/lib/core/bbox.js.map +0 -1
- package/lib/core/element.d.ts +0 -19
- package/lib/core/element.js +0 -205
- package/lib/core/element.js.map +0 -1
- package/lib/core/group.d.ts +0 -72
- package/lib/core/group.js +0 -439
- package/lib/core/group.js.map +0 -1
- package/lib/core/shape.d.ts +0 -35
- package/lib/core/shape.js +0 -160
- package/lib/core/shape.js.map +0 -1
- package/lib/core/timeline.d.ts +0 -15
- package/lib/core/timeline.js +0 -181
- package/lib/core/timeline.js.map +0 -1
- package/lib/event.d.ts +0 -25
- package/lib/event.js +0 -39
- package/lib/event.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interface.d.ts +0 -18
- package/lib/interface.js +0 -3
- package/lib/interface.js.map +0 -1
- package/lib/renderers/canvas/index.d.ts +0 -1
- package/lib/renderers/canvas/index.js +0 -5
- package/lib/renderers/canvas/index.js.map +0 -1
- package/lib/renderers/canvas/painter.d.ts +0 -17
- package/lib/renderers/canvas/painter.js +0 -159
- package/lib/renderers/canvas/painter.js.map +0 -1
- package/lib/renderers/canvas/util.d.ts +0 -2
- package/lib/renderers/canvas/util.js +0 -192
- package/lib/renderers/canvas/util.js.map +0 -1
- package/lib/renderers/index.d.ts +0 -3
- package/lib/renderers/index.js +0 -8
- package/lib/renderers/index.js.map +0 -1
- package/lib/renderers/svg/defs/arrow.d.ts +0 -15
- package/lib/renderers/svg/defs/arrow.js +0 -70
- package/lib/renderers/svg/defs/arrow.js.map +0 -1
- package/lib/renderers/svg/defs/clip.d.ts +0 -12
- package/lib/renderers/svg/defs/clip.js +0 -31
- package/lib/renderers/svg/defs/clip.js.map +0 -1
- package/lib/renderers/svg/defs/gradient.d.ts +0 -10
- package/lib/renderers/svg/defs/gradient.js +0 -119
- package/lib/renderers/svg/defs/gradient.js.map +0 -1
- package/lib/renderers/svg/defs/pattern.d.ts +0 -10
- package/lib/renderers/svg/defs/pattern.js +0 -48
- package/lib/renderers/svg/defs/pattern.js.map +0 -1
- package/lib/renderers/svg/defs/shadow.d.ts +0 -13
- package/lib/renderers/svg/defs/shadow.js +0 -64
- package/lib/renderers/svg/defs/shadow.js.map +0 -1
- package/lib/renderers/svg/defs.d.ts +0 -18
- package/lib/renderers/svg/defs.js +0 -92
- package/lib/renderers/svg/defs.js.map +0 -1
- package/lib/renderers/svg/get-shape.d.ts +0 -1
- package/lib/renderers/svg/get-shape.js +0 -31
- package/lib/renderers/svg/get-shape.js.map +0 -1
- package/lib/renderers/svg/index.d.ts +0 -2
- package/lib/renderers/svg/index.js +0 -7
- package/lib/renderers/svg/index.js.map +0 -1
- package/lib/renderers/svg/painter.d.ts +0 -32
- package/lib/renderers/svg/painter.js +0 -697
- package/lib/renderers/svg/painter.js.map +0 -1
- package/lib/shapes/arc.d.ts +0 -25
- package/lib/shapes/arc.js +0 -109
- package/lib/shapes/arc.js.map +0 -1
- package/lib/shapes/circle.d.ts +0 -17
- package/lib/shapes/circle.js +0 -64
- package/lib/shapes/circle.js.map +0 -1
- package/lib/shapes/dom.d.ts +0 -10
- package/lib/shapes/dom.js +0 -37
- package/lib/shapes/dom.js.map +0 -1
- package/lib/shapes/ellipse.d.ts +0 -18
- package/lib/shapes/ellipse.js +0 -90
- package/lib/shapes/ellipse.js.map +0 -1
- package/lib/shapes/fan.d.ts +0 -21
- package/lib/shapes/fan.js +0 -153
- package/lib/shapes/fan.js.map +0 -1
- package/lib/shapes/image.d.ts +0 -24
- package/lib/shapes/image.js +0 -156
- package/lib/shapes/image.js.map +0 -1
- package/lib/shapes/index.js.map +0 -1
- package/lib/shapes/interface.d.ts +0 -3
- package/lib/shapes/interface.js +0 -3
- package/lib/shapes/interface.js.map +0 -1
- package/lib/shapes/line.d.ts +0 -22
- package/lib/shapes/line.js +0 -72
- package/lib/shapes/line.js.map +0 -1
- package/lib/shapes/marker/index.d.ts +0 -30
- package/lib/shapes/marker/index.js +0 -92
- package/lib/shapes/marker/index.js.map +0 -1
- package/lib/shapes/marker/symbols.d.ts +0 -14
- package/lib/shapes/marker/symbols.js +0 -41
- package/lib/shapes/marker/symbols.js.map +0 -1
- package/lib/shapes/math/arc.d.ts +0 -6
- package/lib/shapes/math/arc.js +0 -116
- package/lib/shapes/math/arc.js.map +0 -1
- package/lib/shapes/math/cubic.d.ts +0 -7
- package/lib/shapes/math/cubic.js +0 -149
- package/lib/shapes/math/cubic.js.map +0 -1
- package/lib/shapes/math/ellipse.d.ts +0 -4
- package/lib/shapes/math/ellipse.js +0 -20
- package/lib/shapes/math/ellipse.js.map +0 -1
- package/lib/shapes/math/line.d.ts +0 -5
- package/lib/shapes/math/line.js +0 -30
- package/lib/shapes/math/line.js.map +0 -1
- package/lib/shapes/math/quadratic.d.ts +0 -5
- package/lib/shapes/math/quadratic.js +0 -81
- package/lib/shapes/math/quadratic.js.map +0 -1
- package/lib/shapes/path.d.ts +0 -25
- package/lib/shapes/path.js +0 -272
- package/lib/shapes/path.js.map +0 -1
- package/lib/shapes/polygon.d.ts +0 -15
- package/lib/shapes/polygon.js +0 -105
- package/lib/shapes/polygon.js.map +0 -1
- package/lib/shapes/polyline.d.ts +0 -24
- package/lib/shapes/polyline.js +0 -173
- package/lib/shapes/polyline.js.map +0 -1
- package/lib/shapes/rect.d.ts +0 -19
- package/lib/shapes/rect.js +0 -109
- package/lib/shapes/rect.js.map +0 -1
- package/lib/shapes/text.d.ts +0 -35
- package/lib/shapes/text.js +0 -264
- package/lib/shapes/text.js.map +0 -1
- package/lib/shapes/util/arrow.d.ts +0 -3
- package/lib/shapes/util/arrow.js +0 -136
- package/lib/shapes/util/arrow.js.map +0 -1
- package/lib/shapes/util/inside.d.ts +0 -9
- package/lib/shapes/util/inside.js +0 -61
- package/lib/shapes/util/inside.js.map +0 -1
- package/lib/shapes/util/is-point-in-path-by-ctx.d.ts +0 -2
- package/lib/shapes/util/is-point-in-path-by-ctx.js +0 -17
- package/lib/shapes/util/is-point-in-path-by-ctx.js.map +0 -1
- package/lib/shapes/util/path-segment.d.ts +0 -18
- package/lib/shapes/util/path-segment.js +0 -596
- package/lib/shapes/util/path-segment.js.map +0 -1
- package/lib/util/format.d.ts +0 -7
- package/lib/util/format.js +0 -65
- package/lib/util/format.js.map +0 -1
- package/lib/util/path.d.ts +0 -11
- package/lib/util/path.js +0 -1339
- package/lib/util/path.js.map +0 -1
|
@@ -1,695 +0,0 @@
|
|
|
1
|
-
import * as Util from '@antv/util';
|
|
2
|
-
import { detect } from 'detect-browser';
|
|
3
|
-
import Defs from './defs';
|
|
4
|
-
import { parseRadius } from '../../util/format';
|
|
5
|
-
import Marker from '../../shapes/marker';
|
|
6
|
-
var symbolsFactory = Marker.symbolsFactory;
|
|
7
|
-
var SHAPE_TO_TAGS = {
|
|
8
|
-
rect: 'path',
|
|
9
|
-
circle: 'circle',
|
|
10
|
-
line: 'line',
|
|
11
|
-
path: 'path',
|
|
12
|
-
marker: 'path',
|
|
13
|
-
text: 'text',
|
|
14
|
-
polygon: 'polygon',
|
|
15
|
-
image: 'image',
|
|
16
|
-
ellipse: 'ellipse',
|
|
17
|
-
dom: 'foreignObject',
|
|
18
|
-
fan: 'path',
|
|
19
|
-
group: 'g',
|
|
20
|
-
};
|
|
21
|
-
var LETTER_SPACING = 0.3;
|
|
22
|
-
var SVG_ATTR_MAP = {
|
|
23
|
-
opacity: 'opacity',
|
|
24
|
-
fillStyle: 'fill',
|
|
25
|
-
strokeOpacity: 'stroke-opacity',
|
|
26
|
-
fillOpacity: 'fill-opacity',
|
|
27
|
-
strokeStyle: 'stroke',
|
|
28
|
-
x: 'x',
|
|
29
|
-
y: 'y',
|
|
30
|
-
r: 'r',
|
|
31
|
-
width: 'width',
|
|
32
|
-
height: 'height',
|
|
33
|
-
x1: 'x1',
|
|
34
|
-
x2: 'x2',
|
|
35
|
-
y1: 'y1',
|
|
36
|
-
y2: 'y2',
|
|
37
|
-
lineCap: 'stroke-linecap',
|
|
38
|
-
lineJoin: 'stroke-linejoin',
|
|
39
|
-
lineWidth: 'stroke-width',
|
|
40
|
-
lineDash: 'stroke-dasharray',
|
|
41
|
-
lineDashOffset: 'stroke-dashoffset',
|
|
42
|
-
miterLimit: 'stroke-miterlimit',
|
|
43
|
-
font: 'font',
|
|
44
|
-
fontSize: 'font-size',
|
|
45
|
-
fontStyle: 'font-style',
|
|
46
|
-
fontVariant: 'font-variant',
|
|
47
|
-
fontWeight: 'font-weight',
|
|
48
|
-
fontFamily: 'font-family',
|
|
49
|
-
startArrow: 'marker-start',
|
|
50
|
-
endArrow: 'marker-end',
|
|
51
|
-
path: 'd',
|
|
52
|
-
class: 'class',
|
|
53
|
-
id: 'id',
|
|
54
|
-
style: 'style',
|
|
55
|
-
preserveAspectRatio: 'preserveAspectRatio',
|
|
56
|
-
};
|
|
57
|
-
var BASELINE_MAP = {
|
|
58
|
-
top: 'before-edge',
|
|
59
|
-
middle: 'central',
|
|
60
|
-
bottom: 'after-edge',
|
|
61
|
-
alphabetic: 'baseline',
|
|
62
|
-
hanging: 'hanging',
|
|
63
|
-
};
|
|
64
|
-
var BASELINE_MAP_FOR_FIREFOX = {
|
|
65
|
-
top: 'text-before-edge',
|
|
66
|
-
middle: 'central',
|
|
67
|
-
bottom: 'text-after-edge',
|
|
68
|
-
alphabetic: 'alphabetic',
|
|
69
|
-
hanging: 'hanging',
|
|
70
|
-
};
|
|
71
|
-
var ANCHOR_MAP = {
|
|
72
|
-
left: 'left',
|
|
73
|
-
start: 'left',
|
|
74
|
-
center: 'middle',
|
|
75
|
-
right: 'end',
|
|
76
|
-
end: 'end',
|
|
77
|
-
};
|
|
78
|
-
var Painter = /** @class */ (function () {
|
|
79
|
-
function Painter(dom) {
|
|
80
|
-
this.toDraw = false;
|
|
81
|
-
this.type = 'svg';
|
|
82
|
-
this.removed = false;
|
|
83
|
-
this.destroyed = false;
|
|
84
|
-
if (!dom) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
var svgId = Util.uniqueId('canvas_');
|
|
88
|
-
var canvasDom = Util.createDom("<svg id=\"" + svgId + "\"></svg>");
|
|
89
|
-
dom.appendChild(canvasDom);
|
|
90
|
-
this.type = 'svg';
|
|
91
|
-
this.canvas = canvasDom;
|
|
92
|
-
this.context = new Defs(canvasDom);
|
|
93
|
-
this.toDraw = false;
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
Painter.prototype.draw = function (model) {
|
|
97
|
-
var self = this;
|
|
98
|
-
function drawInner() {
|
|
99
|
-
self.animateHandler = Util.requestAnimationFrame(function () {
|
|
100
|
-
self.animateHandler = undefined;
|
|
101
|
-
if (self.toDraw) {
|
|
102
|
-
drawInner();
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
try {
|
|
106
|
-
self._drawChildren(model);
|
|
107
|
-
}
|
|
108
|
-
catch (ev) {
|
|
109
|
-
// 绘制时异常,中断重绘
|
|
110
|
-
console.warn('error in draw canvas, detail as:');
|
|
111
|
-
console.warn(ev);
|
|
112
|
-
}
|
|
113
|
-
finally {
|
|
114
|
-
self.toDraw = false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (self.animateHandler) {
|
|
118
|
-
self.toDraw = true;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
drawInner();
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
Painter.prototype.drawSync = function (model) {
|
|
125
|
-
this._drawChildren(model);
|
|
126
|
-
};
|
|
127
|
-
Painter.prototype._drawGroup = function (model, index) {
|
|
128
|
-
var cfg = model.cfg;
|
|
129
|
-
if (model.removed || model.destroyed) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (cfg.tobeRemoved) {
|
|
133
|
-
Util.each(cfg.tobeRemoved, function (item) {
|
|
134
|
-
if (item.parentNode) {
|
|
135
|
-
item.parentNode.removeChild(item);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
cfg.tobeRemoved = [];
|
|
139
|
-
}
|
|
140
|
-
this._drawShape(model, index);
|
|
141
|
-
if (cfg.children && cfg.children.length > 0) {
|
|
142
|
-
this._drawChildren(model);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
Painter.prototype._drawChildren = function (parent) {
|
|
146
|
-
var self = this;
|
|
147
|
-
var children = parent.cfg.children;
|
|
148
|
-
var shape;
|
|
149
|
-
// 防止在画children的时候,父group已经被destroy
|
|
150
|
-
if (!children) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
for (var i = 0; i < children.length; i++) {
|
|
154
|
-
shape = children[i];
|
|
155
|
-
if (shape.isGroup) {
|
|
156
|
-
self._drawGroup(shape, i);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
self._drawShape(shape, i);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
Painter.prototype._drawShape = function (model, index) {
|
|
164
|
-
var self = this;
|
|
165
|
-
var attrs = model.attrs;
|
|
166
|
-
var cfg = model.cfg;
|
|
167
|
-
var el = cfg.el;
|
|
168
|
-
// 删除
|
|
169
|
-
if (model.removed || model.destroyed) {
|
|
170
|
-
if (el) {
|
|
171
|
-
el.parentNode.removeChild(cfg.el);
|
|
172
|
-
}
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
// 新增节点
|
|
176
|
-
if (!el && cfg.parent) {
|
|
177
|
-
self._createDom(model, index);
|
|
178
|
-
self._updateShape(model);
|
|
179
|
-
}
|
|
180
|
-
el = cfg.el;
|
|
181
|
-
if (cfg.visible === false) {
|
|
182
|
-
el.setAttribute('visibility', 'hidden');
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (cfg.visible && el.hasAttribute('visibility')) {
|
|
186
|
-
el.removeAttribute('visibility');
|
|
187
|
-
}
|
|
188
|
-
// 更新
|
|
189
|
-
if (cfg.hasUpdate) {
|
|
190
|
-
self._updateShape(model);
|
|
191
|
-
}
|
|
192
|
-
if (attrs.clip && attrs.clip.cfg.hasUpdate) {
|
|
193
|
-
self._updateShape(attrs.clip);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
Painter.prototype._updateShape = function (model) {
|
|
197
|
-
var self = this;
|
|
198
|
-
var attrs = model.attrs;
|
|
199
|
-
var formerAttrs = model.cfg.attrs;
|
|
200
|
-
if (!formerAttrs) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (!model.cfg.el) {
|
|
204
|
-
self._createDom(model);
|
|
205
|
-
}
|
|
206
|
-
if ('clip' in attrs) {
|
|
207
|
-
this._setClip(model, attrs.clip);
|
|
208
|
-
}
|
|
209
|
-
if ('shadowOffsetX' in attrs || 'shadowOffsetY' in attrs || 'shadowBlur' in attrs || 'shadowColor' in attrs) {
|
|
210
|
-
this._setShadow(model);
|
|
211
|
-
}
|
|
212
|
-
if (model.type === 'text') {
|
|
213
|
-
self._updateText(model);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
if (model.type === 'fan') {
|
|
217
|
-
self._updateFan(model);
|
|
218
|
-
}
|
|
219
|
-
if (model.type === 'marker') {
|
|
220
|
-
model.cfg.el.setAttribute('d', self._assembleMarker(model, attrs));
|
|
221
|
-
}
|
|
222
|
-
if (model.type === 'rect') {
|
|
223
|
-
model.cfg.el.setAttribute('d', self._assembleRect(attrs));
|
|
224
|
-
}
|
|
225
|
-
for (var key in attrs) {
|
|
226
|
-
if (attrs[key] !== formerAttrs[key]) {
|
|
227
|
-
self._setAttribute(model, key, attrs[key]);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
model.cfg.attrs = Util.deepMix({}, model.attrs);
|
|
231
|
-
model.cfg.hasUpdate = false;
|
|
232
|
-
};
|
|
233
|
-
Painter.prototype._setAttribute = function (model, name, value) {
|
|
234
|
-
var type = model.type;
|
|
235
|
-
var attrs = model.attrs;
|
|
236
|
-
var el = model.cfg.el;
|
|
237
|
-
var defs = this.context;
|
|
238
|
-
// 计算marker路径
|
|
239
|
-
if ((type === 'marker' || type === 'rect') && ~['x', 'y', 'radius', 'r'].indexOf(name)) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
// 圆和椭圆不是x, y, 是cx, cy。 marker的x,y 用于计算marker的路径,不需要写到dom
|
|
243
|
-
if (~['circle', 'ellipse'].indexOf(type) && ~['x', 'y'].indexOf(name)) {
|
|
244
|
-
el.setAttribute('c' + name, parseInt(value, 10));
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
// 多边形
|
|
248
|
-
if (type === 'polygon' && name === 'points') {
|
|
249
|
-
if (!value || value.length === 0) {
|
|
250
|
-
value = '';
|
|
251
|
-
}
|
|
252
|
-
if (Util.isArray(value)) {
|
|
253
|
-
value = value.map(function (point) { return point[0] + ',' + point[1]; });
|
|
254
|
-
value = value.join(' ');
|
|
255
|
-
}
|
|
256
|
-
el.setAttribute('points', value);
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
// 设置path
|
|
260
|
-
if (name === 'path') {
|
|
261
|
-
if (Util.isArray(value)) {
|
|
262
|
-
el.setAttribute('d', this._formatPath(value));
|
|
263
|
-
}
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
// 设置图片
|
|
267
|
-
if (name === 'img') {
|
|
268
|
-
this._setImage(model, value);
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
if (name === 'transform') {
|
|
272
|
-
if (!value) {
|
|
273
|
-
el.removeAttribute('transform');
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
this._setTransform(model);
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
if (name === 'rotate') {
|
|
280
|
-
if (!value) {
|
|
281
|
-
el.removeAttribute('transform');
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
this._setTransform(model);
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
if (name === 'matrix') {
|
|
288
|
-
this._setTransform(model);
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
if (name === 'fillStyle' || name === 'strokeStyle') {
|
|
292
|
-
this._setColor(model, name, value);
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
if (name === 'clip') {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
if (~name.indexOf('Arrow')) {
|
|
299
|
-
name = SVG_ATTR_MAP[name];
|
|
300
|
-
if (!value) {
|
|
301
|
-
model.cfg[name] = null;
|
|
302
|
-
el.removeAttribute(name);
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
var id = null;
|
|
306
|
-
if (typeof value === 'boolean') {
|
|
307
|
-
id = defs.getDefaultArrow(attrs, name);
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
id = defs.addArrow(attrs, name);
|
|
311
|
-
}
|
|
312
|
-
el.setAttribute(name, "url(#" + id + ")");
|
|
313
|
-
model.cfg[name] = id;
|
|
314
|
-
}
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
// foreignObject
|
|
318
|
-
if (name === 'html') {
|
|
319
|
-
if (typeof value === 'string') {
|
|
320
|
-
el.innerHTML = value;
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
el.innerHTML = '';
|
|
324
|
-
el.appendChild(value);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
if (SVG_ATTR_MAP[name]) {
|
|
328
|
-
el.setAttribute(SVG_ATTR_MAP[name], value);
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
Painter.prototype._createDom = function (model, index) {
|
|
332
|
-
var type = SHAPE_TO_TAGS[model.type];
|
|
333
|
-
var attrs = model.attrs;
|
|
334
|
-
var parent = model.cfg.parent;
|
|
335
|
-
if (!type) {
|
|
336
|
-
throw new Error('the type' + model.type + 'is not supported by svg');
|
|
337
|
-
}
|
|
338
|
-
var shape = document.createElementNS('http://www.w3.org/2000/svg', type);
|
|
339
|
-
if (model.cfg.id) {
|
|
340
|
-
shape.id = model.cfg.id;
|
|
341
|
-
}
|
|
342
|
-
model.cfg.el = shape;
|
|
343
|
-
if (parent) {
|
|
344
|
-
var parentNode = parent.cfg.el;
|
|
345
|
-
if (typeof index === 'undefined') {
|
|
346
|
-
parentNode.appendChild(shape);
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
var childNodes = parent.cfg.el.childNodes;
|
|
350
|
-
// svg下天然有defs作为子节点,svg下子元素index需要+1
|
|
351
|
-
if (parentNode.tagName === 'svg') {
|
|
352
|
-
index += 1;
|
|
353
|
-
}
|
|
354
|
-
if (childNodes.length <= index) {
|
|
355
|
-
parentNode.appendChild(shape);
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
parentNode.insertBefore(shape, childNodes[index]);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
model.cfg.attrs = {};
|
|
363
|
-
if (model.type === 'text') {
|
|
364
|
-
shape.setAttribute('paint-order', 'stroke');
|
|
365
|
-
shape.setAttribute('style', 'stroke-linecap:butt; stroke-linejoin:miter;');
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
if (!attrs.stroke && !attrs.strokeStyle) {
|
|
369
|
-
shape.setAttribute('stroke', 'none');
|
|
370
|
-
}
|
|
371
|
-
if (!attrs.fill && !attrs.fillStyle) {
|
|
372
|
-
shape.setAttribute('fill', 'none');
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
return shape;
|
|
376
|
-
};
|
|
377
|
-
Painter.prototype._assembleMarker = function (marker, attrs) {
|
|
378
|
-
var d = marker._getPath();
|
|
379
|
-
if (Util.isArray(d)) {
|
|
380
|
-
return d
|
|
381
|
-
.map(function (path) {
|
|
382
|
-
return path.join(' ');
|
|
383
|
-
})
|
|
384
|
-
.join('');
|
|
385
|
-
}
|
|
386
|
-
return d;
|
|
387
|
-
};
|
|
388
|
-
Painter.prototype._assembleRect = function (attrs) {
|
|
389
|
-
var x = attrs.x;
|
|
390
|
-
var y = attrs.y;
|
|
391
|
-
var w = attrs.width;
|
|
392
|
-
var h = attrs.height;
|
|
393
|
-
var radius = attrs.radius;
|
|
394
|
-
if (!radius) {
|
|
395
|
-
return "M " + x + "," + y + " l " + w + ",0 l 0," + h + " l" + -w + " 0 z";
|
|
396
|
-
}
|
|
397
|
-
var r = parseRadius(radius);
|
|
398
|
-
if (Util.isArray(radius)) {
|
|
399
|
-
if (radius.length === 1) {
|
|
400
|
-
r.r1 = r.r2 = r.r3 = r.r4 = radius[0];
|
|
401
|
-
}
|
|
402
|
-
else if (radius.length === 2) {
|
|
403
|
-
r.r1 = r.r3 = radius[0];
|
|
404
|
-
r.r2 = r.r4 = radius[1];
|
|
405
|
-
}
|
|
406
|
-
else if (radius.length === 3) {
|
|
407
|
-
r.r1 = radius[0];
|
|
408
|
-
r.r2 = r.r4 = radius[1];
|
|
409
|
-
r.r3 = radius[2];
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
r.r1 = radius[0];
|
|
413
|
-
r.r2 = radius[1];
|
|
414
|
-
r.r3 = radius[2];
|
|
415
|
-
r.r4 = radius[3];
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
r.r1 = r.r2 = r.r3 = r.r4 = radius;
|
|
420
|
-
}
|
|
421
|
-
var d = [
|
|
422
|
-
["M " + (x + r.r1) + "," + y],
|
|
423
|
-
["l " + (w - r.r1 - r.r2) + ",0"],
|
|
424
|
-
["a " + r.r2 + "," + r.r2 + ",0,0,1," + r.r2 + "," + r.r2],
|
|
425
|
-
["l 0," + (h - r.r2 - r.r3)],
|
|
426
|
-
["a " + r.r3 + "," + r.r3 + ",0,0,1," + -r.r3 + "," + r.r3],
|
|
427
|
-
["l " + (r.r3 + r.r4 - w) + ",0"],
|
|
428
|
-
["a " + r.r4 + "," + r.r4 + ",0,0,1," + -r.r4 + "," + -r.r4],
|
|
429
|
-
["l 0," + (r.r4 + r.r1 - h)],
|
|
430
|
-
["a " + r.r1 + "," + r.r1 + ",0,0,1," + r.r1 + "," + -r.r1],
|
|
431
|
-
['z'],
|
|
432
|
-
];
|
|
433
|
-
return d.join(' ');
|
|
434
|
-
};
|
|
435
|
-
Painter.prototype._formatPath = function (value) {
|
|
436
|
-
value = value
|
|
437
|
-
.map(function (path) {
|
|
438
|
-
return path.join(' ');
|
|
439
|
-
})
|
|
440
|
-
.join('');
|
|
441
|
-
if (~value.indexOf('NaN')) {
|
|
442
|
-
return '';
|
|
443
|
-
}
|
|
444
|
-
return value;
|
|
445
|
-
};
|
|
446
|
-
Painter.prototype._setTransform = function (model) {
|
|
447
|
-
var matrix = model.attrs.matrix;
|
|
448
|
-
var el = model.cfg.el;
|
|
449
|
-
var transform = [];
|
|
450
|
-
for (var i = 0; i < 9; i += 3) {
|
|
451
|
-
transform.push(matrix[i] + ',' + matrix[i + 1]);
|
|
452
|
-
}
|
|
453
|
-
transform = transform.join(',');
|
|
454
|
-
if (transform.indexOf('NaN') === -1) {
|
|
455
|
-
el.setAttribute('transform', "matrix(" + transform + ")");
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
console.warn('invalid matrix:', matrix);
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
Painter.prototype._setImage = function (model, img) {
|
|
462
|
-
var attrs = model.attrs;
|
|
463
|
-
var el = model.cfg.el;
|
|
464
|
-
if (Util.isString(img)) {
|
|
465
|
-
el.setAttribute('href', img);
|
|
466
|
-
}
|
|
467
|
-
else if (img instanceof Image) {
|
|
468
|
-
if (!attrs.width) {
|
|
469
|
-
el.setAttribute('width', img.width);
|
|
470
|
-
model.attrs.width = img.width;
|
|
471
|
-
}
|
|
472
|
-
if (!attrs.height) {
|
|
473
|
-
el.setAttribute('height', img.height);
|
|
474
|
-
model.attrs.height = img.height;
|
|
475
|
-
}
|
|
476
|
-
el.setAttribute('href', img.src);
|
|
477
|
-
}
|
|
478
|
-
else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
|
|
479
|
-
// @ts-ignore
|
|
480
|
-
el.setAttribute('href', img.toDataURL());
|
|
481
|
-
}
|
|
482
|
-
else if (img instanceof ImageData) {
|
|
483
|
-
var canvas = document.createElement('canvas');
|
|
484
|
-
canvas.setAttribute('width', "" + img.width);
|
|
485
|
-
canvas.setAttribute('height', "" + img.height);
|
|
486
|
-
canvas.getContext('2d').putImageData(img, 0, 0);
|
|
487
|
-
if (!attrs.width) {
|
|
488
|
-
el.setAttribute('width', img.width);
|
|
489
|
-
model.attrs.width = img.width;
|
|
490
|
-
}
|
|
491
|
-
if (!attrs.height) {
|
|
492
|
-
el.setAttribute('height', img.height);
|
|
493
|
-
model.attrs.height = img.height;
|
|
494
|
-
}
|
|
495
|
-
el.setAttribute('href', canvas.toDataURL());
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
Painter.prototype._updateFan = function (model) {
|
|
499
|
-
function getPoint(angle, radius, center) {
|
|
500
|
-
return {
|
|
501
|
-
x: radius * Math.cos(angle) + center.x,
|
|
502
|
-
y: radius * Math.sin(angle) + center.y,
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
var attrs = model.attrs;
|
|
506
|
-
var cfg = model.cfg;
|
|
507
|
-
var center = {
|
|
508
|
-
x: attrs.x,
|
|
509
|
-
y: attrs.y,
|
|
510
|
-
};
|
|
511
|
-
var d = [];
|
|
512
|
-
var startAngle = attrs.startAngle;
|
|
513
|
-
var endAngle = attrs.endAngle;
|
|
514
|
-
if (Util.isNumberEqual(endAngle - startAngle, Math.PI * 2)) {
|
|
515
|
-
endAngle -= 0.00001;
|
|
516
|
-
}
|
|
517
|
-
var outerStart = getPoint(startAngle, attrs.re, center);
|
|
518
|
-
var outerEnd = getPoint(endAngle, attrs.re, center);
|
|
519
|
-
var fa = endAngle > startAngle ? 1 : 0;
|
|
520
|
-
var fs = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
|
|
521
|
-
var rs = attrs.rs;
|
|
522
|
-
var re = attrs.re;
|
|
523
|
-
var innerStart = getPoint(startAngle, attrs.rs, center);
|
|
524
|
-
var innerEnd = getPoint(endAngle, attrs.rs, center);
|
|
525
|
-
if (attrs.rs > 0) {
|
|
526
|
-
d.push("M " + outerEnd.x + "," + outerEnd.y);
|
|
527
|
-
d.push("L " + innerEnd.x + "," + innerEnd.y);
|
|
528
|
-
d.push("A " + rs + "," + rs + ",0," + fs + "," + (fa === 1 ? 0 : 1) + "," + innerStart.x + "," + innerStart.y);
|
|
529
|
-
d.push("L " + outerStart.x + " " + outerStart.y);
|
|
530
|
-
}
|
|
531
|
-
else {
|
|
532
|
-
d.push("M " + center.x + "," + center.y);
|
|
533
|
-
d.push("L " + outerStart.x + "," + outerStart.y);
|
|
534
|
-
}
|
|
535
|
-
d.push("A " + re + "," + re + ",0," + fs + "," + fa + "," + outerEnd.x + "," + outerEnd.y);
|
|
536
|
-
if (attrs.rs > 0) {
|
|
537
|
-
d.push("L " + innerEnd.x + "," + innerEnd.y);
|
|
538
|
-
}
|
|
539
|
-
else {
|
|
540
|
-
d.push('Z');
|
|
541
|
-
}
|
|
542
|
-
cfg.el.setAttribute('d', d.join(' '));
|
|
543
|
-
};
|
|
544
|
-
Painter.prototype._updateText = function (model) {
|
|
545
|
-
var self = this;
|
|
546
|
-
var attrs = model.attrs;
|
|
547
|
-
var formerAttrs = model.cfg.attrs;
|
|
548
|
-
var el = model.cfg.el;
|
|
549
|
-
this._setFont(model);
|
|
550
|
-
for (var attr in attrs) {
|
|
551
|
-
if (attrs[attr] !== formerAttrs[attr]) {
|
|
552
|
-
if (attr === 'text') {
|
|
553
|
-
self._setText(model, "" + attrs[attr]);
|
|
554
|
-
continue;
|
|
555
|
-
}
|
|
556
|
-
if (attr === 'fillStyle' || attr === 'strokeStyle') {
|
|
557
|
-
this._setColor(model, attr, attrs[attr]);
|
|
558
|
-
continue;
|
|
559
|
-
}
|
|
560
|
-
if (attr === 'matrix') {
|
|
561
|
-
this._setTransform(model);
|
|
562
|
-
continue;
|
|
563
|
-
}
|
|
564
|
-
if (SVG_ATTR_MAP[attr]) {
|
|
565
|
-
el.setAttribute(SVG_ATTR_MAP[attr], attrs[attr]);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
model.cfg.attrs = Object.assign({}, model.attrs);
|
|
570
|
-
model.cfg.hasUpdate = false;
|
|
571
|
-
};
|
|
572
|
-
Painter.prototype._setFont = function (model) {
|
|
573
|
-
var el = model.get('el');
|
|
574
|
-
var attrs = model.attrs;
|
|
575
|
-
var fontSize = attrs.fontSize;
|
|
576
|
-
var browser = detect();
|
|
577
|
-
if (browser && browser.name === 'firefox') {
|
|
578
|
-
// compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
|
|
579
|
-
el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[attrs.textBaseline] || 'alphabetic');
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
el.setAttribute('alignment-baseline', BASELINE_MAP[attrs.textBaseline] || 'baseline');
|
|
583
|
-
}
|
|
584
|
-
el.setAttribute('text-anchor', ANCHOR_MAP[attrs.textAlign] || 'left');
|
|
585
|
-
if (fontSize && +fontSize < 12) {
|
|
586
|
-
// 小于 12 像素的文本进行 scale 处理
|
|
587
|
-
attrs.matrix = [1, 0, 0, 0, 1, 0, 0, 0, 1];
|
|
588
|
-
model.transform([['t', -attrs.x, -attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', attrs.x, attrs.y]]);
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
Painter.prototype._setText = function (model, text) {
|
|
592
|
-
var el = model.cfg.el;
|
|
593
|
-
var baseline = model.attrs.textBaseline || 'bottom';
|
|
594
|
-
if (!text) {
|
|
595
|
-
el.innerHTML = '';
|
|
596
|
-
}
|
|
597
|
-
else if (~text.indexOf('\n')) {
|
|
598
|
-
var x_1 = model.attrs.x;
|
|
599
|
-
var textArr = text.split('\n');
|
|
600
|
-
var textLen_1 = textArr.length - 1;
|
|
601
|
-
var arr_1 = '';
|
|
602
|
-
Util.each(textArr, function (segment, i) {
|
|
603
|
-
if (i === 0) {
|
|
604
|
-
if (baseline === 'alphabetic') {
|
|
605
|
-
arr_1 += "<tspan x=\"" + x_1 + "\" dy=\"" + -textLen_1 + "em\">" + segment + "</tspan>";
|
|
606
|
-
}
|
|
607
|
-
else if (baseline === 'top') {
|
|
608
|
-
arr_1 += "<tspan x=\"" + x_1 + "\" dy=\"0.9em\">" + segment + "</tspan>";
|
|
609
|
-
}
|
|
610
|
-
else if (baseline === 'middle') {
|
|
611
|
-
arr_1 += "<tspan x=\"" + x_1 + "\" dy=\"" + -(textLen_1 - 1) / 2 + "em\">" + segment + "</tspan>";
|
|
612
|
-
}
|
|
613
|
-
else if (baseline === 'bottom') {
|
|
614
|
-
arr_1 += "<tspan x=\"" + x_1 + "\" dy=\"-" + (textLen_1 + LETTER_SPACING) + "em\">" + segment + "</tspan>";
|
|
615
|
-
}
|
|
616
|
-
else if (baseline === 'hanging') {
|
|
617
|
-
arr_1 += "<tspan x=\"" + x_1 + "\" dy=\"" + (-(textLen_1 - 1) - LETTER_SPACING) + "em\">" + segment + "</tspan>";
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
else {
|
|
621
|
-
arr_1 += "<tspan x=\"" + x_1 + "\" dy=\"1em\">" + segment + "</tspan>";
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
el.innerHTML = arr_1;
|
|
625
|
-
}
|
|
626
|
-
else {
|
|
627
|
-
el.innerHTML = text;
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
Painter.prototype._setClip = function (model, value) {
|
|
631
|
-
var el = model.cfg.el;
|
|
632
|
-
if (!value) {
|
|
633
|
-
el.removeAttribute('clip-path');
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
if (!el.hasAttribute('clip-path')) {
|
|
637
|
-
this._createDom(value);
|
|
638
|
-
this._updateShape(value);
|
|
639
|
-
var id = this.context.addClip(value);
|
|
640
|
-
el.setAttribute('clip-path', "url(#" + id + ")");
|
|
641
|
-
}
|
|
642
|
-
else if (value.cfg.hasUpdate) {
|
|
643
|
-
this._updateShape(value);
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
Painter.prototype._setColor = function (model, name, value) {
|
|
647
|
-
var el = model.cfg.el;
|
|
648
|
-
var defs = this.context;
|
|
649
|
-
if (!value) {
|
|
650
|
-
el.setAttribute(SVG_ATTR_MAP[name], 'none');
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
value = value.trim();
|
|
654
|
-
if (/^[r,R,L,l]{1}[\s]*\(/.test(value)) {
|
|
655
|
-
var id = defs.find('gradient', value);
|
|
656
|
-
if (!id) {
|
|
657
|
-
id = defs.addGradient(value);
|
|
658
|
-
}
|
|
659
|
-
el.setAttribute(SVG_ATTR_MAP[name], "url(#" + id + ")");
|
|
660
|
-
}
|
|
661
|
-
else if (/^[p,P]{1}[\s]*\(/.test(value)) {
|
|
662
|
-
var id = defs.find('pattern', value);
|
|
663
|
-
if (!id) {
|
|
664
|
-
id = defs.addPattern(value);
|
|
665
|
-
}
|
|
666
|
-
el.setAttribute(SVG_ATTR_MAP[name], "url(#" + id + ")");
|
|
667
|
-
}
|
|
668
|
-
else {
|
|
669
|
-
el.setAttribute(SVG_ATTR_MAP[name], value);
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
Painter.prototype._setShadow = function (model) {
|
|
673
|
-
var el = model.cfg.el;
|
|
674
|
-
var attrs = model.attrs;
|
|
675
|
-
var cfg = {
|
|
676
|
-
dx: attrs.shadowOffsetX,
|
|
677
|
-
dy: attrs.shadowOffsetY,
|
|
678
|
-
blur: attrs.shadowBlur,
|
|
679
|
-
color: attrs.shadowColor,
|
|
680
|
-
};
|
|
681
|
-
if (!cfg.dx && !cfg.dy && !cfg.blur && !cfg.color) {
|
|
682
|
-
el.removeAttribute('filter');
|
|
683
|
-
}
|
|
684
|
-
else {
|
|
685
|
-
var id = this.context.find('filter', cfg);
|
|
686
|
-
if (!id) {
|
|
687
|
-
id = this.context.addShadow(cfg);
|
|
688
|
-
}
|
|
689
|
-
el.setAttribute('filter', "url(#" + id + ")");
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
return Painter;
|
|
693
|
-
}());
|
|
694
|
-
export default Painter;
|
|
695
|
-
//# sourceMappingURL=painter.js.map
|