CompositionMaskBrush 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
불투명 마스크가 적용된 CompositionBrush를 사용하여 SpriteVisual을 그립니다. 불투명 마스크의 소스는 CompositionColorBrush, CompositionLinearGradientBrush, CompositionSurfaceBrush, CompositionEffectBrush 또는 CompositionNineGridBrush 형식의 CompositionBrush일 수 있습니다. 불투명 마스크는 CompositionSurfaceBrush로 지정되어야 합니다.
public ref class CompositionMaskBrush sealed : CompositionBrush
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.LiftedContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class CompositionMaskBrush final : CompositionBrush
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65536)]
class CompositionMaskBrush final : CompositionBrush
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.LiftedContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class CompositionMaskBrush : CompositionBrush
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65536)]
public sealed class CompositionMaskBrush : CompositionBrush
Public NotInheritable Class CompositionMaskBrush
Inherits CompositionBrush
- 상속
- 특성
예제
이미지에 star 모양의 마스크를 적용합니다.
private SpriteVisual CreateCircleImage(ICompositionSurface myImageSurface, ICompositionSurface myStarMaskSurface)
{
// Create SurfaceBrush with image surface and specify stretch and alignment
CompositionSurfaceBrush imageBrush = _compositor.CreateSurfaceBrush(myImageSurface);
imageBrush.HorizontalAlignmentRatio = 0.5f;
imageBrush.VerticalAlignmentRatio = 0.5f;
imageBrush.Stretch = CompositionStretch.UniformToFill;
// Create surface brush with opacity mask surface and specify stretch and alignment
CompositionSurfaceBrush starMaskBrush = _compositor.CreateSurfaceBrush(myStarMaskSurface);
starMaskBrush.Stretch = CompositionStretch.Uniform;
// SpriteVisual to be painted with masked content
SpriteVisual imageVisual = _compositor.CreateSpriteVisual();
imageVisual.Size = new Vector2(200, 200);
// Create MaskBrush
CompositionMaskBrush maskBrush = _compositor.CreateMaskBrush();
maskBrush.Source = imageBrush; // Set source to content that is to be masked
maskBrush.Mask = starMaskBrush; // Set mask to content that is the opacity mask
imageVisual.Brush = maskBrush; // Paint SpriteVisual with MaskBrush
return imageVisual;
}
불투명 마스크를 단색 채우기에 적용하여 도형을 만듭니다. 불투명 마스크 CompositionSurfaceBrush 의 변환 속성에 애니메이션 효과를 줍니다.
private void CreateCircleMaskSprite(ICompositionSurface myCircleMaskSurface, ICompositionSurface myImageSurface)
{
// SpriteVisual to be painted by MaskBrush
_circleVisual = _compositor.CreateSpriteVisual();
_circleVisual.Size = MyContainerGrid.RenderSize.ToVector2();
// SurfaceBrush w/ image as MaskBrush.Source
CompositionSurfaceBrush imageBrush = _compositor.CreateSurfaceBrush(myImageSurface);
imageBrush.Stretch = CompositionStretch.UniformToFill;
// SurfaceBrush w/ opacity mask surface as MaskBrush.Mask
CompositionSurfaceBrush circleBrush = _compositor.CreateSurfaceBrush(myCircleMaskSurface);
// Specify stretch and transform properties to scale and position brush for initial state
circleBrush.Stretch = CompositionStretch.Uniform;
circleBrush.CenterPoint = _circleVisual.Size / 2;
circleBrush.Scale = new Vector2(0.5f);
// Create MaskBrush
CompositionMaskBrush maskBrush = _compositor.CreateMaskBrush();
maskBrush.Source = imageBrush;
maskBrush.Mask = circleBrush;
_circleVisual.Brush = maskBrush;
// Set SpriteVisual as child of XAML Grid
ElementCompositionPreview.SetElementChildVisual(MyContainerGrid, _circleVisual);
}
private void BloomAnimation()
{
// Create KeyFrame Animation to target Scale transform on SurfaceBrush
Vector2KeyFrameAnimation scaleAnimation = _compositor.CreateVector2KeyFrameAnimation();
scaleAnimation.InsertKeyFrame(1.0f, new Vector2(2));
scaleAnimation.Duration = TimeSpan.FromMilliseconds(500);
var maskBrush = (CompositionMaskBrush)_circleVisual.Brush;
var surfaceBrush = (CompositionSurfaceBrush) maskBrush.Mask;
// Animate the Scale on the circle opacity mask
surfaceBrush.StartAnimation("Scale", scaleAnimation);
}
둥근 사각형 마스크를 적용하여 크기 조정 시 모서리 반경이 증가하지 않는 단색 둥근 사각형을 만듭니다( CompositionNineGridBrush 를 CompositionMaskBrush 에 대한 입력으로 사용).
private SpriteVisual CreateMaskedRoundedRectVisual(ICompositionSurface myRoundedRectMaskSurface)
{
// ColorBrush to be set as MaskBrush.Source
CompositionColorBrush colorBrush = _compositor.CreateColorBrush(Colors.Blue);
// SurfaceBrush w/ opacity mask surface
CompositionSurfaceBrush roundedRectBrush = _compositor.CreateSurfaceBrush(myRoundedRectMaskSurface);
roundedRectBrush.Stretch = CompositionStretch.Fill; // stretch for center of nine-grid
// NineGridBrush w/ insets on opacity mask surface
CompositionNineGridBrush ninegridBrush = _compositor.CreateNineGridBrush();
ninegridBrush.Source = roundedRectBrush;
ninegridBrush.SetInsets(_cornerRadius); // the radius, in pixels, of the corner as specified on my opacity mask surface
// Create MaskBrush
CompositionMaskBrush maskBrush = _compositor.CreateMaskBrush();
maskBrush.Source = colorBrush;
maskBrush.Mask = ninegridBrush;
// Paint SpriteVisual with MaskBrush
SpriteVisual sprite = _compositor.CreateSpriteVisual();
sprite.Size = new Vector2(300, 200);
sprite.Brush = maskBrush;
return sprite;
}
설명
CompositionMaskBrush는 CompositionEffectBrush에 대한 원본 매개 변수로 설정할 수 없습니다. 마스킹된 콘텐츠에 IGraphicsEffect를 적용하려면 Composite 효과와 함께 CompositionEffectBrush를 대신 사용합니다.
속성
Comment |
CompositionObject와 연결할 문자열입니다. (다음에서 상속됨 CompositionObject) |
Compositor |
이 CompositionObject를 만드는 데 사용되는 Compositor입니다. (다음에서 상속됨 CompositionObject) |
DispatcherQueue |
CompositionObject에 대한 DispatcherQueue를 가져옵니다. (다음에서 상속됨 CompositionObject) |
ImplicitAnimations |
이 개체에 연결된 암시적 애니메이션의 컬렉션입니다. (다음에서 상속됨 CompositionObject) |
Mask |
소스 브러시의 내용을 마스킹할 불투명 마스크가 들어 있는 브러시입니다. CompositionSurfaceBrush 또는 CompositionNineGridBrush 형식일 수 있습니다. |
Properties |
CompositionObject와 연결된 속성의 컬렉션입니다. (다음에서 상속됨 CompositionObject) |
Source |
불투명 마스크로 콘텐츠를 마스킹할 브러시입니다. CompositionSurfaceBrush, CompositionColorBrush 또는 CompositionNineGridBrush 형식일 수 있습니다. |