Skip to content

Commit 832f42a

Browse files
committed
Refactoring code
1 parent 39992af commit 832f42a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+356
-439
lines changed

app/src/main/java/com/zdog/demo/ui/basic/Shapes.kt

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,43 @@ class Shapes {
1515
shape {
1616
addTo = shapes[index++].illo
1717
path(
18-
line(x = -40f),
18+
move(x = -40f),
1919
line(x = 40f)
2020
)
2121
stroke = 20f
22-
color = "#636".toColour()
22+
color = "#636"
2323
}
2424

2525
shape {
2626
addTo = shapes[index++].illo
2727
path(
28-
line(x = -32f, y = -40f),
28+
move(x = -32f, y = -40f),
2929
line(x = 32f, y = -40f),
3030
line(x = -32f, y = 40f),
3131
line(x = 32f, y = 40f)
3232
)
3333
closed = false
3434
stroke = 20f
35-
color = "#636".toColour()
35+
color = "#636"
3636
}
3737

3838
shape {
3939
addTo = shapes[index++].illo
4040
path(
41-
line(x = -32f, y = -40f, z = 40f),
41+
move(x = -32f, y = -40f, z = 40f),
4242
line(x = 32f, y = -40f),
4343
line(x = 32f, y = 40f, z = 40f),
4444
line(x = 32f, y = 40f, z = -40f)
4545
)
4646
closed = false
4747
stroke = 20f
48-
color = "#636".toColour()
48+
color = "#636"
4949
}
5050

5151
shape {
5252
addTo = shapes[index++].illo
5353
path(
54-
line(x = -60f, y = -60f),
54+
move(x = -60f, y = -60f),
5555
arc(
5656
vector(x = 20f, y = -60f),
5757
vector(x = 20f, y = 20f)
@@ -63,13 +63,13 @@ class Shapes {
6363
)
6464
closed = false
6565
stroke = 20f
66-
color = "#636".toColour()
66+
color = "#636"
6767
}
6868

6969
shape {
7070
addTo = shapes[index++].illo
7171
path(
72-
line(x = -60f, y = -60f),
72+
move(x = -60f, y = -60f),
7373
bezier(
7474
vector(x = 20f, y = -60f),
7575
vector(x = 20f, y = 60f),
@@ -78,18 +78,18 @@ class Shapes {
7878
)
7979
closed = false
8080
stroke = 20f
81-
color = "#636".toColour()
81+
color = "#636"
8282
}
8383

8484
val triangle = shape {
8585
addTo = shapes[index++].illo
8686
path(
87-
line(x = 0f, y = -40f),
87+
move(x = 0f, y = -40f),
8888
line(x = 40f, y = 40f),
8989
line(x = -40f, y = 40f)
9090
)
9191
stroke = 20f
92-
color = "#636".toColour()
92+
color = "#636"
9393
}
9494

9595
triangle.copy {
@@ -101,36 +101,36 @@ class Shapes {
101101
addTo = shapes[index++].illo
102102
diameter = 120f
103103
stroke = 0f
104-
color = "#C25".toColour()
105-
backface = "#EA0".toColour()
104+
color = "#C25"
105+
backface = "#EA0"
106106
}
107107

108108
cone {
109109
addTo = shapes[index++].illo
110110
diameter = 70f
111111
length = 90f
112112
stroke = 0f
113-
color = "#636".toColour()
114-
backface = "#C25".toColour()
113+
color = "#636"
114+
backface = "#C25"
115115
}
116116

117117
cylinder {
118118
addTo = shapes[index++].illo
119119
diameter = 80f
120120
length = 120f
121121
stroke = 0f
122-
color = "#C25".toColour()
123-
backface = "#E62".toColour()
122+
color = "#C25"
123+
backface = "#E62"
124124
}
125125

126126
cylinder {
127127
addTo = shapes[index++].illo
128128
diameter = 80f
129129
length = 120f
130130
stroke = 0f
131-
color = "#C25".toColour()
132-
frontFace = "#EA0".toColour()
133-
backface = "#636".toColour()
131+
color = "#C25"
132+
frontFace = "#EA0"
133+
backface = "#636"
134134
}
135135

136136
val box = box {
@@ -139,18 +139,18 @@ class Shapes {
139139
height = 100f
140140
depth = 80f
141141
stroke = 0f
142-
color = "#C25".toColour()
143-
leftFace = "#EA0".toColour()
144-
rightFace = "#E62".toColour()
145-
topFace = "#ED0".toColour()
146-
bottomFace = "#636".toColour()
142+
color = "#C25"
143+
leftFace = "#EA0"
144+
rightFace = "#E62"
145+
topFace = "#ED0"
146+
bottomFace = "#636"
147147
}
148148

149149
box.copy {
150150
addTo = shapes[index++].illo
151151
leftFace = null
152152
rightFace = null
153-
rearFace = "#EA0".toColour()
153+
rearFace = "#EA0"
154154
}
155155

156156
val distance = 40f
@@ -160,23 +160,23 @@ class Shapes {
160160
addTo = shapes[index++].illo
161161
translate(y = -distance)
162162
stroke = 80f
163-
color = "#636".toColour()
163+
color = "#636"
164164
}
165165
dot.copy {
166166
translate(x = -distance)
167-
color = "#EA0".toColour()
167+
color = "#EA0"
168168
}
169169
dot.copy {
170170
translate(z = distance)
171-
color = "#C25".toColour()
171+
color = "#C25"
172172
}
173173
dot.copy {
174174
translate(x = distance)
175-
color = "#E62".toColour()
175+
color = "#E62"
176176
}
177177
dot.copy {
178178
translate(z = -distance)
179-
color = "#C25".toColour()
179+
color = "#C25"
180180
}
181181
dot.copy {
182182
translate(y = distance)

app/src/main/java/com/zdog/demo/ui/effects/Sky.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Sky(world: World) {
7676

7777
sunshine = combine {
7878
translate(y = -16f, z = 47f)
79-
color = Colors.gold2.colour
79+
color = Colors.gold2.color
8080
}.also {
8181
(0..11).forEach { index ->
8282
shape {
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package com.zdog.demo.ui.effects
22

3-
import com.zdog.library.render.Colour
4-
53
abstract class SkyTheme {
6-
abstract val sky: Colour
7-
abstract val background1: Colour
8-
abstract val background2: Colour
9-
abstract val background3: Colour
10-
abstract val sun: Colour
11-
abstract val cloud: Colour
4+
abstract val sky: String
5+
abstract val background1: String
6+
abstract val background2: String
7+
abstract val background3: String
8+
abstract val sun: String
9+
abstract val cloud: String
1210
}

app/src/main/java/com/zdog/demo/ui/effects/cloud/Theme.kt

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,72 +16,71 @@ import com.zdog.demo.ui.shapes.Colors.midday
1616
import com.zdog.demo.ui.shapes.Colors.midnight
1717
import com.zdog.demo.ui.shapes.Colors.white
1818
import com.zdog.demo.ui.effects.SkyTheme
19-
import com.zdog.library.render.Colour
2019

2120
internal data class Theme(
22-
override val sky: Colour,
23-
override val background1: Colour,
24-
override val background2: Colour,
25-
override val background3: Colour,
26-
override val sun: Colour,
27-
override val cloud: Colour,
21+
override val sky: String,
22+
override val background1: String,
23+
override val background2: String,
24+
override val background3: String,
25+
override val sun: String,
26+
override val cloud: String,
2827

29-
val grass1: Colour,
30-
val fan1:Colour,
31-
val body1: Colour,
28+
val grass1: String,
29+
val fan1:String,
30+
val body1: String,
3231

33-
val grass2: Colour,
34-
val fan2:Colour,
35-
val body2: Colour,
32+
val grass2: String,
33+
val fan2:String,
34+
val body2: String,
3635

37-
val grass3: Colour,
38-
val fan3:Colour,
39-
val body3: Colour
36+
val grass3: String,
37+
val fan3:String,
38+
val body3: String
4039
): SkyTheme() {
4140
companion object {
4241
private val day by lazy {
4342
Theme(
44-
sky = midday.colour,
45-
background1 = blue1.colour,
46-
background2 = blue2.colour,
47-
background3 = blue3.colour,
48-
sun = gold1.colour,
49-
cloud = white.colour,
43+
sky = midday.color,
44+
background1 = blue1.color,
45+
background2 = blue2.color,
46+
background3 = blue3.color,
47+
sun = gold1.color,
48+
cloud = white.color,
5049

51-
grass1 = green1.colour,
52-
fan1 = gray1.colour,
53-
body1 = gray2.colour,
50+
grass1 = green1.color,
51+
fan1 = gray1.color,
52+
body1 = gray2.color,
5453

55-
grass2 = green2.colour,
56-
fan2 = gray1.colour,
57-
body2 = gray2.colour,
54+
grass2 = green2.color,
55+
fan2 = gray1.color,
56+
body2 = gray2.color,
5857

59-
grass3 = green3.colour,
60-
fan3 = gray1.colour,
61-
body3 = gray2.colour
58+
grass3 = green3.color,
59+
fan3 = gray1.color,
60+
body3 = gray2.color
6261
)
6362
}
6463

6564
private val night by lazy {
6665
Theme(
67-
sky = midnight.colour,
68-
background1 = magenta.colour,
69-
background2 = amber.colour,
70-
background3 = gold1.colour,
71-
sun = white.colour,
72-
cloud = amber.colour,
66+
sky = midnight.color,
67+
background1 = magenta.color,
68+
background2 = amber.color,
69+
background3 = gold1.color,
70+
sun = white.color,
71+
cloud = amber.color,
7372

74-
grass1 = magenta.colour,
75-
fan1 = magenta.colour,
76-
body1 = magenta.colour,
73+
grass1 = magenta.color,
74+
fan1 = magenta.color,
75+
body1 = magenta.color,
7776

78-
grass2 = eggplant.colour,
79-
fan2 = eggplant.colour,
80-
body2 = eggplant.colour,
77+
grass2 = eggplant.color,
78+
fan2 = eggplant.color,
79+
body2 = eggplant.color,
8180

82-
grass3 = midnight.colour,
83-
fan3 = midnight.colour,
84-
body3 = midnight.colour
81+
grass3 = midnight.color,
82+
fan3 = midnight.color,
83+
body3 = midnight.color
8584
)
8685
}
8786

app/src/main/java/com/zdog/demo/ui/effects/cloud/Windmill.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Windmill : Group() {
6767
return super.scale(scale)
6868
}
6969

70-
fun changeColor(world: World, fan: Colour, body: Colour, duration: Long = 0, delay: Long = 0) {
70+
fun changeColor(world: World, fan: String, body: String, duration: Long = 0, delay: Long = 0) {
7171
if (duration > 0) {
7272
this.fan.colorTo(world, fan).delay(delay).duration(duration).start()
7373
this.body.colorTo(world, body).delay(delay).duration(duration).start()

app/src/main/java/com/zdog/demo/ui/effects/rain/Sea2.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Sea2 : Entity() {
4747
private fun initColor(theme: Theme) {
4848
sea.color = theme.sea2
4949
spray.color = theme.sea2
50-
smoke.color = Colors.gray1.colour
50+
smoke.color = Colors.gray1.color
5151
}
5252

5353
override fun onAttachTo(world: World, inDay: Boolean) {

0 commit comments

Comments
 (0)