pxt-arcade
pxt-arcade copied to clipboard
Image.rotated(0) returns null.
The help for Image.rotated()
says "Returns an image rotated by -90, 0, 90, 180, 270 deg clockwise". However, passing 0 to the function returns null. The corresponding code for imageRotated()
in image.ts is:
/**
* Returns an image rotated by 90, 180, 270 deg clockwise
*/
export function imageRotated(img: Image, deg: number) {
if (deg == -90 || deg == 270) {
let r = img.transposed();
r.flipY();
return r;
} else if (deg == 180 || deg == -180) {
let r = img.clone();
r.flipX();
r.flipY();
return r;
} else if (deg == 90) {
let r = img.transposed();
r.flipX();
return r;
} else {
return null;
}
}
Note that the function actually handles -90, 270, 180, -180, and 90, contrary to the comment on the function or the comment on Image.rotated()
which provides the help string. So either the comments should be updated, or the code should be updated to support a rotation of 0 degrees.