Canvas.Graphics problem

[quote=467251:@DickB]Hi Craig, thanks for your comment.
What I want is something like the pulse monitor but only for the time until the trace reaches the end of the screen. That should be possible by plotting each new point and not erasing everything and plot a whole array… [/quote]

You are going to have to redraw the trace (or part of the trace) repeatedly whenever it is appropriate to update the trace. For example, if you are collecting data every minute and want to show data from the last one hour, you will likely want to redraw the trace about 60 times. While this may seem wasteful, draws are usually quite fast.

If you run into performance issues with large arrays or short time intervals, you can also instruct the canvas to only redraw a smaller rectangular portion. (eg: RectControl.Invalidate(X As Integer, Y As Integer, Width As Integer, Height As Integer [,EraseBackground As Boolean])

You might want to be sure you understand the differences between canvas.refresh canvas.invalidate(true) and canvas.invalidate(false) . In cases where you need to plot data at short time intervals, you may want to use canvas.refresh since this triggers an immediate redraw.

The true and false are used to specify the behavior if your canvas has a “background” . By my reading, if you have no background, then invalidate(true) and invalidate(false) would appear to give the same result. The documentation seems to use “backdrop” and “background” interchangeably. Perhaps “background” is an older term?

i made some test with only drawing a dot of data and move the other picture data to the left but i am not happy with it.

my insight is that you need a thread to collect the incoming data precise in real time because the timer event have only 60 fps.
so you need to collect data in a list first.
and a timer just repaint the list as curve.

https://documentation.xojo.com/api/os/system.html#system-microseconds

Dear Markus and Craig, thanks for your efforts. Actually for my app there is no need for scrolling. When one graph is plotted incrementally on the canvas I can stop. It is just one plot on one screen that gets an extra point at timer-events. I think that since this is no high speed app I will stick with plotting a array again and again when a new datapont arrives. The solution with using the old syntax to draw int a picture which is copied on the canvas with each time interrupt is also attractive. I will take now some days to get it cleaned up and close this thread for the moment.

I stumbled over the same problem, that canvas.graphics… would not run anymore.
In they whole conversation I’m missing the reason why Xojo has changed this… This would make me feel better and give an understanding to adapt my program, and Xojo should indicate how to circumvent this ‘old’ coding, not the forum users… (sorry, if they did, but I missed it).
@ Dick: how did you finally change your code, if I may ask?

https://forum.xojo.com/56713-canvas-graphics-gone

[quote=474795:@Peter Kronenberg]I stumbled over the same problem, that canvas.graphics… would not run anymore.
In they whole conversation I’m missing the reason why Xojo has changed this… This would make me feel better and give an understanding to adapt my program, and Xojo should indicate how to circumvent this ‘old’ coding, not the forum users… (sorry, if they did, but I missed it).[/quote]

Developers have been advised not to write to Graphics outside the Paint event handler for many, many years. This goes back to the time when Xojo was REALbasic and I think it predates this forum. The writing was on the wall for a long time.

at least you can paint into a picture within a method and later you can use it at backdrop or in the paint event.
you can store a picture also as property.

[code]Dim p As New Picture(320,240)

p.Graphics.DrawingColor = Color.Red
p.Graphics.DrawOval(160,120,64,64)[/code]

The official word from Xojo is here:

https://blog.xojo.com/2018/12/06/updating-code-that-used-the-graphics-property/

The feature was removed in Xojo 2018r3. (go figure).

1 Like

Thank you all, I fixed it now as well and am up-to-date.