CompositionColorBrush Klasse

Definition

Zeichnet ein SpriteVisual mit einer Volltonfarbe.

public ref class CompositionColorBrush 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 CompositionColorBrush 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 CompositionColorBrush : CompositionBrush
Public NotInheritable Class CompositionColorBrush
Inherits CompositionBrush
Vererbung
Object Platform::Object IInspectable CompositionObject CompositionBrush CompositionColorBrush
Attribute

Windows-Anforderungen

Gerätefamilie
Windows 10 (eingeführt in 10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (eingeführt in v2.0)

Beispiele

SpriteVisual visual= compositor.CreateSpriteVisual();
visual.Brush = compositor.CreateColorBrush  (Colors.White);
using Windows.UI.Composition;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Hosting;
using System.Numerics;

…
public sealed partial class MainPage : Page
    {
        Compositor _compositor;
        ContainerVisual _root;
        SpriteVisual _visual;

        public MainPage()
        {
            this.InitializeComponent();
            this.Loaded += MainPage_Loaded;
        }

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            // Get compositor and create a solid color visual
            _root = ElementCompositionPreview.GetContainerVisual(MainGrid) as ContainerVisual;
            _compositor = _root.Compositor;

            // Create a solid color visual
            _visual = _compositor.CreateSpriteVisual();
            _visual.Brush = _compositor.CreateColorBrush( Windows.UI.Colors.Blue );
            _visual.Size = new Vector2(250, 250);

            // Set hard border mode to disable anti-aliasing
            _visual.BorderMode = CompositionBorderMode.Hard;

            // Set backface-visibility to hidden in event of 3D rotation
            _visual.BackfaceVisibility = CompositionBackfaceVisibility.Hidden;

            // Set composite mode to DestinationInvert to do color subtraction blending
            _visual.CompositeMode = CompositionCompositeMode.DestinationInvert;

            _root.Children.InsertAtTop(_visual);

	     // Create a child visual of the solid color visual
            SpriteVisual childVisual = _compositor.CreateSpriteVisual();
            childvisual.Brush = _compositor.CreateColorBrush( Windows.UI.Colors.Orange );
            childVisual.Size = new Vector2(250, 20);
            _visual.Children.InsertAtTop(childVisual);

        }

	 private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Show or hide visual and subtree
            if (_visual.IsVisible)
            {
                _visual.IsVisible = false;
            }
            else
            {
                _visual.IsVisible = true;
            }
        }

    }

Animieren der Color-Eigenschaft mithilfe einer Keyframeanimation.

void ColorAnimation(SpriteVisual targetVisual)
{
  //
  // Create a key frame animation for the targetBrush.Color property
  //
  var animation = _compositor.CreateColorKeyFrameAnimation(); 
  animation.InsertKeyFrame(0.0f, Color.FromArgb(255, 0, 255, 0));
  animation.InsertKeyFrame(1.0f, Colors.Purple);
  targetVisual.Brush.StartAnimation("Color", animation);
}

Animieren der Color-Eigenschaft mithilfe einer ExpressionAnimation.

void ColorExpression(SpriteVisual targetVisual, float screenWidth )
{
  var expression = _compositor.CreateExpressionAnimation("ColorLerp(ColorFrom, ColorTo, target.Offset.X / Width");
  expression.SetReferenceParameter("target", targetVisual);
  expression.SetColorParameter("ColorFrom", Colors.Green);
  expression.SetColorParameter("ColorTo", Colors.Purple);
  expression.SetFloatParameter("Width", screenWidth);
  targetVisual.Brush.StartAnimation("Color", expression);
}

Eigenschaften

Color

Die Farbe, die zum Füllen eines SpriteVisual verwendet wird. Animatable.

Comment

Eine Zeichenfolge, die dem CompositionObject zugeordnet werden soll.

(Geerbt von CompositionObject)
Compositor

Der Compositor , der zum Erstellen dieses CompositionObject verwendet wird.

(Geerbt von CompositionObject)
Dispatcher

Der Dispatcher für das CompositionObject.

(Geerbt von CompositionObject)
DispatcherQueue

Ruft den DispatcherQueue für das CompostionObject ab.

(Geerbt von CompositionObject)
ImplicitAnimations

Die Auflistung impliziter Animationen, die diesem Objekt angefügt sind.

(Geerbt von CompositionObject)
Properties

Die Auflistung von Eigenschaften, die dem CompositionObject zugeordnet sind.

(Geerbt von CompositionObject)

Methoden

Close()

Schließt das CompositionObject und gibt Systemressourcen frei.

(Geerbt von CompositionObject)
ConnectAnimation(String, CompositionAnimation)

Verbindet und Animation.

(Geerbt von CompositionObject)
DisconnectAnimation(String)

Trennt eine Animation.

(Geerbt von CompositionObject)
Dispose()

Führt anwendungsspezifische Aufgaben durch, die mit der Freigabe, der Zurückgabe oder dem Zurücksetzen von nicht verwalteten Ressourcen zusammenhängen.

(Geerbt von CompositionObject)
PopulatePropertyInfo(String, AnimationPropertyInfo)

Definiert eine Eigenschaft, die animiert werden kann.

(Geerbt von CompositionObject)
StartAnimation(String, CompositionAnimation)

Verbindet eine Animation mit der angegebenen Eigenschaft des Objekts und startet die Animation.

(Geerbt von CompositionObject)
StartAnimation(String, CompositionAnimation, AnimationController)

Verbindet eine Animation mit der angegebenen Eigenschaft des Objekts und startet die Animation.

(Geerbt von CompositionObject)
StartAnimationGroup(ICompositionAnimationBase)

Startet eine Animationsgruppe.

Mit der StartAnimationGroup-Methode für CompositionObject können Sie CompositionAnimationGroup starten. Alle Animationen in der Gruppe werden gleichzeitig für das Objekt gestartet.

(Geerbt von CompositionObject)
StopAnimation(String)

Trennt eine Animation von der angegebenen Eigenschaft und beendet die Animation.

(Geerbt von CompositionObject)
StopAnimationGroup(ICompositionAnimationBase)

Beendet eine Animationsgruppe.

(Geerbt von CompositionObject)
TryGetAnimationController(String)

Gibt einen AnimationController für die Animation zurück, die für die angegebene Eigenschaft ausgeführt wird.

(Geerbt von CompositionObject)

Gilt für:

Weitere Informationen