public static void DrawMeasureLine(Graphics2D graphics2D, Vector2 lineStart, Vector2 lineEnd, RGBA_Bytes color, LineArrows arrows) { graphics2D.Line(lineStart, lineEnd, RGBA_Bytes.Black); Vector2 direction = lineEnd - lineStart; if (direction.LengthSquared > 0 && (arrows.HasFlag(LineArrows.Start) || arrows.HasFlag(LineArrows.End))) { PathStorage arrow = new PathStorage(); arrow.MoveTo(-3, -5); arrow.LineTo(0, 0); arrow.LineTo(3, -5); if (arrows.HasFlag(LineArrows.End)) { double rotation = Math.Atan2(direction.y, direction.x); IVertexSource correctRotation = new VertexSourceApplyTransform(arrow, Affine.NewRotation(rotation - MathHelper.Tau / 4)); IVertexSource inPosition = new VertexSourceApplyTransform(correctRotation, Affine.NewTranslation(lineEnd)); graphics2D.Render(inPosition, RGBA_Bytes.Black); } if (arrows.HasFlag(LineArrows.Start)) { double rotation = Math.Atan2(direction.y, direction.x) + MathHelper.Tau / 2; IVertexSource correctRotation = new VertexSourceApplyTransform(arrow, Affine.NewRotation(rotation - MathHelper.Tau / 4)); IVertexSource inPosition = new VertexSourceApplyTransform(correctRotation, Affine.NewTranslation(lineStart)); graphics2D.Render(inPosition, RGBA_Bytes.Black); } } }
public static void DrawMeasureLine(this Graphics2D graphics2D, Vector2 lineStart, Vector2 lineEnd, LineArrows arrows, ThemeConfig theme) { graphics2D.Line(lineStart, lineEnd, theme.TextColor); Vector2 direction = lineEnd - lineStart; if (direction.LengthSquared > 0 && (arrows.HasFlag(LineArrows.Start) || arrows.HasFlag(LineArrows.End))) { var arrow = new VertexStorage(); arrow.MoveTo(-3, -5); arrow.LineTo(0, 0); arrow.LineTo(3, -5); if (arrows.HasFlag(LineArrows.End)) { double rotation = Math.Atan2(direction.Y, direction.X); IVertexSource correctRotation = new VertexSourceApplyTransform(arrow, Affine.NewRotation(rotation - MathHelper.Tau / 4)); IVertexSource inPosition = new VertexSourceApplyTransform(correctRotation, Affine.NewTranslation(lineEnd)); graphics2D.Render(inPosition, theme.TextColor); } if (arrows.HasFlag(LineArrows.Start)) { double rotation = Math.Atan2(direction.Y, direction.X) + MathHelper.Tau / 2; IVertexSource correctRotation = new VertexSourceApplyTransform(arrow, Affine.NewRotation(rotation - MathHelper.Tau / 4)); IVertexSource inPosition = new VertexSourceApplyTransform(correctRotation, Affine.NewTranslation(lineStart)); graphics2D.Render(inPosition, theme.TextColor); } } }