CompositionSurfaceBrush クラス

定義

ICompositionSurface のピクセルを使用して SpriteVisual を描画します。

public ref class CompositionSurfaceBrush sealed : CompositionBrush
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 131072)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class CompositionSurfaceBrush final : CompositionBrush
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 131072)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class CompositionSurfaceBrush : CompositionBrush
Public NotInheritable Class CompositionSurfaceBrush
Inherits CompositionBrush
継承
Object Platform::Object IInspectable CompositionObject CompositionBrush CompositionSurfaceBrush
属性

Windows の要件

デバイス ファミリ
Windows 10 (10.0.10586.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v2.0 で導入)

SpriteVisual に画像アセットを描画する

private SpriteVisual CreateImageVisual(ICompositionSurface imageSurface)
{
  SpriteVisual imageVisual = _compositor.CreateSpriteVisual();
  imageVisual.Size = new Vector2(300, 200);

  CompositionSurfaceBrush imageBrush = _compositor.CreateSurfaceBrush();
  imageBrush.Surface = imageSurface;

  // specify CompositionStretch on SurfaceBrush and horizontal/vertical alignment
  imageBrush.Stretch = CompositionStretch.UniformToFill;
  imageBrush.HorizontalAlignmentRatio = 0.5f;
  imageBrush.VerticalAlignmentRatio = 0.5f;

  imageVisual.Brush = imageBrush;
  return imageVisual;
}

CompositionSurfaceBrush にカスタム スケール変換アニメーションを適用する

private void AnimateBrushScale(SpriteVisual imageVisual)
{
  CompositionSurfaceBrush imageBrush = (CompositionSurfaceBrush)imageVisual.Brush;

  // set brush CenterPoint at the center of the content painted onto imageVisual 
  imageBrush.CenterPoint = imageVisual.Size / 2;

  // set up scale keyframe animation
  CompositionScopedBatch batch = _compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
  Vector2KeyFrameAnimation scaleAnimation = _compositor.CreateVector2KeyFrameAnimation();
  scaleAnimation.InsertKeyFrame(1.0f, new Vector2(1.5f));
  scaleAnimation.Duration = TimeSpan.FromMilliseconds(500);

  // start animation on CompositionSurfaceBrush.Scale
  imageBrush.StartAnimation("Scale", scaleAnimation);

  // end animation batch and fire completion event
  batch.End();
  batch.Completed += ScaleAnimationBatch_Completed;
} 

注釈

Stretch プロパティを HorizontalAlignmentRatio プロパティと VerticalAlignmentRatio プロパティと組み合わせて使用して、SpriteVisual に描画するときに CompositionSurfaceBrush のコンテンツのスケールと配置を指定します。

CompositionSurfaceBrush には、カスタム変換を有効にする次のプロパティもあります。

  • AnchorPoint
  • CenterPoint
  • Offset
  • RotationAngle
  • RotationAngleInDegrees
  • スケール
  • TransformMatrix

CompositionSurfaceBrush に対する変換操作の順序は次のとおりです。

  1. CompositionSurfaceBrush の内容は、 SpriteVisual に引き伸ばされて配置されます ( 「Stretch」、「 HorizontalAlignmentRatio」、「 VerticalAlignmentRatio 」の各プロパティを参照)。

  2. CompositionSurfaceBrush に設定されているその他の変換プロパティが適用されます。

    そのため、CompositionSurfaceBrush に適用されるカスタム変換は、ブラシが描画される SpriteVisual の座標空間で評価されます。 たとえば、Offset を Vector2(100, 0) に設定すると、ブラシのストレッチおよび整列されたコンテンツは、ペイントされる SpriteVisual の左端を基準にして 100 単位右にオフセットされます。

バージョン履歴

Windows のバージョン SDK バージョン 追加された値
1607 14393 AnchorPoint
1607 14393 CenterPoint
1607 14393 Offset
1607 14393 RotationAngle
1607 14393 RotationAngleInDegrees
1607 14393 スケール
1607 14393 TransformMatrix
1903 18362 SnapToPixels

プロパティ

AnchorPoint

ブラシのオフセットに配置するブラシ上のポイント。 値は SpriteVisual のサイズに対して正規化されます。

BitmapInterpolationMode

SpriteVisual 上のピクセルへの一対一のマッピングを形成しない場合に、ICompositionSurface からピクセルを補間するために使用されるアルゴリズムを指定します (ストレッチ、スケール、回転、その他の変換で発生する可能性があります)。

CenterPoint

ブラシの回転と拡大縮小を行うポイント。

Comment

CompositionObject に関連付ける文字列。

(継承元 CompositionObject)
Compositor

この CompositionObject の作成に使用するコンポジター

(継承元 CompositionObject)
Dispatcher

CompositionObject のディスパッチャー。

(継承元 CompositionObject)
DispatcherQueue

CompostionObject の DispatcherQueue を取得します。

(継承元 CompositionObject)
HorizontalAlignmentRatio

SpriteVisual の縦軸に対するコンテンツの縦軸の位置を制御します。 この値は 0.0f から 1.0f にクランプされ、0.0f は左の垂直エッジを表し、1.0f は SpriteVisual の右端を表します。

ImplicitAnimations

このオブジェクトにアタッチされている暗黙的なアニメーションのコレクション。

(継承元 CompositionObject)
Offset

SpriteVisual に対するブラシの相対オフセット。

Properties

CompositionObject に関連付けられているプロパティのコレクション。

(継承元 CompositionObject)
RotationAngle

ブラシの回転角度 (ラジアン単位)。

RotationAngleInDegrees

ブラシの回転角度 (度単位)。

Scale

ブラシに適用するスケール。

SnapToPixels

サーフェス ブラシがピクセルに合わせるかどうかを示す値を取得または設定します。

Stretch

塗りつぶされている SpriteVisual のサイズに関して、ICompositionSurface のコンテンツに適用されるスケーリングを制御します。

Surface

CompositionSurfaceBrush に関連付けられている ICompositionSurface

TransformMatrix

ブラシに適用する変換マトリックス。

VerticalAlignmentRatio

SpriteVisual の横軸に対するコンテンツの横軸の位置を制御します。 この値は 0.0f から 1.0f にクランプされ、0.0f は上の水平エッジを表し、1.0f は SpriteVisual の下端を表します。 既定値は 0.5f です。

メソッド

Close()

CompositionObject を閉じ、システム リソースを解放します。

(継承元 CompositionObject)
ConnectAnimation(String, CompositionAnimation)

接続とアニメーション。

(継承元 CompositionObject)
DisconnectAnimation(String)

アニメーションを切断します。

(継承元 CompositionObject)
Dispose()

アンマネージ リソースの解放またはリセットに関連付けられているアプリケーション定義のタスクを実行します。

(継承元 CompositionObject)
PopulatePropertyInfo(String, AnimationPropertyInfo)

アニメーション化できるプロパティを定義します。

(継承元 CompositionObject)
StartAnimation(String, CompositionAnimation)

アニメーションをオブジェクトの指定したプロパティに接続し、アニメーションを開始します。

(継承元 CompositionObject)
StartAnimation(String, CompositionAnimation, AnimationController)

アニメーションをオブジェクトの指定したプロパティに接続し、アニメーションを開始します。

(継承元 CompositionObject)
StartAnimationGroup(ICompositionAnimationBase)

アニメーション グループを開始します。

CompositionObject の StartAnimationGroup メソッドを使用すると、CompositionAnimationGroup を開始できます。 グループ内のすべてのアニメーションは、オブジェクトで同時に開始されます。

(継承元 CompositionObject)
StopAnimation(String)

指定したプロパティからアニメーションを切断し、アニメーションを停止します。

(継承元 CompositionObject)
StopAnimationGroup(ICompositionAnimationBase)

アニメーション グループを停止します。

(継承元 CompositionObject)
TryGetAnimationController(String)

指定したプロパティで実行されているアニメーションの AnimationController を返します。

(継承元 CompositionObject)

適用対象

こちらもご覧ください