Init
This commit is contained in:
32
DataDisplay/Common/DrawingHelper.cs
Normal file
32
DataDisplay/Common/DrawingHelper.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user