From 36fec83f37c1fe749d877f312f5f9b4f214d4723 Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 2 Jul 2025 06:59:53 -0400 Subject: [PATCH] Added DrawTriangle --- .../CNNProcessing/ImageHelper.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/MarketData/MarketDataLib/CNNProcessing/ImageHelper.cs b/MarketData/MarketDataLib/CNNProcessing/ImageHelper.cs index 0bedaf1..03c7e97 100644 --- a/MarketData/MarketDataLib/CNNProcessing/ImageHelper.cs +++ b/MarketData/MarketDataLib/CNNProcessing/ImageHelper.cs @@ -611,5 +611,29 @@ namespace MarketData.CNNProcessing canvas.DrawCircle(txPointCenter, radius, paint); return true; } + + /// + /// Draw a triangle centered inside the bounded area defined by imageWidth, imageHeight + /// + /// The width of the bounded area + /// The height of the bounded area + /// The paint stroke to to use to outline the triangle + /// The paint stroke to use to fill the triangle + public void DrawTriangle(int imageWidth, int imageHeight, SKPaint paintStroke, SKPaint paintFill) + { + using SKPath path = new SKPath(); + float hLength = (float)imageWidth / 2f; + CreateImage(imageWidth,imageHeight); + Transparent(SKColors.White); + SKPoint txOrigin = pointMapping.MapPoint(new SKPoint(imageWidth/2.0f,imageHeight)); + using SKCanvas canvas = new SKCanvas(bitmap); + path.MoveTo(txOrigin.X, txOrigin.Y); + path.LineTo(txOrigin.X - hLength, (txOrigin.Y + imageHeight)-1f); + path.LineTo((txOrigin.X + hLength)-1f, (txOrigin.Y + imageHeight)-1f); + path.LineTo(txOrigin.X, txOrigin.Y); + path.Close(); + canvas.DrawPath(path, paintStroke); + canvas.DrawPath(path, paintFill); + } } } \ No newline at end of file