espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.73k stars 741 forks source link

Graphics: drawing image in string in clipped rect fails when rotated #2435

Closed gfwilliams closed 7 months ago

gfwilliams commented 7 months ago

As reported in https://forum.espruino.com/conversations/392047/#comment17204835

Reproducible with:

g.setRotation(2);
var txt = "\0"+atob("EhKBAH//v/////////////5//x//j//H+eP+Mf/A//h//z//////////3//g");

E.showScroller({
  h : 40, c : 8,
  draw : (idx, r) => {
    g.setBgColor((idx&1)?"#666":"#999").clearRect(r.x,r.y,r.x+r.w-1,r.y+r.h-1);
    g.setFont("6x8:2").drawString(txt+idx,r.x+10,r.y+4);
  },
  select : (idx) => console.log("You selected ", idx)
});

Renders fine initially but then broken when scrolling.

gfwilliams commented 7 months ago

Or more basic:

g.setRotation(2); // works if not set
var txt = "\0"+atob("EhKBAH//v/////////////5//x//j//H+eP+Mf/A//h//z//////////3//g");

for (var y=0;y<176;y+=24) {
  g.setClipRect(0,y,175,y+23);
  g.setFont("6x8:3").drawString(txt,0,y);
}

It renders in the middle, so it's that the clip rect for drawing images hasn't been rotated