Skip to content

Commit 9c1120c

Browse files
committed
feat(plugin): add rotate method to Rotations
1 parent 73873b7 commit 9c1120c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

plugin/src/shared/sc/plugin2021/Rotation.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ enum class Rotation(val value: Int) {
99
RIGHT(1),
1010
MIRROR(2),
1111
LEFT(3);
12+
13+
fun rotate(rotation: Rotation): Rotation =
14+
Rotation.values()[(Rotation.values().size + value + rotation.value) % Rotation.values().size]
1215
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package sc.plugin2021
2+
3+
import io.kotlintest.shouldBe
4+
import io.kotlintest.specs.StringSpec
5+
6+
class RotationTest: StringSpec ({
7+
"Rotations can get rotated" {
8+
Rotation.values().forEach {
9+
it.rotate(Rotation.NONE) shouldBe it
10+
Rotation.NONE.rotate(it) shouldBe it
11+
it.rotate(Rotation.RIGHT).rotate(Rotation.LEFT) shouldBe it
12+
it.rotate(Rotation.MIRROR).rotate(Rotation.MIRROR) shouldBe it
13+
it.rotate(Rotation.LEFT).rotate(Rotation.LEFT) shouldBe it.rotate(Rotation.MIRROR)
14+
}
15+
}
16+
})

0 commit comments

Comments
 (0)