@visactor/vrender-components 0.20.10 → 0.20.11-alpha.1

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/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.20.10";
1
+ export declare const version = "0.20.11-alpha.1";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
@@ -26,4 +26,5 @@ export * from './jsx';
26
26
  export * from './checkbox';
27
27
  export * from './radio';
28
28
  export * from './empty-tip';
29
+ export * from './weather';
29
30
  export * from './util';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "0.20.10";
1
+ export const version = "0.20.11-alpha.1";
2
2
 
3
3
  export * from "./core/base";
4
4
 
@@ -54,5 +54,7 @@ export * from "./radio";
54
54
 
55
55
  export * from "./empty-tip";
56
56
 
57
+ export * from "./weather";
58
+
57
59
  export * from "./util";
58
60
  //# sourceMappingURL=index.js.map
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.20.10\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAEzC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.20.11-alpha.1\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './weather';\nexport * from './util';\n"]}
@@ -0,0 +1 @@
1
+ export * from './weather-box';
@@ -0,0 +1,2 @@
1
+ export * from "./weather-box";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/weather/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC","file":"index.js","sourcesContent":["export * from './weather-box';\n"]}
@@ -0,0 +1 @@
1
+ export declare function loadWeatherComponent(): void;
@@ -0,0 +1,6 @@
1
+ import { registerGroup, registerSymbol } from "@visactor/vrender-kits";
2
+
3
+ export function loadWeatherComponent() {
4
+ registerGroup(), registerSymbol();
5
+ }
6
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/weather/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEvE,MAAM,UAAU,oBAAoB;IAClC,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,CAAC;AACnB,CAAC","file":"register.js","sourcesContent":["import { registerGroup, registerSymbol } from '@visactor/vrender-kits';\n\nexport function loadWeatherComponent() {\n registerGroup();\n registerSymbol();\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import type { IGroupGraphicAttribute } from '@visactor/vrender-core';
2
+ export interface IWeatherBoxAttrs extends IGroupGraphicAttribute {
3
+ rainIconPath?: string;
4
+ snowIconPath?: string;
5
+ windIconPath?: string;
6
+ width: number;
7
+ height: number;
8
+ rainSizeRange?: [number, number];
9
+ snowSizeRange?: [number, number];
10
+ windSize?: number;
11
+ rainSpeed?: number;
12
+ snowSpeed?: number;
13
+ windSpeed?: number;
14
+ rainRatio?: number;
15
+ rainCountThreshold?: number;
16
+ snowRatio?: number;
17
+ snowCountThreshold?: number;
18
+ windRatio?: number;
19
+ rainStyle?: {
20
+ background?: string;
21
+ };
22
+ snowStyle?: {
23
+ background?: string;
24
+ };
25
+ rainSnowStyle?: {
26
+ background?: string;
27
+ };
28
+ defaultStyle?: {
29
+ background?: string;
30
+ };
31
+ }
@@ -0,0 +1,2 @@
1
+ export { };
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/weather/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IGroupGraphicAttribute } from '@visactor/vrender-core';\n\nexport interface IWeatherBoxAttrs extends IGroupGraphicAttribute {\n rainIconPath?: string;\n snowIconPath?: string;\n windIconPath?: string;\n width: number;\n height: number;\n rainSizeRange?: [number, number];\n snowSizeRange?: [number, number];\n windSize?: number;\n rainSpeed?: number;\n snowSpeed?: number;\n windSpeed?: number;\n\n rainRatio?: number;\n rainCountThreshold?: number;\n snowRatio?: number;\n snowCountThreshold?: number;\n windRatio?: number;\n\n rainStyle?: {\n background?: string;\n };\n snowStyle?: {\n background?: string;\n };\n rainSnowStyle?: {\n background?: string;\n };\n defaultStyle?: {\n background?: string;\n };\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { AbstractComponent } from '../core/base';
2
+ import type { IWeatherBoxAttrs } from './type';
3
+ import type { ComponentOptions } from '../interface';
4
+ import type { IGroup } from '@visactor/vrender-core';
5
+ export declare class WeatherBox extends AbstractComponent<Required<IWeatherBoxAttrs>> {
6
+ name: string;
7
+ static defaultAttributes: Partial<IWeatherBoxAttrs>;
8
+ constructor(attributes: IWeatherBoxAttrs, options?: ComponentOptions);
9
+ protected render(): void;
10
+ protected generateWind(windRatio: number, windIconPath: string, group: IGroup, size: number, speed: number): void;
11
+ protected generateRainOrSnow(type: string, ratio: number, threshold: number, windRatio: number, group: IGroup, path: string, windAngle: number, sizeRange: [number, number], speed: number): void;
12
+ }
@@ -0,0 +1,115 @@
1
+ import { AbstractComponent } from "../core/base";
2
+
3
+ import { merge } from "@visactor/vutils";
4
+
5
+ function random() {
6
+ return Math.random();
7
+ }
8
+
9
+ function createUniformRandom(count) {
10
+ const result = [], step = 1 / count;
11
+ for (let i = 0; i < count; i++) result.push((random() - .5) * step / 2 + step * i);
12
+ result.sort((() => Math.random() - .5));
13
+ let idx = 0;
14
+ return function(i) {
15
+ return idx > count - 1 && (idx = 0), void 0 === i && (i = idx, idx++), result[i];
16
+ };
17
+ }
18
+
19
+ export class WeatherBox extends AbstractComponent {
20
+ constructor(attributes, options) {
21
+ super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, WeatherBox.defaultAttributes, attributes)),
22
+ this.name = "weatherBox";
23
+ }
24
+ render() {
25
+ const {rainRatio: rainRatio, rainIconPath: rainIconPath, snowRatio: snowRatio, snowIconPath: snowIconPath, rainCountThreshold: rainCountThreshold, snowCountThreshold: snowCountThreshold, windRatio: windRatio, rainSizeRange: rainSizeRange, snowSizeRange: snowSizeRange, rainSpeed: rainSpeed, snowSpeed: snowSpeed, width: width, height: height, rainSnowStyle: rainSnowStyle, rainStyle: rainStyle, snowStyle: snowStyle, defaultStyle: defaultStyle, windIconPath: windIconPath, windSize: windSize, windSpeed: windSpeed} = this.attribute;
26
+ this.attribute.background = rainRatio && snowRatio ? null == rainSnowStyle ? void 0 : rainSnowStyle.background : rainRatio ? null == rainStyle ? void 0 : rainStyle.background : snowRatio ? null == snowStyle ? void 0 : snowStyle.background : null == defaultStyle ? void 0 : defaultStyle.background,
27
+ this.attribute.clip = !0;
28
+ const windAngle = -windRatio * Math.PI / 4, rainGroup = this.createOrUpdateChild("rain-container", {
29
+ zIndex: 1,
30
+ width: width,
31
+ height: height
32
+ }, "group");
33
+ rainRatio > 0 && this.generateRainOrSnow("rain", rainRatio, rainCountThreshold, windRatio, rainGroup, rainIconPath, windAngle, rainSizeRange, rainSpeed);
34
+ const snowGroup = this.createOrUpdateChild("snow-container", {
35
+ zIndex: 1,
36
+ width: width,
37
+ height: height
38
+ }, "group");
39
+ snowRatio > 0 && this.generateRainOrSnow("snow", snowRatio, snowCountThreshold, windRatio, snowGroup, snowIconPath, windAngle, snowSizeRange, snowSpeed);
40
+ const windGroup = this.createOrUpdateChild("wind-container", {
41
+ zIndex: 0,
42
+ width: width,
43
+ height: height
44
+ }, "group");
45
+ windRatio > 0 && this.generateWind(windRatio, windIconPath, windGroup, windSize, windSpeed);
46
+ }
47
+ generateWind(windRatio, windIconPath, group, size, speed) {
48
+ const {width: width, height: height} = group.attribute, duration = speed / 4 * 1e3;
49
+ group.createOrUpdateChild("wind", {
50
+ x: (width - size) / 2,
51
+ y: (height - size) / 2,
52
+ symbolType: windIconPath,
53
+ size: size,
54
+ fill: "white",
55
+ opacity: 0
56
+ }, "symbol").animate().to({
57
+ opacity: 1
58
+ }, duration, "linear").to({
59
+ opacity: 0
60
+ }, duration, "linear").loop(1 / 0);
61
+ }
62
+ generateRainOrSnow(type, ratio, threshold, windRatio, group, path, windAngle, sizeRange, speed) {
63
+ let {width: width} = group.attribute;
64
+ const {height: height} = group.attribute;
65
+ let maxCount = Math.round(ratio * threshold);
66
+ windRatio > 0 && (maxCount *= Math.round(1 + windRatio)), width *= Math.round(1 + windRatio);
67
+ const uniformRandomX = createUniformRandom(maxCount), uniformRandomY = createUniformRandom(maxCount);
68
+ for (let i = 0; i < maxCount; i++) {
69
+ const x = uniformRandomX(), y = uniformRandomY(), size = sizeRange[0] + random() * (sizeRange[1] - sizeRange[0]), startX = x * width - (windAngle ? height * Math.tan(Math.abs(windAngle)) : 0), startY = -y * height, particle = group.createOrUpdateChild(`${type}-${i}`, {
70
+ x: startX,
71
+ y: startY,
72
+ symbolType: path,
73
+ size: size,
74
+ fill: "white",
75
+ angle: windAngle
76
+ }, "symbol"), duration = 1 / speed / 2 * (1 + y) * 1e3;
77
+ let endX = x * width;
78
+ "rain" === type && windAngle && (endX = startX + (1 + y) * height * Math.tan(Math.abs(windAngle))),
79
+ particle.animate().to({
80
+ x: endX,
81
+ y: height
82
+ }, duration, "linear").loop(1 / 0);
83
+ }
84
+ }
85
+ }
86
+
87
+ WeatherBox.defaultAttributes = {
88
+ snowIconPath: "M512 64c24.7 0 44.8 20.1 44.8 44.8v43.1l29.3-15.5c21.9-11.6 49-3.2 60.5 18.7s3.2 49-18.7 60.5l-71.2 37.6v85.2c32 8.2 60.6 25.1 83.1 48l73.8-42.6-3-80.4c-0.9-24.7 18.4-45.5 43.1-46.4 24.7-0.9 45.5 18.4 46.4 43.1l1.2 33.1 37.3-21.5c21.4-12.4 48.8-5 61.2 16.4 12.4 21.4 5 48.8-16.4 61.2l-37.3 21.5 28.1 17.6c21 13.2 27.3 40.8 14.1 61.8-13.2 20.9-40.8 27.3-61.8 14.1l-68.2-42.8-73.6 42.5c4.2 15.3 6.5 31.4 6.5 48s-2.3 32.7-6.5 48l73.8 42.6 68.2-42.8c20.9-13.2 48.6-6.8 61.8 14.1 13.2 21 6.8 48.6-14.1 61.8l-28.1 17.6 37.3 21.5c21.4 12.4 28.8 39.8 16.4 61.2-12.4 21.4-39.8 28.8-61.2 16.4l-37.3-21.5-1.2 33.1c-0.9 24.7-21.7 44-46.4 43.1-24.7-0.9-44-21.7-43.1-46.4l3-80.4-73.8-42.6c-22.5 22.9-51 39.8-83.1 48v85.2l71.2 37.6c21.9 11.6 30.2 38.7 18.7 60.5-11.6 21.9-38.7 30.2-60.5 18.7L557 872.2v43.1c0 24.7-20.1 44.8-44.8 44.8-24.7 0-44.8-20.1-44.8-44.8v-43.1l-29.3 15.5c-21.9 11.6-49 3.2-60.5-18.7-11.6-21.9-3.2-49 18.7-60.5l71.2-37.6v-85.2c-32-8.2-60.6-25.1-83.1-48l-73.8 42.6 3 80.4c0.9 24.7-18.4 45.5-43.1 46.4-24.7 0.9-45.5-18.4-46.4-43.1l-1.2-33.1-37.3 21.5c-21.4 12.4-48.8 5-61.2-16.4s-5-48.8 16.4-61.2l37.3-21.5-28.1-17.6c-21-13.2-27.3-40.8-14.1-61.8 13.2-20.9 40.8-27.3 61.8-14.1l68.2 42.8 73.8-42.6c-4.2-15.3-6.5-31.4-6.5-48s2.3-32.7 6.5-48l-73.8-42.6-68.2 42.8c-21 13.2-48.6 6.8-61.8-14.1-13.2-21-6.8-48.6 14.1-61.8l28.1-17.6-37.3-21.5C119 336.8 111.7 309.4 124 288c12.4-21.4 39.8-28.8 61.2-16.4l37.3 21.5 1.2-33.1c0.9-24.7 21.7-44 46.4-43.1 24.7 0.9 44 21.7 43.1 46.4l-3 80.4 73.8 42.6c22.5-22.9 51-39.8 83.1-48v-85.2L396 215.6c-21.9-11.6-30.2-38.7-18.7-60.5 11.6-21.9 38.7-30.2 60.5-18.7l29.3 15.5v-43.1C467.2 84.1 487.3 64 512 64z m0 537.6c49.5 0 89.6-40.1 89.6-89.6s-40.1-89.6-89.6-89.6-89.6 40.1-89.6 89.6 40.1 89.6 89.6 89.6z",
89
+ rainIconPath: "M802.94208 583.04c19.328 38.016 29.056 78.336 29.056 120.96a313.216 313.216 0 0 1-44.032 161.536 324.48 324.48 0 0 1-114.56 114.944c-23.552 13.696-49.024 24.32-76.416 32-27.264 7.68-55.68 11.52-84.992 11.52-29.44 0-57.6-3.84-84.992-11.52a331.136 331.136 0 0 1-76.544-32 337.536 337.536 0 0 1-65.024-49.92 337.536 337.536 0 0 1-49.92-65.024 331.136 331.136 0 0 1-32-76.544A313.216 313.216 0 0 1 191.99808 704c0-42.24 9.344-82.56 28.032-120.448L509.43808 0l293.504 583.04z",
90
+ windIconPath: "M686.624 143.072h-150.816a40.352 40.352 0 1 0 0 80.608h150.816a80.672 80.672 0 1 1 0 161.184H226.624a40.352 40.352 0 1 0 0 80.608h460a161.344 161.344 0 1 0 0-322.4z m168.768 725.344h-126.72a40.352 40.352 0 1 1 0-80.576h126.56a80.672 80.672 0 1 0 0-161.184H42.176a40.352 40.352 0 1 1 0-80.608h813.056a161.344 161.344 0 1 1 0 322.368z",
91
+ windRatio: 0,
92
+ rainRatio: 0,
93
+ snowRatio: 0,
94
+ rainCountThreshold: 10,
95
+ snowCountThreshold: 10,
96
+ rainSizeRange: [ 5, 10 ],
97
+ snowSizeRange: [ 5, 13 ],
98
+ windSize: 30,
99
+ rainSpeed: 1,
100
+ snowSpeed: .5,
101
+ windSpeed: 1,
102
+ rainStyle: {
103
+ background: "rgb(135, 160, 225)"
104
+ },
105
+ snowStyle: {
106
+ background: "rgb(64, 68, 144)"
107
+ },
108
+ rainSnowStyle: {
109
+ background: "rgb(130, 190, 210)"
110
+ },
111
+ defaultStyle: {
112
+ background: "rgb(184, 206, 239)"
113
+ }
114
+ };
115
+ //# sourceMappingURL=weather-box.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/weather/weather-box.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKzC,SAAS,MAAM;IACb,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;AACvB,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC;IACvB,KAAK,IAAI,CAAC,GAAG,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D,YAAY,EAAE;QACZ,UAAU,EAAE,oBAAoB;KACjC;CACF,CAAC","file":"weather-box.js","sourcesContent":["import { AbstractComponent } from '../core/base';\nimport type { IWeatherBoxAttrs } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { merge } from '@visactor/vutils';\nimport type { IGroup, ISymbol } from '@visactor/vrender-core';\nimport { IGraphic } from '@visactor/vrender-core';\n\n// todo 后续可能做成有随机数种子的伪随机,这样可以保证每次都生成一样的随机数\nfunction random() {\n return Math.random();\n}\n\nfunction createUniformRandom(count: number) {\n const result: number[] = [];\n const step = 1 / count;\n for (let i = 0; i < count; i++) {\n result.push(((random() - 0.5) * step) / 2 + step * i);\n }\n result.sort(() => Math.random() - 0.5);\n let idx = 0;\n return function (i?: number) {\n if (idx > count - 1) {\n idx = 0;\n }\n if (i === void 0) {\n i = idx;\n idx++;\n }\n return result[i];\n };\n}\n\nexport class WeatherBox extends AbstractComponent<Required<IWeatherBoxAttrs>> {\n name: string = 'weatherBox';\n\n static defaultAttributes: Partial<IWeatherBoxAttrs> = {\n snowIconPath:\n 'M512 64c24.7 0 44.8 20.1 44.8 44.8v43.1l29.3-15.5c21.9-11.6 49-3.2 60.5 18.7s3.2 49-18.7 60.5l-71.2 37.6v85.2c32 8.2 60.6 25.1 83.1 48l73.8-42.6-3-80.4c-0.9-24.7 18.4-45.5 43.1-46.4 24.7-0.9 45.5 18.4 46.4 43.1l1.2 33.1 37.3-21.5c21.4-12.4 48.8-5 61.2 16.4 12.4 21.4 5 48.8-16.4 61.2l-37.3 21.5 28.1 17.6c21 13.2 27.3 40.8 14.1 61.8-13.2 20.9-40.8 27.3-61.8 14.1l-68.2-42.8-73.6 42.5c4.2 15.3 6.5 31.4 6.5 48s-2.3 32.7-6.5 48l73.8 42.6 68.2-42.8c20.9-13.2 48.6-6.8 61.8 14.1 13.2 21 6.8 48.6-14.1 61.8l-28.1 17.6 37.3 21.5c21.4 12.4 28.8 39.8 16.4 61.2-12.4 21.4-39.8 28.8-61.2 16.4l-37.3-21.5-1.2 33.1c-0.9 24.7-21.7 44-46.4 43.1-24.7-0.9-44-21.7-43.1-46.4l3-80.4-73.8-42.6c-22.5 22.9-51 39.8-83.1 48v85.2l71.2 37.6c21.9 11.6 30.2 38.7 18.7 60.5-11.6 21.9-38.7 30.2-60.5 18.7L557 872.2v43.1c0 24.7-20.1 44.8-44.8 44.8-24.7 0-44.8-20.1-44.8-44.8v-43.1l-29.3 15.5c-21.9 11.6-49 3.2-60.5-18.7-11.6-21.9-3.2-49 18.7-60.5l71.2-37.6v-85.2c-32-8.2-60.6-25.1-83.1-48l-73.8 42.6 3 80.4c0.9 24.7-18.4 45.5-43.1 46.4-24.7 0.9-45.5-18.4-46.4-43.1l-1.2-33.1-37.3 21.5c-21.4 12.4-48.8 5-61.2-16.4s-5-48.8 16.4-61.2l37.3-21.5-28.1-17.6c-21-13.2-27.3-40.8-14.1-61.8 13.2-20.9 40.8-27.3 61.8-14.1l68.2 42.8 73.8-42.6c-4.2-15.3-6.5-31.4-6.5-48s2.3-32.7 6.5-48l-73.8-42.6-68.2 42.8c-21 13.2-48.6 6.8-61.8-14.1-13.2-21-6.8-48.6 14.1-61.8l28.1-17.6-37.3-21.5C119 336.8 111.7 309.4 124 288c12.4-21.4 39.8-28.8 61.2-16.4l37.3 21.5 1.2-33.1c0.9-24.7 21.7-44 46.4-43.1 24.7 0.9 44 21.7 43.1 46.4l-3 80.4 73.8 42.6c22.5-22.9 51-39.8 83.1-48v-85.2L396 215.6c-21.9-11.6-30.2-38.7-18.7-60.5 11.6-21.9 38.7-30.2 60.5-18.7l29.3 15.5v-43.1C467.2 84.1 487.3 64 512 64z m0 537.6c49.5 0 89.6-40.1 89.6-89.6s-40.1-89.6-89.6-89.6-89.6 40.1-89.6 89.6 40.1 89.6 89.6 89.6z',\n rainIconPath:\n 'M802.94208 583.04c19.328 38.016 29.056 78.336 29.056 120.96a313.216 313.216 0 0 1-44.032 161.536 324.48 324.48 0 0 1-114.56 114.944c-23.552 13.696-49.024 24.32-76.416 32-27.264 7.68-55.68 11.52-84.992 11.52-29.44 0-57.6-3.84-84.992-11.52a331.136 331.136 0 0 1-76.544-32 337.536 337.536 0 0 1-65.024-49.92 337.536 337.536 0 0 1-49.92-65.024 331.136 331.136 0 0 1-32-76.544A313.216 313.216 0 0 1 191.99808 704c0-42.24 9.344-82.56 28.032-120.448L509.43808 0l293.504 583.04z',\n windIconPath:\n 'M686.624 143.072h-150.816a40.352 40.352 0 1 0 0 80.608h150.816a80.672 80.672 0 1 1 0 161.184H226.624a40.352 40.352 0 1 0 0 80.608h460a161.344 161.344 0 1 0 0-322.4z m168.768 725.344h-126.72a40.352 40.352 0 1 1 0-80.576h126.56a80.672 80.672 0 1 0 0-161.184H42.176a40.352 40.352 0 1 1 0-80.608h813.056a161.344 161.344 0 1 1 0 322.368z',\n windRatio: 0,\n rainRatio: 0,\n snowRatio: 0,\n rainCountThreshold: 10,\n snowCountThreshold: 10,\n rainSizeRange: [5, 10],\n snowSizeRange: [5, 13],\n windSize: 30,\n rainSpeed: 1,\n snowSpeed: 0.5,\n windSpeed: 1,\n rainStyle: {\n background: 'rgb(135, 160, 225)'\n },\n snowStyle: {\n background: 'rgb(64, 68, 144)'\n },\n rainSnowStyle: {\n background: 'rgb(130, 190, 210)'\n },\n defaultStyle: {\n background: 'rgb(184, 206, 239)'\n }\n };\n\n constructor(attributes: IWeatherBoxAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, WeatherBox.defaultAttributes, attributes));\n }\n\n protected render(): void {\n const {\n rainRatio,\n rainIconPath,\n snowRatio,\n snowIconPath,\n rainCountThreshold,\n snowCountThreshold,\n windRatio,\n rainSizeRange,\n snowSizeRange,\n rainSpeed,\n snowSpeed,\n width,\n height,\n rainSnowStyle,\n rainStyle,\n snowStyle,\n defaultStyle,\n windIconPath,\n windSize,\n windSpeed\n } = this.attribute as IWeatherBoxAttrs;\n\n if (rainRatio && snowRatio) {\n this.attribute.background = rainSnowStyle?.background;\n } else if (rainRatio) {\n this.attribute.background = rainStyle?.background;\n } else if (snowRatio) {\n this.attribute.background = snowStyle?.background;\n } else {\n this.attribute.background = defaultStyle?.background;\n }\n this.attribute.clip = true;\n\n // 计算风速导致的偏转角度\n const windAngle = (-windRatio * Math.PI) / 4;\n\n const rainGroup = this.createOrUpdateChild('rain-container', { zIndex: 1, width, height }, 'group') as IGroup;\n if (rainRatio > 0) {\n this.generateRainOrSnow(\n 'rain',\n rainRatio,\n rainCountThreshold,\n windRatio,\n rainGroup,\n rainIconPath,\n windAngle,\n rainSizeRange,\n rainSpeed\n );\n }\n const snowGroup = this.createOrUpdateChild('snow-container', { zIndex: 1, width, height }, 'group') as IGroup;\n if (snowRatio > 0) {\n this.generateRainOrSnow(\n 'snow',\n snowRatio,\n snowCountThreshold,\n windRatio,\n snowGroup,\n snowIconPath,\n windAngle,\n snowSizeRange,\n snowSpeed\n );\n }\n\n const windGroup = this.createOrUpdateChild('wind-container', { zIndex: 0, width, height }, 'group') as IGroup;\n if (windRatio > 0) {\n this.generateWind(windRatio, windIconPath, windGroup, windSize, windSpeed);\n }\n }\n\n protected generateWind(windRatio: number, windIconPath: string, group: IGroup, size: number, speed: number) {\n const { width, height } = group.attribute;\n\n const wind = group.createOrUpdateChild(\n `wind`,\n {\n x: (width - size) / 2,\n y: (height - size) / 2,\n symbolType: windIconPath,\n size,\n fill: 'white',\n opacity: 0\n },\n 'symbol'\n ) as ISymbol;\n\n const duration = (speed / 4) * 1000;\n\n wind.animate().to({ opacity: 1 }, duration, 'linear').to({ opacity: 0 }, duration, 'linear').loop(Infinity);\n }\n\n protected generateRainOrSnow(\n type: string,\n ratio: number,\n threshold: number,\n windRatio: number,\n group: IGroup,\n path: string,\n windAngle: number,\n sizeRange: [number, number],\n speed: number\n ) {\n let { width } = group.attribute;\n const { height } = group.attribute;\n let maxCount = Math.round(ratio * threshold);\n // 由于风速,雨雪粒子会偏转,所以需要增加粒子数量\n if (windRatio > 0) {\n maxCount = maxCount * Math.round(1 + windRatio);\n }\n width = width * Math.round(1 + windRatio);\n const uniformRandomX = createUniformRandom(maxCount);\n const uniformRandomY = createUniformRandom(maxCount);\n for (let i = 0; i < maxCount; i++) {\n const x = uniformRandomX();\n const y = uniformRandomY();\n const size = sizeRange[0] + random() * (sizeRange[1] - sizeRange[0]);\n\n const deltaX = windAngle ? height * Math.tan(Math.abs(windAngle)) : 0;\n const startX = x * width - deltaX;\n const startY = -y * height;\n const particle = group.createOrUpdateChild(\n `${type}-${i}`,\n {\n x: startX,\n y: startY,\n symbolType: path,\n size,\n fill: 'white',\n angle: windAngle\n },\n 'symbol'\n ) as ISymbol;\n const duration = (1 / speed / 2) * (1 + y) * 1000;\n let endX = x * width;\n if (type === 'rain' && windAngle) {\n endX = startX + (1 + y) * height * Math.tan(Math.abs(windAngle));\n }\n particle.animate().to({ x: endX, y: height }, duration, 'linear').loop(Infinity);\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-components",
3
- "version": "0.20.10",
3
+ "version": "0.20.11-alpha.1",
4
4
  "description": "components library for dp visualization",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -14,8 +14,8 @@
14
14
  "dependencies": {
15
15
  "@visactor/vutils": "~0.18.17",
16
16
  "@visactor/vscale": "~0.18.17",
17
- "@visactor/vrender-core": "0.20.10",
18
- "@visactor/vrender-kits": "0.20.10"
17
+ "@visactor/vrender-core": "0.20.11-alpha.1",
18
+ "@visactor/vrender-kits": "0.20.11-alpha.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@rushstack/eslint-patch": "~1.1.4",