Método IDCompositionAnimation::AddCubic (dcompanimation.h)

Agrega un segmento polinómico cúbico a la función de animación.

Sintaxis

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

Parámetros

[in] beginOffset

Tipo: double

Desplazamiento, en segundos, desde el principio de la función de animación hasta el punto en que este segmento debe surtir efecto.

[in] constantCoefficient

Tipo: float

Coeficiente constante del polinomio.

[in] linearCoefficient

Tipo: float

Coeficiente lineal del polinomio.

[in] quadraticCoefficient

Tipo: float

Coeficiente cuadrático del polinomio.

[in] cubicCoefficient

Tipo: float

Coeficiente cúbico del polinomio.

Valor devuelto

Tipo: HRESULT

Si la función se ejecuta correctamente, devuelve S_OK. De lo contrario, devuelve un código de error de HRESULT. Consulte Códigos de error de DirectComposition para obtener una lista de códigos de error.

Comentarios

Un segmento cúbico pasa el tiempo a lo largo de un polinomio cúbico. Para una entrada de tiempo determinada (t), la ecuación siguiente proporciona el valor de salida.

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

Este método produce un error si alguno de los parámetros es NaN, infinito positivo o infinito negativo.

Dado que los segmentos de animación se deben agregar en orden creciente, este método produce un error si el parámetro beginOffset es menor o igual que el parámetro beginOffset del segmento anterior, si existe.

Este segmento de animación permanece en vigor hasta la hora de inicio del siguiente segmento en la función de animación. Si la función de animación no contiene más segmentos, este segmento permanece en vigor indefinidamente.

Si todos los coeficientes excepto constantCoefficient son cero, el valor de este segmento permanece constante a lo largo del tiempo y la animación no provoca una recomposición durante la duración del segmento.

Ejemplos

En el ejemplo siguiente se crea una función de animación con dos segmentos polinómicos cúbicos.

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

Requisitos

   
Cliente mínimo compatible Windows 8 [solo aplicaciones de escritorio]
Servidor mínimo compatible Windows Server 2012 [solo aplicaciones de escritorio]
Plataforma de destino Windows
Encabezado dcompanimation.h
Library Dcomp.lib
Archivo DLL Dcomp.dll

Consulte también

Animación

IDCompositionAnimation