ImmutableVisualBrush.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 Avalonia.Visuals.Media.Imaging;
  4. using Avalonia.VisualTree;
  5. namespace Avalonia.Media.Immutable
  6. {
  7. /// <summary>
  8. /// Paints an area with an <see cref="IVisual"/>.
  9. /// </summary>
  10. internal class ImmutableVisualBrush : ImmutableTileBrush, IVisualBrush
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="ImmutableImageBrush"/> class.
  14. /// </summary>
  15. /// <param name="visual">The visual to draw.</param>
  16. /// <param name="alignmentX">The horizontal alignment of a tile in the destination.</param>
  17. /// <param name="alignmentY">The vertical alignment of a tile in the destination.</param>
  18. /// <param name="destinationRect">The rectangle on the destination in which to paint a tile.</param>
  19. /// <param name="opacity">The opacity of the brush.</param>
  20. /// <param name="sourceRect">The rectangle of the source image that will be displayed.</param>
  21. /// <param name="stretch">
  22. /// How the source rectangle will be stretched to fill the destination rect.
  23. /// </param>
  24. /// <param name="tileMode">The tile mode.</param>
  25. /// <param name="bitmapInterpolationMode">Controls the quality of interpolation.</param>
  26. public ImmutableVisualBrush(
  27. IVisual visual,
  28. AlignmentX alignmentX = AlignmentX.Center,
  29. AlignmentY alignmentY = AlignmentY.Center,
  30. RelativeRect? destinationRect = null,
  31. double opacity = 1,
  32. RelativeRect? sourceRect = null,
  33. Stretch stretch = Stretch.Uniform,
  34. TileMode tileMode = TileMode.None,
  35. BitmapInterpolationMode bitmapInterpolationMode = BitmapInterpolationMode.Default)
  36. : base(
  37. alignmentX,
  38. alignmentY,
  39. destinationRect ?? RelativeRect.Fill,
  40. opacity,
  41. sourceRect ?? RelativeRect.Fill,
  42. stretch,
  43. tileMode,
  44. bitmapInterpolationMode)
  45. {
  46. Visual = visual;
  47. }
  48. /// <summary>
  49. /// Initializes a new instance of the <see cref="ImmutableVisualBrush"/> class.
  50. /// </summary>
  51. /// <param name="source">The brush from which this brush's properties should be copied.</param>
  52. public ImmutableVisualBrush(IVisualBrush source)
  53. : base(source)
  54. {
  55. Visual = source.Visual;
  56. }
  57. /// <inheritdoc/>
  58. public IVisual Visual { get; }
  59. }
  60. }