I am assuming you are talking about "electrocardiography"?
In this case you probably want to draw a path, which you will construct using the data points (if any) or just random ups and downs. Then you can paint and request a repaint to keep a continuous update:
public var DoPaint(object sender, SKPaintSurfaceEventArgs)
{
// draw ...
// request repaint
canvasView.InvalidateSurface();
// or, if you don't have access to the view, just use sender
((SKCanvasView)sender).InvalidateSurface();
}
This will make the paint event similar to a game loop, which you can use to move the drawing by either using new points of the path, or translating the drawing matrix:
canvas.Translate(-10, 0); // move the drawing 10 pixels to the left
The Translate was more of an example. What you will need to do is use it in a draw loop:
int xOffset = 0;
public var DoPaint(object sender, SKPaintSurfaceEventArgs e)
{
// move the canvas a bit
e.Surface.Canvas.Translate(xOffset, 0);
// tile the path / draw ...
// prepare for next frame
xOffset -= 10;
if (xOffset < -canvasView.Width)
xOffset = 0;
// request repaint
canvasView.InvalidateSurface();
}
Rather than just doing -= 10, you probably will want to calculate the delta time so that the animation is smooth and consistent.
It might be that you are doing too much on the UI thread... what is happening in the paint cycle? If at all possible, your project, or a simplified example would be very helpful.
Posts
Hi Christophe,
I am assuming you are talking about "electrocardiography"?
In this case you probably want to draw a path, which you will construct using the data points (if any) or just random ups and downs. Then you can paint and request a repaint to keep a continuous update:
This will make the paint event similar to a game loop, which you can use to move the drawing by either using new points of the path, or translating the drawing matrix:
Hello,
I would like to use the Translate instruction, but its not working :
e.Surface.Canvas.Translate(-10, 0);
After the drawPath.
Could you help?
Thx
The
Translate
was more of an example. What you will need to do is use it in a draw loop:Rather than just doing
-= 10
, you probably will want to calculate the delta time so that the animation is smooth and consistent.Its working but the advance si sometime jerky. Could you help ?
Thx
Do you have something I could have a look at?
It might be that you are doing too much on the UI thread... what is happening in the paint cycle? If at all possible, your project, or a simplified example would be very helpful.
Hello,
In the Xaml
In the Cs:
To fill the Array every 200 ms. An Redraw.
Then the draw function :
Thx,
I think the issue was that your time was to high and the distance each tick too far. As a result, it was "jumpy". I tried this and it looked smooth:
Also, if it is possible on your target devices, try using
SKGLView
for even better performance.Hello;
I use Android; SKGLView is for IOS ?
Thx
Hello
I use
But I have the Error :
Could you help ?
Thx
@cjacquel You can use both
SKCanvasView
andSKGLView
on iOS, Android and UWP.Your
myPaint
method must have the signature (I think you are missing the first arg,sender
):Hi ,
How to increase Height of ECG Signal in this sloution.
public partial class MainPage : ContentPage
{
private readonly SKPath path;
private readonly SKPaint paint;
}