LineNode.cs 971 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using Avalonia.Media;
  5. namespace Avalonia.Rendering.SceneGraph
  6. {
  7. public class LineNode : ISceneNode
  8. {
  9. public LineNode(Matrix transform, Pen pen, Point p1, Point p2)
  10. {
  11. Transform = transform;
  12. Pen = pen;
  13. P1 = p1;
  14. P2 = p2;
  15. }
  16. public Matrix Transform { get; }
  17. public Pen Pen { get; }
  18. public Point P1 { get; }
  19. public Point P2 { get; }
  20. public bool Equals(Matrix transform, Pen pen, Point p1, Point p2)
  21. {
  22. return transform == Transform && pen == Pen && p1 == P1 && p2 == P2;
  23. }
  24. public void Render(IDrawingContextImpl context)
  25. {
  26. context.Transform = Transform;
  27. context.DrawLine(Pen, P1, P2);
  28. }
  29. }
  30. }