IDCompositionAnimation::AddCubic-Methode (dcompanimation.h)
Fügt der Animationsfunktion ein kubisches Polynomsegment hinzu.
Syntax
HRESULT AddCubic(
[in] double beginOffset,
[in] float constantCoefficient,
[in] float linearCoefficient,
[in] float quadraticCoefficient,
[in] float cubicCoefficient
);
Parameter
[in] beginOffset
Typ: double
Der Offset in Sekunden vom Anfang der Animationsfunktion bis zu dem Punkt, an dem dieses Segment wirksam werden soll.
[in] constantCoefficient
Typ: float
Der konstante Koeffizient des Polynoms.
[in] linearCoefficient
Typ: float
Der lineare Koeffizient des Polynoms.
[in] quadraticCoefficient
Typ: float
Der quadratische Koeffizient des Polynoms.
[in] cubicCoefficient
Typ: float
Der kubische Koeffizient des Polynoms.
Rückgabewert
Typ: HRESULT
Wenn die Funktion erfolgreich ist, gibt sie S_OK zurück. Andernfalls wird ein Fehlercode HRESULT zurückgegeben. Eine Liste der Fehlercodes finden Sie unter DirectComposition-Fehlercodes .
Hinweise
Ein kubisches Segment wechselt die Zeit entlang eines kubischen Polynoms. Für eine bestimmte Zeiteingabe (t) wird der Ausgabewert durch die folgende Gleichung angegeben.
x(t) = at³ + bt² + ct + d
Diese Methode schlägt fehl, wenn einer der Parameter NaN, positive Unendlichkeit oder negative Unendlichkeit ist.
Da Animationssegmente in zunehmender Reihenfolge hinzugefügt werden müssen, schlägt diese Methode fehl, wenn der beginOffset-Parameter kleiner oder gleich dem beginOffset-Parameter des vorherigen Segments ist, falls vorhanden.
Dieses Animationssegment bleibt bis zum Beginn des nächsten Segments in der Animationsfunktion wirksam. Wenn die Animationsfunktion keine weiteren Segmente enthält, bleibt dieses Segment auf unbestimmte Zeit wirksam.
Wenn alle Koeffizienten außer constantCoefficient null sind, bleibt der Wert dieses Segments im Laufe der Zeit konstant, und die Animation verursacht keine Neukomposition für die Dauer des Segments.
Beispiele
Im folgenden Beispiel wird eine Animationsfunktion mit zwei kubischen Polynomsegmenten erstellt.
HRESULT DoAnimatedRotation(IDCompositionDevice *pDevice,
IDCompositionRotateTransform *pRotateTransform,
IDCompositionVisual *pVisual,
float animationTime)
{
HRESULT hr = S_OK;
IDCompositionAnimation *pAnimation = nullptr;
// Create an animation object.
hr = pDevice->CreateAnimation(&pAnimation);
if (SUCCEEDED(hr))
{
// Create the animation function by adding cubic polynomial segments.
// For a given time input (t), the output value is
// a*t^3 + b* t^2 + c*t + d.
//
// The following segment will rotate the visual clockwise.
pAnimation->AddCubic(
0.0, // Begin offset
0.0, // Constant coefficient - d
(360.0f * 1.0f) / animationTime, // Linear coefficient - c
0.0, // Quadratic coefficient - b
0.0); // Cubic coefficient - a
// The following segment will rotate the visual counterclockwise.
pAnimation->AddCubic(
animationTime,
0.0,
-(360.0f * 1.0f) / animationTime,
0.0,
0.0);
// Set the end of the animation.
pAnimation->End(
2 * animationTime, // End offset
0.0); // End value
// Apply the animation to the Angle property of the
// rotate transform.
hr = pRotateTransform->SetAngle(pAnimation);
}
if (SUCCEEDED(hr))
{
// Apply the rotate transform object to a visual.
hr = pVisual->SetTransform(pRotateTransform);
}
if (SUCCEEDED(hr))
{
// Commit the changes to the composition.
hr = pDevice->Commit();
}
SafeRelease(&pAnimation);
return hr;
}
Anforderungen
Unterstützte Mindestversion (Client) | Windows 8 [nur Desktop-Apps] |
Unterstützte Mindestversion (Server) | Windows Server 2012 [nur Desktop-Apps] |
Zielplattform | Windows |
Kopfzeile | dcompanimation.h |
Bibliothek | Dcomp.lib |
DLL | Dcomp.dll |
Weitere Informationen
Feedback
https://aka.ms/ContentUserFeedback.
Bald verfügbar: Im Laufe des Jahres 2024 werden wir GitHub-Issues stufenweise als Feedbackmechanismus für Inhalte abbauen und durch ein neues Feedbacksystem ersetzen. Weitere Informationen finden Sie unterFeedback senden und anzeigen für