Bug: Execution interrupted while drawing #6181
Replies: 1 comment
-
Posted at 2023-08-11 by @gfwilliams Yes, I think likely what's happening is the IDE uploads the code and then doesn't get a response after a second or so, so it issues a Ctrl-C to break out of it. You could do:
to run the command after a delay so the IDE can upload the code fine and see a response, but then the code happens after. BUT: iterating over every pixel is always going to be really slow I'm afraid - it's probably not something you want to be doing if there's any way to avoid it. What I'd suggest is actually making two images - one with what you want to draw and one with the circle, and XORing the actual binary data of the image together.
There are other ways to do it (eg compiled code) but this way a relatively straightforward. It still takes ~0.4sec to do the entire screen, but if you only wanted part of the screen done then it'd be a bit faster. I was considering adding different draw styles (add/xor/or/etc) to the Graphics lib which would really help with this, but I'm afraid that isn't implemented yet. Posted at 2023-08-11 by stweedo I was trying to implement something similar for a stop watch app except mine was a rectangle, not a circle, so I was able to use g.setClipRect. Maybe there could also be a g.setClipCircle? Posted at 2023-08-14 by @gfwilliams That feels like it's quite a rare thing to want to do - I could imagine maybe having a 'mask' image where you set the areas you want to write to though? ...but personally I'd have thought that extending In the case above, you could have an XOR mode, but you could also do AND/OR or even just using an image to set the transparency, which would do what you want too Posted at 2023-08-14 by stweedo Yeah, I was using setClipRect as a mask essentially and layering the draws to create the animation.
But it sounds like extending drawImages like you said could be way more versatile. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2023-08-10 by Frickolas
First, I should mention that I'm pretty new to JS, so forgive me if this is a rookie mistake. I'm trying to make a custom clock for my bangle.js 2, and it involves inverting the colors of portions of the screen. I wrote a function that iterates over the pixels in a given circle and inverts them:
When inverting larger areas, execution gets halted a few hundred milliseconds into the drawing process.
I'm guessing that this has something to do with hogging the CPU for too long, but I'm not really sure. Any advice on how to avoid halting execution and / or make this more efficient would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions