@@ -26,19 +26,13 @@ class Rain(start: PointF, end: PointF) : WeatherShape(start, end) {
26
26
length = value
27
27
}
28
28
29
- var translateX = 0f
30
29
var timeSpace = 16
31
30
// var originSpeed = speed
32
- var rainAlpha = 100
33
31
var rainColor = Color .parseColor(" #efefef" )
34
- // override var time: Long = 5000 // 总共下落时间
35
32
36
33
37
34
// 计算加速度
38
35
override fun getAcceleration (): Float {
39
- // val acc = context.getScreenHeight() / (time * time).toFloat()
40
- // LogUtil.i(TAG, "acc = " + acc)
41
- // 恩,决定了,放弃加速,匀速走完
42
36
return 0f
43
37
}
44
38
@@ -65,58 +59,14 @@ class Rain(start: PointF, end: PointF) : WeatherShape(start, end) {
65
59
end.y = 0f
66
60
}
67
61
68
- // override fun initStyle(wtc: () -> Unit) {
69
- // super.initStyle(wtc)
70
- // }
71
-
72
- override fun wtc () {
73
- val random = Random ()
62
+ override fun wtc (random : Random ) {
74
63
length = random.nextInt(5 ).toFloat() + originLength
75
64
paint.apply {
76
65
color = rainColor
77
66
}
78
67
}
79
68
80
69
81
- // 通过该方法来获取一个随机的初始化样式
82
- // override fun initStyle() {
83
- // val random = Random()
84
- // // 获取随机透明值
85
- // rainAlpha = random.nextInt(155) + 50
86
- // // 获得起点x偏移
87
- // translateX = random.nextInt(10).toFloat() + 5
88
- // // 获得长度
89
- // length = random.nextInt(5).toFloat() + originLength
90
- // // 获得宽度 5 ~ 8
91
- // width = random.nextInt(3) + 5f
92
- // if (!isRandom) {
93
- // start.x = translateX + originX
94
- // end.x = translateX + originX
95
- // } else {
96
- // // 如果是随机雨点,将x坐标随机范围扩大
97
- // val randomWidth = random.nextInt(context.getScreenWidth())
98
- // start.x = randomWidth + originX
99
- // end.x = randomWidth + originX
100
- // }
101
- // start.y = -length
102
- // end.y = 0f
103
- // paint.apply {
104
- // alpha = rainAlpha
105
- // strokeWidth = width
106
- // color = rainColor
107
- // isAntiAlias = true
108
- // }
109
- // super.initStyle {
110
- //
111
- // }
112
- // val random = Random()
113
- // length = random.nextInt(5).toFloat() + originLength
114
- // paint.apply {
115
- // color = rainColor
116
- // }
117
-
118
- // }
119
-
120
70
override fun randomSpeed (random : Random ): Float {
121
71
// 获取随机速度 0.02 ~ 0.06
122
72
var randomSpeed = random.nextFloat() / 10
0 commit comments