DrawLine() public méthode

public DrawLine ( float x0, float y0, float x1, float y1, SKPaint paint ) : void
x0 float
y0 float
x1 float
y1 float
paint SKPaint
Résultat void
 public void DrawLine(float x1, float y1, float x2, float y2, PaintBrush paint)
 => _canvas.DrawLine(x1, y1, x2, y2, GetSKPaint(paint));
        protected override void Draw(SKCanvas canvas, int width, int height)
        {
            float time = _frame / (LengthSec * Fps);

            using (var paint = new SKPaint())
            {
                paint.Color = Foreground.ToSkia();
                paint.StrokeWidth = (float)StrokeWidth;
                paint.IsAntialias = true;
                paint.IsStroke = true;

                for (int a = 0; a < 3; ++a)
                {
                    var matrix = SKMatrix.MakeRotation(2 * (float)Math.PI * time / 6 + 2 * (float)Math.PI * a / 3);
                    matrix.TransX = width / 2f;
                    matrix.TransY = height / 2f;

                    canvas.SetMatrix(matrix);

                    const int n = 12;
                    const int sp = 39;

                    for (int i = -n; i <= n; ++i)
                    {
                        float y = (float)(i * sp * Math.Pow(2, time));
                        float tt = (float)Math.Min(1, Math.Max(0, 1.09 * time - 0.00275 * Math.Abs(y) + 0.075));

                        float x;

                        if (i % 2 == 0)
                            x = width;
                        else
                            x = width * tt;

                        if (x > 0)
                            canvas.DrawLine(-x, y, x, y, paint);
                    }
                }
            }

            ++_frame;
            if (_frame > LengthSec * Fps)
                _frame = 0;
        }
Exemple #3
0
		public static void PathEffects (SKCanvas canvas, int width, int height)
		{
			canvas.Clear (SKColors.White);

			var step = height / 4;

			using (var paint = new SKPaint ())
			using (var effect = SKPathEffect.CreateDash (new [] { 15f, 5f }, 0)) {
				paint.IsStroke = true;
				paint.StrokeWidth = 4;
				paint.PathEffect = effect;
				canvas.DrawLine (10, step, width - 10 - 10, step, paint);
			}

			using (var paint = new SKPaint ())
			using (var effect = SKPathEffect.CreateDiscrete (10, 10)) {
				paint.IsStroke = true;
				paint.StrokeWidth = 4;
				paint.PathEffect = effect;
				canvas.DrawLine (10, step * 2, width - 10 - 10, step * 2, paint);
			}

			using (var paint = new SKPaint ())
			using (var dashEffect = SKPathEffect.CreateDash (new [] { 15f, 5f }, 0))
			using (var discreteEffect = SKPathEffect.CreateDiscrete (10, 10))
			using (var effect = SKPathEffect.CreateCompose (dashEffect, discreteEffect)) {
				paint.IsStroke = true;
				paint.StrokeWidth = 4;
				paint.PathEffect = effect;
				canvas.DrawLine (10, step * 3, width - 10 - 10, step * 3, paint);
			}

		}
Exemple #4
0
 private void DrawLineInternal(SKCanvas canvas, SKPaint pen, bool isStroked, ref SKPoint p0, ref SKPoint p1)
 {
     if (isStroked)
     {
         canvas.DrawLine(p0.X, p0.Y, p1.X, p1.Y, pen);
     }
 }
Exemple #5
0
 public void DrawLine(float x1, float y1, float x2, float y2, PaintBrush grid)
 => _canvas.DrawLine(x1, y1, x2, y2, grid.ToSkia());