using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Text;

namespace DataDisplay.Common
{
  public class DrawingHelper
  {
    private DrawingHelper()
    {
    }
    public static void DrawIsoTriangle(SKCanvas canvas, SKPoint origin, int length, SKPaint paintStroke, SKPaint paintFill)
    {
      SKPath path = new SKPath();

      float lengthF = (float)length;
      float hLength = lengthF / 2f;
      float height = (float)Math.Sqrt(Math.Pow(lengthF, 2) - Math.Pow(hLength, 2));

      height/=1.15f;               // reduce the height by 15%

      path.MoveTo(origin.X, origin.Y);
      path.LineTo(origin.X - hLength, origin.Y + height);
      path.LineTo(origin.X + hLength, origin.Y + height);
      path.LineTo(origin.X, origin.Y);
      path.Close();
      canvas.DrawPath(path, paintStroke);
      canvas.DrawPath(path, paintFill);
    }
  }
}
