Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlays are cut off from the top instead of landing at desired y position #2520

Closed
ssievert42 opened this issue Jun 21, 2024 · 2 comments · Fixed by #2522
Closed

overlays are cut off from the top instead of landing at desired y position #2520

ssievert42 opened this issue Jun 21, 2024 · 2 comments · Fixed by #2522

Comments

@ssievert42
Copy link
Contributor

Overlays are being cut off from the top, by about as many pixels as their y position should be, instead of landing at the desired y position.

To reproduce on a Bangle.js 2 (code copied from the docs about overlays):

g.setBgColor(0, 1, 0).clear().reset();

var ovr = Graphics.createArrayBuffer(100,100,2,{msb:true});
ovr.transparent = 0;
ovr.palette = new Uint16Array([0,0,g.toColor("#F00"),g.toColor("#FFF")]);
ovr.setColor(1).fillRect({x:0,y:0,w:99,h:99,r:8});
ovr.setColor(3).fillRect({x:2,y:2,w:95,h:95,r:7});
ovr.setColor(2).setFont("Vector:30").setFontAlign(0,0).drawString("Hi",50,50);
Bangle.setLCDOverlay(ovr,38,38, {id: "myOverlay", remove: () => print("Removed")});

Expected outcome:
good

Actual outcome:
bad

A git bisect, using the emulator, leads to this being the first bad commit: fdbf0bf

Moving the following line inside the for loop above it seems to fix things

_jswrap_drawImageLayerNextY(&l);

but that would revert part of 5a99fbd
I've got absolutely no idea when partial updates happen, but I guess moving that iterator call inside the for loop would probably break something else ¯\_(ツ)_/¯

@ssievert42
Copy link
Contributor Author

I did some more digging:
Since fdbf0bf changed the positions of a GfxDrawImageLayer to be the value in pixels, shifted to the left by 8 bits, we need to shift the desired overlay y position by 8 bits before assigning it to the GfxDrawImageLayer's y1.
I did just that in #2521, and it looks like that did the trick :)

@ssievert42
Copy link
Contributor Author

I completely forgot that overlay positions can be negative 😅
Multiplying the pixel position by 256 (which I did in #2522) is probably a lot more readable anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant