Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Makecode program crashes when rotating an image
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Makecode program crashes when rotating an image

by ractive on Sat Apr 25, 2020 3:49 pm

Dear PyGamer users

Rotating any image by 90 or 270 degrees let the MakeCode arcade game crash on the PyGamer. This very simple MakeCode arcade program crashes with the error code 821 when executed on the PyGamer (while it successfully runs in the simulator):

Code: Select all | TOGGLE FULL SIZE
img`1`.rotated(90);


I'm not sure if this is an issue with MakeCode arcade or with the PyGamer. Any clues where to do a proper error report?

ractive
 
Posts: 3
Joined: Sat Apr 25, 2020 3:41 pm

Re: Makecode program crashes when rotating an image

by ractive on Sat Apr 25, 2020 4:27 pm

Actually the call to image.transpose fails: img`1`.transpose()

As a workaround, use these functions here:
Code: Select all | TOGGLE FULL SIZE
function transpose(img: Image): Image {
    const result = image.create(img.height, img.width);
    for(let x = 0; x < img.width; x++) {
        for (let y = 0; y < img.height; y++) {
            result.setPixel(y, x, img.getPixel(x, y));
        }
    }
    return result;
}

function rotate(img: Image, deg: number): Image {
    if (deg == -90 || deg == 270) {
        const r = transpose(img);
        r.flipY();
        return r;
    } else if (deg == 180 || deg == -180) {
        const r = i.clone();
        r.flipX();
        r.flipY();
        return r;
    } else if (deg == 90) {
        const r = transpose(i);
        r.flipX();
        return r;
    } else {
        return i;
    }
}

ractive
 
Posts: 3
Joined: Sat Apr 25, 2020 3:41 pm

Re: Makecode program crashes when rotating an image

by johnpark on Thu Apr 30, 2020 10:02 pm

Interesting. Could you share the original code you were using that was crashing?

johnpark
 
Posts: 767
Joined: Wed Mar 25, 2009 2:15 pm

Re: Makecode program crashes when rotating an image

by ractive on Sun May 03, 2020 3:15 pm

Hi John

This super simple program crashes on my PyGamer with code 821:
https://makecode.com/_JkFch21Mp3AW

Best regards,
James

ractive
 
Posts: 3
Joined: Sat Apr 25, 2020 3:41 pm

Please be positive and constructive with your questions and comments.