IdCompositionAnimation::AddCubic, méthode (dcompanimation.h)

Ajoute un segment polynôme cubique à la fonction d’animation.

Syntaxe

HRESULT AddCubic(
  [in] double beginOffset,
  [in] float  constantCoefficient,
  [in] float  linearCoefficient,
  [in] float  quadraticCoefficient,
  [in] float  cubicCoefficient
);

Paramètres

[in] beginOffset

Type : double

Décalage, en secondes, entre le début de la fonction d’animation et le moment où ce segment doit prendre effet.

[in] constantCoefficient

Type : float

Coefficient constant du polynôme.

[in] linearCoefficient

Type : float

Coefficient linéaire du polynôme.

[in] quadraticCoefficient

Type : float

Coefficient quadratique du polynôme.

[in] cubicCoefficient

Type : float

Coefficient cubique du polynôme.

Valeur retournée

Type : HRESULT

Si la fonction réussit, elle retourne S_OK. Sinon, elle retourne un code d’erreur HRESULT. Pour obtenir la liste des codes d’erreur, consultez Codes d’erreur DirectComposition .

Notes

Un segment cubique fait passer le temps le long d’un polynôme cubique. Pour une entrée de temps donnée (t), la valeur de sortie est donnée par l’équation suivante.

x(t) = at³ + bt² + ct + d

Cette méthode échoue si l’un des paramètres est NaN, l’infini positif ou l’infini négatif.

Étant donné que les segments d’animation doivent être ajoutés dans l’ordre croissant, cette méthode échoue si le paramètre beginOffset est inférieur ou égal au paramètre beginOffset du segment précédent, le cas échéant.

Ce segment d’animation reste en vigueur jusqu’à l’heure de début du segment suivant dans la fonction d’animation. Si la fonction d’animation ne contient plus de segments, ce segment reste en vigueur indéfiniment.

Si tous les coefficients à l’exception de constantCoefficient sont nuls, la valeur de ce segment reste constante dans le temps et l’animation n’entraîne pas de recomposition pendant la durée du segment.

Exemples

L’exemple suivant crée une fonction d’animation avec deux segments polynomials cubiques.

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;
}

Spécifications

   
Client minimal pris en charge Windows 8 [applications de bureau uniquement]
Serveur minimal pris en charge Windows Server 2012 [applications de bureau uniquement]
Plateforme cible Windows
En-tête dcompanimation.h
Bibliothèque Dcomp.lib
DLL Dcomp.dll

Voir aussi

Animation

IDCompositionAnimation