1
0
Fork 0

feat(shape): add RotateCW() and RotateCCW()

This commit is contained in:
Henrik Hautakoski 2025-09-15 06:54:20 +02:00
parent ab1c774a26
commit 6131b751e5

View file

@ -56,3 +56,29 @@ func (s Shape) Coordinates() [4]core.Vec2i8 {
s.coordinates[2],
}
}
func (s Shape) RotateCW() Shape {
rotated := [3]core.Vec2i8{}
for i, block := range s.coordinates {
block.X, block.Y = -1*block.Y, block.X
rotated[i] = block
}
return Shape{
typ: s.typ,
coordinates: rotated,
}
}
func (s Shape) RotateCCW() Shape {
rotated := [3]core.Vec2i8{}
for i, block := range s.coordinates {
block.X, block.Y = block.Y, -1*block.X
rotated[i] = block
}
return Shape{
typ: s.typ,
coordinates: rotated,
}
}