@vtx/ol-map 1.0.2-0

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.
Files changed (210) hide show
  1. package/README.md +202 -0
  2. package/lib/_util/filterSpecialCharacters.js +90 -0
  3. package/lib/_util/filterSpecialCharacters.js.map +1 -0
  4. package/lib/_util/getComponentProps.js +14 -0
  5. package/lib/_util/getComponentProps.js.map +1 -0
  6. package/lib/_util/getCookie.js +25 -0
  7. package/lib/_util/getCookie.js.map +1 -0
  8. package/lib/_util/getDefaultMapInfo.js +34 -0
  9. package/lib/_util/getDefaultMapInfo.js.map +1 -0
  10. package/lib/_util/getSystemInfo.js +27 -0
  11. package/lib/_util/getSystemInfo.js.map +1 -0
  12. package/lib/_util/getToken.js +14 -0
  13. package/lib/_util/getToken.js.map +1 -0
  14. package/lib/_util/getUrlParam.js +16 -0
  15. package/lib/_util/getUrlParam.js.map +1 -0
  16. package/lib/_util/http.js +235 -0
  17. package/lib/_util/http.js.map +1 -0
  18. package/lib/_util/isFunction.js +10 -0
  19. package/lib/_util/isFunction.js.map +1 -0
  20. package/lib/_util/isObject.js +10 -0
  21. package/lib/_util/isObject.js.map +1 -0
  22. package/lib/_util/layer.js +134 -0
  23. package/lib/_util/layer.js.map +1 -0
  24. package/lib/_util/mapTool.js +189 -0
  25. package/lib/_util/mapTool.js.map +1 -0
  26. package/lib/_util/setCookie.js +16 -0
  27. package/lib/_util/setCookie.js.map +1 -0
  28. package/lib/_util/useColSize.js +29 -0
  29. package/lib/_util/useColSize.js.map +1 -0
  30. package/lib/_util/useInterval.js +19 -0
  31. package/lib/_util/useInterval.js.map +1 -0
  32. package/lib/_util/useSet.js +45 -0
  33. package/lib/_util/useSet.js.map +1 -0
  34. package/lib/config.js +13 -0
  35. package/lib/config.js.map +1 -0
  36. package/lib/feature-layer/FeatureLayer.js +277 -0
  37. package/lib/feature-layer/FeatureLayer.js.map +1 -0
  38. package/lib/feature-layer/index.js +48 -0
  39. package/lib/feature-layer/index.js.map +1 -0
  40. package/lib/feature-layer/style/css.js +4 -0
  41. package/lib/feature-layer/style/css.js.map +1 -0
  42. package/lib/feature-layer/style/index.css +0 -0
  43. package/lib/feature-layer/style/index.js +4 -0
  44. package/lib/feature-layer/style/index.js.map +1 -0
  45. package/lib/feature-layer/style/index.less +0 -0
  46. package/lib/image-layer/ImageLayer.js +101 -0
  47. package/lib/image-layer/ImageLayer.js.map +1 -0
  48. package/lib/image-layer/index.js +44 -0
  49. package/lib/image-layer/index.js.map +1 -0
  50. package/lib/image-layer/style/css.js +4 -0
  51. package/lib/image-layer/style/css.js.map +1 -0
  52. package/lib/image-layer/style/index.css +0 -0
  53. package/lib/image-layer/style/index.js +4 -0
  54. package/lib/image-layer/style/index.js.map +1 -0
  55. package/lib/image-layer/style/index.less +0 -0
  56. package/lib/index.js +42 -0
  57. package/lib/index.js.map +1 -0
  58. package/lib/map/Popup.js +134 -0
  59. package/lib/map/Popup.js.map +1 -0
  60. package/lib/map/getBaseLayers.js +50 -0
  61. package/lib/map/getBaseLayers.js.map +1 -0
  62. package/lib/map/index.js +319 -0
  63. package/lib/map/index.js.map +1 -0
  64. package/lib/map/style/css.js +4 -0
  65. package/lib/map/style/css.js.map +1 -0
  66. package/lib/map/style/index.css +140 -0
  67. package/lib/map/style/index.js +4 -0
  68. package/lib/map/style/index.js.map +1 -0
  69. package/lib/map/style/index.less +128 -0
  70. package/lib/map-icon/Canvas.js +367 -0
  71. package/lib/map-icon/Canvas.js.map +1 -0
  72. package/lib/map-icon/CockpitIcon.js +317 -0
  73. package/lib/map-icon/CockpitIcon.js.map +1 -0
  74. package/lib/map-icon/CockpitIcon2.js +268 -0
  75. package/lib/map-icon/CockpitIcon2.js.map +1 -0
  76. package/lib/map-icon/CommonIcon.js +193 -0
  77. package/lib/map-icon/CommonIcon.js.map +1 -0
  78. package/lib/map-icon/CommonIcon2.js +164 -0
  79. package/lib/map-icon/CommonIcon2.js.map +1 -0
  80. package/lib/map-icon/Legend.js +53 -0
  81. package/lib/map-icon/Legend.js.map +1 -0
  82. package/lib/map-icon/config.js +3868 -0
  83. package/lib/map-icon/config.js.map +1 -0
  84. package/lib/map-icon/index.js +21 -0
  85. package/lib/map-icon/index.js.map +1 -0
  86. package/lib/map-icon/style/css.js +4 -0
  87. package/lib/map-icon/style/css.js.map +1 -0
  88. package/lib/map-icon/style/index.css +0 -0
  89. package/lib/map-icon/style/index.js +4 -0
  90. package/lib/map-icon/style/index.js.map +1 -0
  91. package/lib/map-icon/style/index.less +0 -0
  92. package/lib/map-icon/svg/index.js +53 -0
  93. package/lib/map-icon/svg/index.js.map +1 -0
  94. package/lib/map-icon/svg/tuceng.svg.js +2 -0
  95. package/lib/map-icon/svg/tuceng.svg.js.map +1 -0
  96. package/lib/style/index.css +0 -0
  97. package/lib/style/index.less +2 -0
  98. package/lib/style/themes/compact.css +0 -0
  99. package/lib/style/themes/compact.less +1 -0
  100. package/lib/style/themes/dark.css +0 -0
  101. package/lib/style/themes/dark.less +9 -0
  102. package/lib/style/themes/default.css +0 -0
  103. package/lib/style/themes/default.less +7 -0
  104. package/lib/style/themes/index.css +0 -0
  105. package/lib/style/themes/index.less +1 -0
  106. package/lib/style/themes/variable.css +0 -0
  107. package/lib/style/themes/variable.less +5 -0
  108. package/lib/tools/Analysis/AnalysisLayer.js +380 -0
  109. package/lib/tools/Analysis/AnalysisLayer.js.map +1 -0
  110. package/lib/tools/Layer/LayerService.js +150 -0
  111. package/lib/tools/Layer/LayerService.js.map +1 -0
  112. package/lib/tools/Layer/LayersCheckService.js +173 -0
  113. package/lib/tools/Layer/LayersCheckService.js.map +1 -0
  114. package/lib/tools/Layer/index.css +34 -0
  115. package/lib/tools/Layer/index.js +227 -0
  116. package/lib/tools/Layer/index.js.map +1 -0
  117. package/lib/tools/Layer/index.less +27 -0
  118. package/lib/tools/Search/index.js +194 -0
  119. package/lib/tools/Search/index.js.map +1 -0
  120. package/lib/tools/Toolbox/BoxSelect/index.js +20 -0
  121. package/lib/tools/Toolbox/BoxSelect/index.js.map +1 -0
  122. package/lib/tools/Toolbox/CircleSelect/index.js +20 -0
  123. package/lib/tools/Toolbox/CircleSelect/index.js.map +1 -0
  124. package/lib/tools/Toolbox/EagleEye/index.js +57 -0
  125. package/lib/tools/Toolbox/EagleEye/index.js.map +1 -0
  126. package/lib/tools/Toolbox/MapBookmark/index.css +18 -0
  127. package/lib/tools/Toolbox/MapBookmark/index.js +494 -0
  128. package/lib/tools/Toolbox/MapBookmark/index.js.map +1 -0
  129. package/lib/tools/Toolbox/MapBookmark/index.less +20 -0
  130. package/lib/tools/Toolbox/MapDownload/index.js +16 -0
  131. package/lib/tools/Toolbox/MapDownload/index.js.map +1 -0
  132. package/lib/tools/Toolbox/MapPrint/index.css +4 -0
  133. package/lib/tools/Toolbox/MapPrint/index.js +242 -0
  134. package/lib/tools/Toolbox/MapPrint/index.js.map +1 -0
  135. package/lib/tools/Toolbox/MapPrint/index.less +4 -0
  136. package/lib/tools/Toolbox/Measure/Area/index.js +17 -0
  137. package/lib/tools/Toolbox/Measure/Area/index.js.map +1 -0
  138. package/lib/tools/Toolbox/Measure/Distance/index.js +17 -0
  139. package/lib/tools/Toolbox/Measure/Distance/index.js.map +1 -0
  140. package/lib/tools/Toolbox/Measure/Measure.js +229 -0
  141. package/lib/tools/Toolbox/Measure/Measure.js.map +1 -0
  142. package/lib/tools/Toolbox/Measure/index.js +70 -0
  143. package/lib/tools/Toolbox/Measure/index.js.map +1 -0
  144. package/lib/tools/Toolbox/PolygonSelect/index.js +20 -0
  145. package/lib/tools/Toolbox/PolygonSelect/index.js.map +1 -0
  146. package/lib/tools/Toolbox/ScaleLine/index.js +55 -0
  147. package/lib/tools/Toolbox/ScaleLine/index.js.map +1 -0
  148. package/lib/tools/Toolbox/SelectTools/index.css +15 -0
  149. package/lib/tools/Toolbox/SelectTools/index.js +243 -0
  150. package/lib/tools/Toolbox/SelectTools/index.js.map +1 -0
  151. package/lib/tools/Toolbox/SelectTools/index.less +10 -0
  152. package/lib/tools/Toolbox/SpaceQuery/index.css +19 -0
  153. package/lib/tools/Toolbox/SpaceQuery/index.js +590 -0
  154. package/lib/tools/Toolbox/SpaceQuery/index.js.map +1 -0
  155. package/lib/tools/Toolbox/SpaceQuery/index.less +18 -0
  156. package/lib/tools/Toolbox/index.css +6 -0
  157. package/lib/tools/Toolbox/index.js +187 -0
  158. package/lib/tools/Toolbox/index.js.map +1 -0
  159. package/lib/tools/Toolbox/index.less +11 -0
  160. package/lib/tools/Utils/CreateOverlay.js +47 -0
  161. package/lib/tools/Utils/CreateOverlay.js.map +1 -0
  162. package/lib/tools/Utils/Draw.js +129 -0
  163. package/lib/tools/Utils/Draw.js.map +1 -0
  164. package/lib/tools/Utils/HighLayer.js +184 -0
  165. package/lib/tools/Utils/HighLayer.js.map +1 -0
  166. package/lib/tools/Utils/measure.js +247 -0
  167. package/lib/tools/Utils/measure.js.map +1 -0
  168. package/lib/tools/Utils/utils.js +272 -0
  169. package/lib/tools/Utils/utils.js.map +1 -0
  170. package/lib/tools/View/index.js +51 -0
  171. package/lib/tools/View/index.js.map +1 -0
  172. package/lib/tools/components/Icon/index.js +28 -0
  173. package/lib/tools/components/Icon/index.js.map +1 -0
  174. package/lib/tools/components/ItemWrap/index.css +43 -0
  175. package/lib/tools/components/ItemWrap/index.js +40 -0
  176. package/lib/tools/components/ItemWrap/index.js.map +1 -0
  177. package/lib/tools/components/ItemWrap/index.less +41 -0
  178. package/lib/tools/components/Modal/index.css +36 -0
  179. package/lib/tools/components/Modal/index.js +37 -0
  180. package/lib/tools/components/Modal/index.js.map +1 -0
  181. package/lib/tools/components/Modal/index.less +28 -0
  182. package/lib/tools/components/MyTabs/index.js +22 -0
  183. package/lib/tools/components/MyTabs/index.js.map +1 -0
  184. package/lib/tools/components/RequiredLabel/index.css +5 -0
  185. package/lib/tools/components/RequiredLabel/index.js +32 -0
  186. package/lib/tools/components/RequiredLabel/index.js.map +1 -0
  187. package/lib/tools/components/RequiredLabel/index.less +5 -0
  188. package/lib/tools/components/Select/index.js +33 -0
  189. package/lib/tools/components/Select/index.js.map +1 -0
  190. package/lib/tools/components/Table/index.css +10 -0
  191. package/lib/tools/components/Table/index.js +91 -0
  192. package/lib/tools/components/Table/index.js.map +1 -0
  193. package/lib/tools/components/Table/index.less +13 -0
  194. package/lib/tools/components/ToolItem/index.css +30 -0
  195. package/lib/tools/components/ToolItem/index.js +29 -0
  196. package/lib/tools/components/ToolItem/index.js.map +1 -0
  197. package/lib/tools/components/ToolItem/index.less +27 -0
  198. package/lib/tools/components/ToolsSelect/index.css +30 -0
  199. package/lib/tools/components/ToolsSelect/index.js +43 -0
  200. package/lib/tools/components/ToolsSelect/index.js.map +1 -0
  201. package/lib/tools/components/ToolsSelect/index.less +29 -0
  202. package/lib/tools/index.js +84 -0
  203. package/lib/tools/index.js.map +1 -0
  204. package/lib/tools/style/css.js +4 -0
  205. package/lib/tools/style/css.js.map +1 -0
  206. package/lib/tools/style/index.css +19 -0
  207. package/lib/tools/style/index.js +4 -0
  208. package/lib/tools/style/index.js.map +1 -0
  209. package/lib/tools/style/index.less +19 -0
  210. package/package.json +118 -0
@@ -0,0 +1,317 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _config = _interopRequireDefault(require("./config"));
9
+ var _Canvas2 = _interopRequireDefault(require("./Canvas"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
13
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
17
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
20
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /* eslint-disable */
23
+ var _default = /*#__PURE__*/function (_Canvas) {
24
+ _inherits(_default, _Canvas);
25
+ var _super = _createSuper(_default);
26
+ function _default(options) {
27
+ var _this;
28
+ _classCallCheck(this, _default);
29
+ _this = _super.call(this);
30
+ _this.options = options || {};
31
+ _this.settings = {
32
+ height: 118,
33
+ // 整体高度
34
+ width: 55,
35
+ // 整体高度
36
+ iconOuterWrapSize: 55,
37
+ // 外侧圆大小
38
+ iconInnerWrapSize: 43,
39
+ // 内侧圆大小
40
+ pillar: {
41
+ // 中间的柱子
42
+ width: 5,
43
+ // 宽度
44
+ height: 58 // 高度
45
+ },
46
+
47
+ info: {
48
+ // 信息框
49
+ height: 55,
50
+ // 高度
51
+ gutter: 32 // 两侧间距
52
+ },
53
+
54
+ footerOuterCircle: {
55
+ // 底部外侧圆
56
+ width: 51,
57
+ // 宽度
58
+ height: 18 // 高度
59
+ },
60
+
61
+ footerInnerCircle: {
62
+ // 底部外侧圆
63
+ width: 26,
64
+ // 宽度
65
+ height: 10 // 高度
66
+ }
67
+ };
68
+
69
+ // 初始化框高
70
+ _this.setWidth(_this.settings.width);
71
+ _this.setHeight(_this.settings.height);
72
+
73
+ // 创建图标
74
+ _this.createIcon();
75
+ return _this;
76
+ }
77
+
78
+ // 创建图标
79
+ _createClass(_default, [{
80
+ key: "createIcon",
81
+ value: function createIcon() {
82
+ // 绘制底座外侧椭圆
83
+ this.drawFooterOuterCircle();
84
+
85
+ // 绘制底座内侧椭圆
86
+ this.drawFooterInnerCircle();
87
+
88
+ // 绘制柱子
89
+ this.drawPillar();
90
+
91
+ // 绘制图标外侧
92
+ this.drawIconOuterWrap();
93
+
94
+ // 绘制图标内侧侧
95
+ this.drawIconInnerWrap();
96
+ var _this$options = this.options,
97
+ info = _this$options.info,
98
+ icon = _this$options.icon,
99
+ canvasIcon = _this$options.canvasIcon;
100
+
101
+ // 绘制信息框
102
+ if (info) {
103
+ this.drawInfo();
104
+ }
105
+
106
+ // 绘制图标
107
+ if (icon) {
108
+ this.drawIcon();
109
+ }
110
+
111
+ // 绘制图标
112
+ if (canvasIcon) {
113
+ this.drawCanvasIcon();
114
+ }
115
+ }
116
+
117
+ // 绘制图标外侧
118
+ }, {
119
+ key: "drawIconOuterWrap",
120
+ value: function drawIconOuterWrap() {
121
+ var color = this.options.color;
122
+ var iconOuterWrapSize = this.settings.iconOuterWrapSize;
123
+
124
+ // 根据对角线计算正方形边长, 计算公式:正方形边长 = 对角线 / 1.414
125
+ var sideLength = iconOuterWrapSize / 1.414;
126
+
127
+ // 保存状态,为下面偏移中心点、旋转做恢复
128
+ this.ctx.save();
129
+ this.ctx.beginPath();
130
+
131
+ // 偏移中心点
132
+ this.ctx.translate(sideLength / 2 - 11, sideLength / 2);
133
+
134
+ // 旋转
135
+ this.ctx.rotate(45 * Math.PI / 180);
136
+
137
+ // 绘制背景
138
+ this.roundRectInnerShadow(this.ctx, 0, -(iconOuterWrapSize / 2), sideLength, sideLength, 2, color);
139
+
140
+ // 绘制边框
141
+ this.roundRect(this.ctx, 0, -(iconOuterWrapSize / 2), sideLength, sideLength, 2, color);
142
+ this.ctx.strokeStyle = color;
143
+ this.ctx.stroke();
144
+ this.ctx.restore();
145
+ }
146
+
147
+ // 绘制图标内侧侧
148
+ }, {
149
+ key: "drawIconInnerWrap",
150
+ value: function drawIconInnerWrap() {
151
+ var color = this.options.color;
152
+ var iconOuterWrapSize = this.settings.iconOuterWrapSize;
153
+ var iconInnerWrapSize = this.settings.iconInnerWrapSize;
154
+
155
+ // 绘制图标轮廓
156
+ var wrapOuterSize = iconOuterWrapSize / 1.414;
157
+
158
+ // 保存状态,为下面偏移中心点、旋转做恢复
159
+ this.ctx.save();
160
+
161
+ // 偏移中心点
162
+ this.ctx.translate(wrapOuterSize / 2 - 11, wrapOuterSize / 2);
163
+
164
+ // 旋转
165
+ this.ctx.rotate(45 * Math.PI / 180);
166
+
167
+ // 根据对角线计算正方形边长, 计算公式:正方形边长 = 对角线 / 1.414
168
+ var sideLength = iconInnerWrapSize / 1.414;
169
+
170
+ // 绘制
171
+ this.roundRect(this.ctx, 4, -(iconInnerWrapSize / 2) - 1.8, sideLength, sideLength, 2, color);
172
+
173
+ // 填充背景色
174
+ this.ctx.fillStyle = '#FFF';
175
+ this.ctx.fill();
176
+ this.ctx.restore();
177
+ }
178
+
179
+ // 绘制柱子
180
+ }, {
181
+ key: "drawPillar",
182
+ value: function drawPillar() {
183
+ var ctx = this.ctx;
184
+ var color = this.options.color;
185
+ var x = this.settings.iconOuterWrapSize / 2 - this.settings.pillar.width / 2;
186
+ var y = this.settings.iconOuterWrapSize - 8;
187
+ var w = this.settings.pillar.width;
188
+ var h = this.settings.pillar.height;
189
+ ctx.save();
190
+ ctx.beginPath();
191
+
192
+ // 裁剪区(只保留内部阴影部分)
193
+ this.roundPillarArrow(ctx, x, y, w, h);
194
+ ctx.clip();
195
+
196
+ // 边框+阴影
197
+ ctx.beginPath();
198
+ var grd1 = ctx.createLinearGradient(x, y, x + w, y + h);
199
+ grd1.addColorStop(0.1, 'rgba(0, 0, 0, 0)');
200
+ grd1.addColorStop(0.15, this.transformRgb(color, 0.5));
201
+ grd1.addColorStop(0.45, color);
202
+ grd1.addColorStop(0.7, this.transformRgb(color, 0.5));
203
+ grd1.addColorStop(1, 'rgba(0, 0, 0, 0)');
204
+ ctx.fillStyle = grd1;
205
+
206
+ // 因线是由坐标位置向两则画的,所以要移动起点坐标位置,和加大矩形。
207
+ this.roundPillarArrow(ctx, x, y, w, h);
208
+ ctx.fillRect(x, y, x + w, y + h);
209
+ ctx.restore();
210
+ }
211
+
212
+ // 绘制底座外侧椭圆
213
+ }, {
214
+ key: "drawFooterOuterCircle",
215
+ value: function drawFooterOuterCircle() {
216
+ var x = this.settings.iconOuterWrapSize / 2;
217
+ var y = this.settings.height - this.settings.footerOuterCircle.height / 2 - 2;
218
+ var w = this.settings.footerOuterCircle.width;
219
+ var h = this.settings.footerOuterCircle.height;
220
+ var color = this.options.color;
221
+ this.ellipseShadow(this.ctx, x, y, w, h, color);
222
+ }
223
+
224
+ // 绘制底座内侧椭圆
225
+ }, {
226
+ key: "drawFooterInnerCircle",
227
+ value: function drawFooterInnerCircle() {
228
+ var x = this.settings.iconOuterWrapSize / 2;
229
+ var y = this.settings.height - 12;
230
+ var w = this.settings.footerInnerCircle.width;
231
+ var h = this.settings.footerInnerCircle.height;
232
+ var color = this.options.color;
233
+ this.ellipseShadow(this.ctx, x, y, w, h, color);
234
+ }
235
+
236
+ // 绘制信息框
237
+ }, {
238
+ key: "drawInfo",
239
+ value: function drawInfo() {
240
+ var _this$options2 = this.options,
241
+ info = _this$options2.info,
242
+ color = _this$options2.color;
243
+ var x = this.settings.iconOuterWrapSize / 2 + 4;
244
+ var y = 0;
245
+ var width = this.getCanvasWidth(info) + this.settings.info.gutter * 2;
246
+ var height = this.settings.info.height;
247
+ var radius = 30;
248
+
249
+ // 改变 canvas 大小
250
+ this.resize(x + width);
251
+
252
+ // 绘制阴影
253
+ this.roundRectInnerArrowShadow(this.ctx, x, y, width, height, radius, color);
254
+
255
+ // 绘制文本
256
+ var textHeight = this.settings.info.height;
257
+ var textX = this.settings.iconOuterWrapSize + 2;
258
+ this.renderText(this.ctx, textHeight, info, textX);
259
+ }
260
+ }, {
261
+ key: "drawIcon",
262
+ value: function drawIcon() {
263
+ var _this2 = this;
264
+ var _this$options3 = this.options,
265
+ icon = _this$options3.icon,
266
+ color = _this$options3.color;
267
+ var src = icon.src,
268
+ _icon$width = icon.width,
269
+ width = _icon$width === void 0 ? 22 : _icon$width,
270
+ _icon$height = icon.height,
271
+ height = _icon$height === void 0 ? 22 : _icon$height;
272
+ var x = this.settings.iconOuterWrapSize / 2 - width / 2;
273
+ var y = this.settings.iconOuterWrapSize / 2 - height / 2;
274
+ this.drawImage(src, color, function (imgSrc) {
275
+ var image = new Image();
276
+ image.src = imgSrc;
277
+ image.onload = function () {
278
+ _this2.ctx.drawImage(image, x, y, width, height);
279
+ };
280
+ });
281
+ }
282
+
283
+ // 绘制canvas图标
284
+ }, {
285
+ key: "drawCanvasIcon",
286
+ value: function drawCanvasIcon() {
287
+ var _this$options4 = this.options,
288
+ canvasIcon = _this$options4.canvasIcon,
289
+ color = _this$options4.color;
290
+ var _ref = _config["default"][canvasIcon] || {},
291
+ size = _ref.size,
292
+ draw = _ref.draw;
293
+
294
+ // 起始位置
295
+ var x = this.settings.iconOuterWrapSize / 2 - size / 2;
296
+ var y = this.settings.iconOuterWrapSize / 2 - size / 2;
297
+
298
+ // 保存状态
299
+ this.ctx.save();
300
+
301
+ // 偏移中心点
302
+ this.ctx.translate(x, y);
303
+
304
+ // 绘制颜色
305
+ this.ctx.fillStyle = color;
306
+
307
+ // 绘制图标
308
+ draw(this.ctx);
309
+
310
+ // 恢复状态
311
+ this.ctx.restore();
312
+ }
313
+ }]);
314
+ return _default;
315
+ }(_Canvas2["default"]);
316
+ exports["default"] = _default;
317
+ //# sourceMappingURL=CockpitIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CockpitIcon.js","names":["_config","_interopRequireDefault","require","_Canvas2","obj","__esModule","_classCallCheck","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","protoProps","staticProps","prototype","arg","_toPrimitive","_typeof","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","Number","_inherits","subClass","superClass","create","constructor","value","_setPrototypeOf","o","p","setPrototypeOf","bind","__proto__","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf","result","NewTarget","Reflect","construct","arguments","apply","_possibleConstructorReturn","self","_assertThisInitialized","ReferenceError","sham","Proxy","Boolean","valueOf","e","getPrototypeOf","_default","_Canvas","_super","options","_this","settings","height","width","iconOuterWrapSize","iconInnerWrapSize","pillar","info","gutter","footerOuterCircle","footerInnerCircle","setWidth","setHeight","createIcon","drawFooterOuterCircle","drawFooterInnerCircle","drawPillar","drawIconOuterWrap","drawIconInnerWrap","_this$options","icon","canvasIcon","drawInfo","drawIcon","drawCanvasIcon","color","sideLength","ctx","save","beginPath","translate","rotate","Math","PI","roundRectInnerShadow","roundRect","strokeStyle","stroke","restore","wrapOuterSize","fillStyle","fill","x","y","w","h","roundPillarArrow","clip","grd1","createLinearGradient","addColorStop","transformRgb","fillRect","ellipseShadow","_this$options2","getCanvasWidth","radius","resize","roundRectInnerArrowShadow","textHeight","textX","renderText","_this2","_this$options3","src","_icon$width","_icon$height","drawImage","imgSrc","image","Image","onload","_this$options4","_ref","iconConfig","size","draw","Canvas","exports"],"sources":["map-icon/CockpitIcon.js"],"sourcesContent":["/* eslint-disable */\nimport iconConfig from './config';\nimport Canvas from './Canvas';\n\nexport default class extends Canvas {\n constructor(options) {\n super();\n\n this.options = options || {};\n\n this.settings = {\n height: 118, // 整体高度\n width: 55, // 整体高度\n iconOuterWrapSize: 55, // 外侧圆大小\n iconInnerWrapSize: 43, // 内侧圆大小\n pillar: {\n // 中间的柱子\n width: 5, // 宽度\n height: 58, // 高度\n },\n info: {\n // 信息框\n height: 55, // 高度\n gutter: 32, // 两侧间距\n },\n footerOuterCircle: {\n // 底部外侧圆\n width: 51, // 宽度\n height: 18, // 高度\n },\n footerInnerCircle: {\n // 底部外侧圆\n width: 26, // 宽度\n height: 10, // 高度\n },\n };\n\n // 初始化框高\n this.setWidth(this.settings.width);\n this.setHeight(this.settings.height);\n\n // 创建图标\n this.createIcon();\n }\n\n // 创建图标\n createIcon() {\n // 绘制底座外侧椭圆\n this.drawFooterOuterCircle();\n\n // 绘制底座内侧椭圆\n this.drawFooterInnerCircle();\n\n // 绘制柱子\n this.drawPillar();\n\n // 绘制图标外侧\n this.drawIconOuterWrap();\n\n // 绘制图标内侧侧\n this.drawIconInnerWrap();\n\n const { info, icon, canvasIcon } = this.options;\n\n // 绘制信息框\n if (info) {\n this.drawInfo();\n }\n\n // 绘制图标\n if (icon) {\n this.drawIcon();\n }\n\n // 绘制图标\n if (canvasIcon) {\n this.drawCanvasIcon();\n }\n }\n\n // 绘制图标外侧\n drawIconOuterWrap() {\n const { color } = this.options;\n const iconOuterWrapSize = this.settings.iconOuterWrapSize;\n\n // 根据对角线计算正方形边长, 计算公式:正方形边长 = 对角线 / 1.414\n const sideLength = iconOuterWrapSize / 1.414;\n\n // 保存状态,为下面偏移中心点、旋转做恢复\n this.ctx.save();\n this.ctx.beginPath();\n\n // 偏移中心点\n this.ctx.translate(sideLength / 2 - 11, sideLength / 2);\n\n // 旋转\n this.ctx.rotate((45 * Math.PI) / 180);\n\n // 绘制背景\n this.roundRectInnerShadow(\n this.ctx,\n 0,\n -(iconOuterWrapSize / 2),\n sideLength,\n sideLength,\n 2,\n color,\n );\n\n // 绘制边框\n this.roundRect(this.ctx, 0, -(iconOuterWrapSize / 2), sideLength, sideLength, 2, color);\n this.ctx.strokeStyle = color;\n this.ctx.stroke();\n\n this.ctx.restore();\n }\n\n // 绘制图标内侧侧\n drawIconInnerWrap() {\n const { color } = this.options;\n const iconOuterWrapSize = this.settings.iconOuterWrapSize;\n const iconInnerWrapSize = this.settings.iconInnerWrapSize;\n\n // 绘制图标轮廓\n let wrapOuterSize = iconOuterWrapSize / 1.414;\n\n // 保存状态,为下面偏移中心点、旋转做恢复\n this.ctx.save();\n\n // 偏移中心点\n this.ctx.translate(wrapOuterSize / 2 - 11, wrapOuterSize / 2);\n\n // 旋转\n this.ctx.rotate((45 * Math.PI) / 180);\n\n // 根据对角线计算正方形边长, 计算公式:正方形边长 = 对角线 / 1.414\n let sideLength = iconInnerWrapSize / 1.414;\n\n // 绘制\n this.roundRect(this.ctx, 4, -(iconInnerWrapSize / 2) - 1.8, sideLength, sideLength, 2, color);\n\n // 填充背景色\n this.ctx.fillStyle = '#FFF';\n this.ctx.fill();\n\n this.ctx.restore();\n }\n\n // 绘制柱子\n drawPillar() {\n const ctx = this.ctx;\n const { color } = this.options;\n const x = this.settings.iconOuterWrapSize / 2 - this.settings.pillar.width / 2;\n const y = this.settings.iconOuterWrapSize - 8;\n const w = this.settings.pillar.width;\n const h = this.settings.pillar.height;\n\n ctx.save();\n ctx.beginPath();\n\n // 裁剪区(只保留内部阴影部分)\n this.roundPillarArrow(ctx, x, y, w, h);\n ctx.clip();\n\n // 边框+阴影\n ctx.beginPath();\n\n const grd1 = ctx.createLinearGradient(x, y, x + w, y + h);\n grd1.addColorStop(0.1, 'rgba(0, 0, 0, 0)');\n grd1.addColorStop(0.15, this.transformRgb(color, 0.5));\n grd1.addColorStop(0.45, color);\n grd1.addColorStop(0.7, this.transformRgb(color, 0.5));\n grd1.addColorStop(1, 'rgba(0, 0, 0, 0)');\n ctx.fillStyle = grd1;\n\n // 因线是由坐标位置向两则画的,所以要移动起点坐标位置,和加大矩形。\n this.roundPillarArrow(ctx, x, y, w, h);\n\n ctx.fillRect(x, y, x + w, y + h);\n\n ctx.restore();\n }\n\n // 绘制底座外侧椭圆\n drawFooterOuterCircle() {\n const x = this.settings.iconOuterWrapSize / 2;\n const y = this.settings.height - this.settings.footerOuterCircle.height / 2 - 2;\n const w = this.settings.footerOuterCircle.width;\n const h = this.settings.footerOuterCircle.height;\n const color = this.options.color;\n\n this.ellipseShadow(this.ctx, x, y, w, h, color);\n }\n\n // 绘制底座内侧椭圆\n drawFooterInnerCircle() {\n const x = this.settings.iconOuterWrapSize / 2;\n const y = this.settings.height - 12;\n const w = this.settings.footerInnerCircle.width;\n const h = this.settings.footerInnerCircle.height;\n const color = this.options.color;\n\n this.ellipseShadow(this.ctx, x, y, w, h, color);\n }\n\n // 绘制信息框\n drawInfo() {\n const { info, color } = this.options;\n\n const x = this.settings.iconOuterWrapSize / 2 + 4;\n const y = 0;\n const width = this.getCanvasWidth(info) + this.settings.info.gutter * 2;\n const height = this.settings.info.height;\n const radius = 30;\n\n // 改变 canvas 大小\n this.resize(x + width);\n\n // 绘制阴影\n this.roundRectInnerArrowShadow(this.ctx, x, y, width, height, radius, color);\n\n // 绘制文本\n const textHeight = this.settings.info.height;\n const textX = this.settings.iconOuterWrapSize + 2;\n this.renderText(this.ctx, textHeight, info, textX);\n }\n\n drawIcon() {\n const { icon, color } = this.options;\n const { src, width = 22, height = 22 } = icon;\n const x = this.settings.iconOuterWrapSize / 2 - width / 2;\n const y = this.settings.iconOuterWrapSize / 2 - height / 2;\n\n this.drawImage(src, color, imgSrc => {\n let image = new Image();\n image.src = imgSrc;\n\n image.onload = () => {\n this.ctx.drawImage(image, x, y, width, height);\n };\n });\n }\n\n // 绘制canvas图标\n drawCanvasIcon() {\n const { canvasIcon, color } = this.options;\n let { size, draw } = iconConfig[canvasIcon] || {};\n\n // 起始位置\n const x = this.settings.iconOuterWrapSize / 2 - size / 2;\n const y = this.settings.iconOuterWrapSize / 2 - size / 2;\n\n // 保存状态\n this.ctx.save();\n\n // 偏移中心点\n this.ctx.translate(x, y);\n\n // 绘制颜色\n this.ctx.fillStyle = color;\n\n // 绘制图标\n draw(this.ctx);\n\n // 恢复状态\n this.ctx.restore();\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8B,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,gBAAAC,QAAA,EAAAC,WAAA,UAAAD,QAAA,YAAAC,WAAA,eAAAC,SAAA;AAAA,SAAAC,kBAAAC,MAAA,EAAAC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strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _config = _interopRequireDefault(require("./config"));
9
+ var _Canvas2 = _interopRequireDefault(require("./Canvas"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
13
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
17
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
19
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
20
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23
+ var CockpitIcon = /*#__PURE__*/function (_Canvas) {
24
+ _inherits(CockpitIcon, _Canvas);
25
+ var _super = _createSuper(CockpitIcon);
26
+ function CockpitIcon(options) {
27
+ var _this;
28
+ _classCallCheck(this, CockpitIcon);
29
+ _this = _super.call(this);
30
+ _this.options = options || {};
31
+ _this.settings = {
32
+ height: 110,
33
+ // 整体高度
34
+ width: 38,
35
+ // 整体宽度
36
+ iconInnerWrapSize: 36,
37
+ // 内侧圆大小
38
+ pillar: {
39
+ // 中间的柱子
40
+ width: 5,
41
+ // 宽度
42
+ height: 62 // 高度
43
+ },
44
+
45
+ info: {
46
+ // 信息框
47
+ height: 38,
48
+ // 高度
49
+ gutter: 26 // 两侧间距
50
+ },
51
+
52
+ footerInnerCircle: {
53
+ // 底部外侧圆
54
+ width: 20,
55
+ // 宽度
56
+ height: 8 // 高度
57
+ }
58
+ };
59
+
60
+ // 初始化框高
61
+ _this.setWidth(_this.settings.width);
62
+ _this.setHeight(_this.settings.height);
63
+
64
+ // 创建图标
65
+ _this.createIcon();
66
+ return _this;
67
+ }
68
+
69
+ // 创建图标
70
+ _createClass(CockpitIcon, [{
71
+ key: "createIcon",
72
+ value: function createIcon() {
73
+ var _this$options = this.options,
74
+ info = _this$options.info,
75
+ icon = _this$options.icon,
76
+ canvasIcon = _this$options.canvasIcon;
77
+
78
+ // 绘制信息框
79
+ if (info) {
80
+ this.drawInfo();
81
+ }
82
+
83
+ // 绘制底座内侧椭圆
84
+ this.drawFooterInnerCircle();
85
+
86
+ // 绘制柱子
87
+ this.drawPillar();
88
+
89
+ // 绘制图标内侧侧
90
+ this.drawIconInnerWrap();
91
+
92
+ // 绘制图标
93
+ if (icon) {
94
+ this.drawIcon();
95
+ }
96
+
97
+ // 绘制图标
98
+ if (canvasIcon) {
99
+ this.drawCanvasIcon();
100
+ }
101
+ }
102
+
103
+ // 绘制图标内侧侧
104
+ }, {
105
+ key: "drawIconInnerWrap",
106
+ value: function drawIconInnerWrap() {
107
+ var color = this.options.color;
108
+ var iconInnerWrapSize = this.settings.iconInnerWrapSize;
109
+
110
+ // 保存状态,为下面偏移中心点、旋转做恢复
111
+ this.ctx.save();
112
+ var x = this.settings.width / 2;
113
+ var y = this.settings.width / 2;
114
+ // 绘制
115
+ this.ellipseShadow(this.ctx, x, y, iconInnerWrapSize, iconInnerWrapSize, color);
116
+
117
+ // 填充背景色
118
+ this.ctx.fillStyle = this.transformRgb(this.options.color, 0.75);
119
+ this.ctx.fill();
120
+ this.ctx.strokeStyle = "#FFF";
121
+ this.ctx.lineWidth = 2;
122
+ this.ctx.stroke();
123
+ this.ctx.restore();
124
+ }
125
+
126
+ // 绘制柱子
127
+ }, {
128
+ key: "drawPillar",
129
+ value: function drawPillar() {
130
+ var ctx = this.ctx;
131
+ var color = this.options.color;
132
+ var x = this.settings.iconInnerWrapSize / 2 - this.settings.pillar.width / 2;
133
+ var y = this.settings.iconInnerWrapSize - 8;
134
+ var w = this.settings.pillar.width;
135
+ var h = this.settings.pillar.height;
136
+ ctx.save();
137
+ ctx.beginPath();
138
+
139
+ // 裁剪区(只保留内部阴影部分)
140
+ this.roundPillarArrow(ctx, x, y, w, h);
141
+ ctx.clip();
142
+
143
+ // 边框+阴影
144
+ ctx.beginPath();
145
+ var grd1 = ctx.createLinearGradient(x, y, x + w, y + h);
146
+ grd1.addColorStop(0.1, "rgba(0, 0, 0, 0)");
147
+ grd1.addColorStop(0.15, this.transformRgb(color, 0.5));
148
+ grd1.addColorStop(0.45, color);
149
+ grd1.addColorStop(0.7, this.transformRgb(color, 0.5));
150
+ grd1.addColorStop(1, "rgba(0, 0, 0, 0)");
151
+ ctx.fillStyle = grd1;
152
+
153
+ // 因线是由坐标位置向两则画的,所以要移动起点坐标位置,和加大矩形。
154
+ this.roundPillarArrow(ctx, x, y, w, h);
155
+ ctx.fillRect(x, y, x + w, y + h);
156
+ ctx.restore();
157
+ }
158
+
159
+ // 绘制底座内侧椭圆
160
+ }, {
161
+ key: "drawFooterInnerCircle",
162
+ value: function drawFooterInnerCircle() {
163
+ var x = this.settings.iconInnerWrapSize / 2;
164
+ var y = this.settings.height - 12;
165
+ var w = this.settings.footerInnerCircle.width;
166
+ var h = this.settings.footerInnerCircle.height;
167
+ var color = this.options.color;
168
+ this.ellipseShadow(this.ctx, x, y, w, h, color, .5);
169
+ }
170
+
171
+ // 绘制信息框
172
+ }, {
173
+ key: "drawInfo",
174
+ value: function drawInfo() {
175
+ var _this$options2 = this.options,
176
+ info = _this$options2.info,
177
+ color = _this$options2.color;
178
+ var x = this.settings.iconInnerWrapSize / 2 + 4;
179
+ var width = this.getCanvasWidth(info) + this.settings.info.gutter * 2;
180
+ var height = this.settings.info.height;
181
+
182
+ // 改变 canvas 大小
183
+ this.resize(x + width);
184
+
185
+ // 保存状态
186
+ this.ctx.save();
187
+ this.ctx.beginPath();
188
+ this.ctx.moveTo(this.settings.width / 2, 1);
189
+ this.ctx.lineTo(this.settings.width / 2 + width, 1);
190
+ this.ctx.lineTo(this.settings.width / 2 + width, height);
191
+ this.ctx.lineTo(this.settings.width / 2, height);
192
+ this.ctx.arc(this.settings.width / 2, height / 2, this.settings.iconInnerWrapSize / 2, Math.PI / 2, 3 * Math.PI / 2, true);
193
+ this.ctx.closePath();
194
+
195
+ // 绘制颜色
196
+ this.ctx.fillStyle = 'rgba(255, 255, 255, .15)';
197
+ this.ctx.fill();
198
+ this.ctx.strokeStyle = this.options.color;
199
+ this.ctx.stroke();
200
+
201
+ // 恢复状态
202
+ this.ctx.restore();
203
+
204
+ // 绘制文本
205
+ var textHeight = this.settings.info.height;
206
+ var textX = this.settings.iconInnerWrapSize + 10;
207
+ this.renderText(this.ctx, textHeight, info, textX, this.options.color);
208
+ }
209
+
210
+ // 绘制图标
211
+ }, {
212
+ key: "drawIcon",
213
+ value: function drawIcon() {
214
+ var _this2 = this;
215
+ var _this$options3 = this.options,
216
+ icon = _this$options3.icon,
217
+ color = _this$options3.color;
218
+ var src = icon.src,
219
+ _icon$width = icon.width,
220
+ width = _icon$width === void 0 ? 22 : _icon$width,
221
+ _icon$height = icon.height,
222
+ height = _icon$height === void 0 ? 22 : _icon$height;
223
+ var x = this.settings.iconInnerWrapSize / 2 - width / 2;
224
+ var y = this.settings.iconInnerWrapSize / 2 - height / 2;
225
+ this.drawImage(src, color, function (imgSrc) {
226
+ var image = new Image();
227
+ image.src = imgSrc;
228
+ image.onload = function () {
229
+ _this2.ctx.drawImage(image, x, y, width, height);
230
+ };
231
+ });
232
+ }
233
+
234
+ // 绘制canvas图标
235
+ }, {
236
+ key: "drawCanvasIcon",
237
+ value: function drawCanvasIcon() {
238
+ var _this$options4 = this.options,
239
+ canvasIcon = _this$options4.canvasIcon,
240
+ color = _this$options4.color;
241
+ var _ref = _config["default"][canvasIcon] || {},
242
+ size = _ref.size,
243
+ draw = _ref.draw;
244
+
245
+ // 起始位置
246
+ var x = this.settings.iconInnerWrapSize / 2 - size / 2;
247
+ var y = this.settings.iconInnerWrapSize / 2 - size / 2;
248
+
249
+ // 保存状态
250
+ this.ctx.save();
251
+
252
+ // 偏移中心点
253
+ this.ctx.translate(x, y);
254
+
255
+ // 绘制颜色
256
+ this.ctx.fillStyle = "#FFF";
257
+
258
+ // 绘制图标
259
+ draw(this.ctx);
260
+
261
+ // 恢复状态
262
+ this.ctx.restore();
263
+ }
264
+ }]);
265
+ return CockpitIcon;
266
+ }(_Canvas2["default"]);
267
+ exports["default"] = CockpitIcon;
268
+ //# sourceMappingURL=CockpitIcon2.js.map