g.clear();
// fill screen with green
g.setColor(0,1,0); // green
g.fillRect(0,0,239,239);
// reset getModified area
m=g.getModified(true);
print(m);
g.setColor(1,0,0); // red
// g.fillRect(100,100,120,120);
m=g.getModified();
print(m);
g.clearRect(m.x1,m.y1,m.x2,m.y2);
Output is:
>{ "x1": 0, "y1": 0, "x2": 239, "y2": 239 }
>undefined
>Uncaught Error: Cannot read property 'x1' of undefined
at line 20 col 14
g.clearRect(m.x1,m.y1,m.x2,m.y2);
^
>
I see now dat getModified(true) returns an undefined. I was completely mislead by the response >{ "x1": 0, "y1": 0, "x2": 239, "y2": 239 } and assumed that this was the area that was set.
Apologies for wasting your time (red face), appreciate the help.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hmmmmmm, major error on my part :-(
My code from the emulator:
Output is:
I see now dat getModified(true) returns an
undefined
. I was completely mislead by the response>{ "x1": 0, "y1": 0, "x2": 239, "y2": 239 }
and assumed that this was the area that was set.Apologies for wasting your time (red face), appreciate the help.