-
Notifications
You must be signed in to change notification settings - Fork 43
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
[Question] How to render changeable picture efficiently enough? #283
Comments
@Lev135 Hi! In color picker widget there is a pattern with alternating colors to indicate transparency which is implemented using monomer/src/Monomer/Widgets/Singles/ColorPicker.hs Lines 265 to 276 in 67f747a
Perhaps you can use imageMem to render your square grid.
|
Hi @Lev135! The main problem is you're drawing quite a few items using a helper function that is not particularly efficient. This function is used to render widget borders in several scenarios, and because of that it's too general; I added a note for myself to review it for the most basic case. Based on what I see from the code, is the objective only drawing a grid, or are you planning on drawing squares in the viewport? If you are only going to draw the borders, the simplest/most efficient solution is just drawing ten lines horizontally and ten lines vertically. If you need to draw individual blocks and want them to have their own borders (be it because there are spaces between blocks or the border colors are different), you could try using Renderer's beginPath renderer
setFillColor renderer rectColor
renderRect renderer rectBounds
fill renderer Alternatively, if you only want to draw borders, you can call: setStrokeColor renderer color
setStrokeWidth renderer width |
In my case I have colored cells, so solution with drawing lines doesn't work. Replacing |
I want to show square grid with about 100x100 colored cells. The state of the grid (i. e. the colors of the cells) shouldn't change frequently. However, the simplest solution, which I've tried: to create a widget and draw the grid in
render
function works very poorly, since rerendering is called too often. Is there any way to make it better?The text was updated successfully, but these errors were encountered: