GeometryClippingTests.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. namespace Avalonia.Skia.RenderTests
  10. {
  11. public class GeometryClippingTests : TestBase
  12. {
  13. public GeometryClippingTests()
  14. :base("GeometryClipping")
  15. {
  16. }
  17. [Fact]
  18. public async Task Geometry_Clip_Clips_Path()
  19. {
  20. var target = new Canvas
  21. {
  22. Background = Brushes.Yellow,
  23. Clip = StreamGeometry.Parse("F1 M 0,0 H 76 V 76 Z"),
  24. Width = 76,
  25. Height = 76,
  26. Children =
  27. {
  28. new Path
  29. {
  30. Width = 32,
  31. Height = 40,
  32. [Canvas.LeftProperty] = 23,
  33. [Canvas.TopProperty] = 18,
  34. Stretch = Stretch.Fill,
  35. Fill = Brushes.Black,
  36. 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")
  37. }
  38. }
  39. };
  40. await RenderToFile(target);
  41. CompareImages();
  42. }
  43. }
  44. }