added mirror function to structure
This commit is contained in:
parent
9bb6b8bf2b
commit
1d2a43155a
@ -14,6 +14,14 @@ abstract Structure(Array<Layer>) from Array<Layer> {
|
||||
public function rotate():Structure {
|
||||
return [for (i in 0...height()) this[i].rotate()];
|
||||
}
|
||||
|
||||
public function mirrorX():Structure {
|
||||
return [for (i in 0...height()) this[i].mirrorX()];
|
||||
}
|
||||
|
||||
public function mirrorY():Structure {
|
||||
return [for (i in 0...height()) this[i].mirrorY()];
|
||||
}
|
||||
}
|
||||
|
||||
abstract Layer(Array<Array<Block>>) from Array<Array<Block>> {
|
||||
@ -65,4 +73,28 @@ abstract Layer(Array<Array<Block>>) from Array<Array<Block>> {
|
||||
|
||||
return rotatedMatrix;
|
||||
}
|
||||
|
||||
public function mirrorX():Layer {
|
||||
var rtn = [];
|
||||
|
||||
for (y in 0...height()) {
|
||||
var rev = this[y].copy();
|
||||
rev.reverse();
|
||||
rtn.push(rev);
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
public function mirrorY():Layer {
|
||||
var rtn = [for (_ in 0...height()) []];
|
||||
|
||||
for (y in 0...height()) {
|
||||
for (x in 0...width()) {
|
||||
rtn[height() - 1 - y][x] = get(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user