Added DrawTriangle
This commit is contained in:
@@ -611,5 +611,29 @@ namespace MarketData.CNNProcessing
|
||||
canvas.DrawCircle(txPointCenter, radius, paint);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw a triangle centered inside the bounded area defined by imageWidth, imageHeight
|
||||
/// </summary>
|
||||
/// <param name="imageWidth">The width of the bounded area</param>
|
||||
/// <param name="imageHeight">The height of the bounded area</param>
|
||||
/// <param name="paintStroke">The paint stroke to to use to outline the triangle</param>
|
||||
/// <param name="paintFill">The paint stroke to use to fill the triangle</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user