in ExampleGallery/GeometryOperations.xaml.cs [139:204]
private void Canvas_Draw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args)
{
Matrix3x2 displayTransform = Utils.GetDisplayTransform(sender.Size.ToVector2(), new Vector2(1000, 1000));
args.DrawingSession.Transform = displayTransform;
args.DrawingSession.FillGeometry(combinedGeometry, Colors.Blue);
if (showSourceGeometry)
{
args.DrawingSession.DrawGeometry(leftGeometry, Colors.Red, 5.0f);
args.DrawingSession.Transform = interGeometryTransform * displayTransform;
args.DrawingSession.DrawGeometry(rightGeometry, Colors.Red, 5.0f);
args.DrawingSession.Transform = displayTransform;
}
if (showTessellation)
{
foreach (var triangle in tessellation)
{
args.DrawingSession.DrawLine(triangle.Vertex1, triangle.Vertex2, Colors.Gray);
args.DrawingSession.DrawLine(triangle.Vertex2, triangle.Vertex3, Colors.Gray);
args.DrawingSession.DrawLine(triangle.Vertex3, triangle.Vertex1, Colors.Gray);
}
}
if (CurrentContourTracingAnimation != ContourTracingAnimationOption.None)
{
args.DrawingSession.FillCircle(pointOnContourPath, 2, Colors.White);
const float arrowSize = 10.0f;
Vector2 tangentLeft = new Vector2(
-tangentOnContourPath.Y,
tangentOnContourPath.X);
Vector2 tangentRight = new Vector2(
tangentOnContourPath.Y,
-tangentOnContourPath.X);
Vector2 bisectorLeft = new Vector2(
tangentOnContourPath.X + tangentLeft.X,
tangentOnContourPath.Y + tangentLeft.Y);
Vector2 bisectorRight = new Vector2(
tangentOnContourPath.X + tangentRight.X,
tangentOnContourPath.Y + tangentRight.Y);
Vector2 arrowheadFront = new Vector2(
pointOnContourPath.X + (tangentOnContourPath.X * arrowSize * 2),
pointOnContourPath.Y + (tangentOnContourPath.Y * arrowSize * 2));
Vector2 arrowheadLeft = new Vector2(
arrowheadFront.X - (bisectorLeft.X * arrowSize),
arrowheadFront.Y - (bisectorLeft.Y * arrowSize));
Vector2 arrowheadRight = new Vector2(
arrowheadFront.X - (bisectorRight.X * arrowSize),
arrowheadFront.Y - (bisectorRight.Y * arrowSize));
const float strokeWidth = arrowSize / 4.0f;
args.DrawingSession.DrawLine(pointOnContourPath, arrowheadFront, Colors.White, strokeWidth);
args.DrawingSession.DrawLine(arrowheadFront, arrowheadLeft, Colors.White, strokeWidth);
args.DrawingSession.DrawLine(arrowheadFront, arrowheadRight, Colors.White, strokeWidth);
}
}