canvasChanged and sheetengine.drawing.drawScene

May 9, 2013 at 7:24 PM

I faced with such problem:
I have a sheet, which is changed by click (for example, I change color). My code is looks like:

I suppose, that code is correct, because it just a documentation's example with a bit changed structure, but sheetengine.drawing.drawScene() makes nothing. The scene doesn't changed. But when I add true to sheetengine.drawing.drawScene(true) (full scene redraw) it began to work.

And my question: what I do wrong and how I can fix it? :) Or such behavior is normal and I misplaced it in documentation?
May 9, 2013 at 7:32 PM
Oh, and I just found, that wrapping of sheet with sheetobject makes everything ok and sheetengine.drawing.drawScene() redraw the scene. Maybe it just my fault and I missed it in docs.
May 9, 2013 at 8:46 PM
That's correct. Objects are the way to add dynamics to your scene. A stand-alone sheet will always become part of the static scenery and its region will only be refreshed if an object moves nearby.
May 16, 2013 at 12:09 PM
Is there a way to make this work without having to wrap my sheets in sheetobject?
May 16, 2013 at 12:53 PM
It is easier to wrap any moving sheet into a sheetobject. You gain a lot of functionality with sheetobjects, simple sheets are for static rendering only. The philosophy of this library is to manage larger static areas and smaller moving areas in order to render scenes in a performant way. So ideally you wouldn't have too many moving stuff on your scenes, otherwise HTML5, canvas, or at least this library may not be very useful to you. The objects behind the "smaller moving areas" are called sheetobjects and can refresh their own ROIs.

If you don't want to use sheetobjects and you want to stick to sheets, you would need to redraw the whole scene all the time (using sheetengine.drawing.drawScene(true); and possibliy the sheetengine.calc.calculateAllSheets(); method), which could be very time consuming.
May 16, 2013 at 10:03 PM
What if i'm only trying to "highlight" a sheet? The sheet doesn't move. What is the best way to render this quickly?

Right now i am drawing a transparent rectangle on the sheet to make a highlight.
May 16, 2013 at 10:35 PM
Here are your options:
If you check out Crossyards ( in the yard editor I also highlight sheets on mouse hover, with a different technique (I draw the contours of the sheet) but it also requires to redraw the whole scene. However in that case since the scene is quite small it is not expensive to do a full redraw.
May 16, 2013 at 10:49 PM
3rd is fastest, unfortunately i can't use that method.

2nd is faster than 1st, would you say much much faster?

Thanks for the help! Great engine you've made here!
May 17, 2013 at 2:28 AM
2nd is much faster. But... for some reason i still have to tell it redraw the entire scene.
if i take the true out, it doesn't work. But this is much much faster than calculating the entire scene again.
May 17, 2013 at 8:10 AM
What's your code? You need to call sheet.canvasChanged() after any change to the sheet's canvas (see, in order to tell the engine that the region of the object has changed.
May 17, 2013 at 7:00 PM
I do call it, but it seems to be picky when it decides a sheet is redrawn. I can get it redraw just the modified sheets, but not everytime.
May 18, 2013 at 7:08 PM
Could you send your code with some repro steps? Let me take a look at it maybe I can help fix it.
Jun 28, 2013 at 2:34 AM
Sorry for a very very late reply. I thought I responded to this already...

Issue was I didn't define my object to be as big as it was on screen, so it wasn't updating the sheets that were changing.