GeometryClippingTests.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Avalonia.Controls;
  2. using Avalonia.Controls.Shapes;
  3. using Avalonia.Media;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Text;
  7. using Xunit;
  8. using System.Threading.Tasks;
  9. #if AVALONIA_SKIA
  10. namespace Avalonia.Skia.RenderTests
  11. #else
  12. namespace Avalonia.Direct2D1.RenderTests
  13. #endif
  14. {
  15. public class GeometryClippingTests : TestBase
  16. {
  17. public GeometryClippingTests()
  18. :base("GeometryClipping")
  19. {
  20. }
  21. [Fact]
  22. public async Task Geometry_Clip_Clips_Path()
  23. {
  24. var target = new Canvas
  25. {
  26. Background = Brushes.Yellow,
  27. Clip = StreamGeometry.Parse("F1 M 0,0 H 76 V 76 Z"),
  28. Width = 76,
  29. Height = 76,
  30. Children =
  31. {
  32. new Path
  33. {
  34. Width = 32,
  35. Height = 40,
  36. [Canvas.LeftProperty] = 23,
  37. [Canvas.TopProperty] = 18,
  38. Stretch = Stretch.Fill,
  39. Fill = Brushes.Black,
  40. Data = StreamGeometry.Parse("F1 M 27,18L 23,26L 33,30L 24,38L 33,46L 23,50L 27,58L 45,58L 55,38L 45,18L 27,18 Z")
  41. }
  42. }
  43. };
  44. await RenderToFile(target);
  45. CompareImages();
  46. }
  47. }
  48. }