Files
Navigator/DataDisplay/Common/DrawingHelper.cs
2024-02-23 06:53:16 -05:00

33 lines
887 B
C#

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);
}
}
}