IDCompositionAnimation::AddCubic 메서드(dcompanimation.h)

애니메이션 함수에 입방형 다항 세그먼트를 추가합니다.

구문

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

매개 변수

[in] beginOffset

형식: double

애니메이션 함수의 시작부터 이 세그먼트가 적용되어야 하는 지점까지의 오프셋(초)입니다.

[in] constantCoefficient

형식: float

다항식의 상수 계수입니다.

[in] linearCoefficient

형식: float

다항식의 선형 계수입니다.

[in] quadraticCoefficient

형식: float

다항식의 이차 계수입니다.

[in] cubicCoefficient

형식: float

다항식의 입방 계수입니다.

반환 값

형식: HRESULT

함수가 성공하면 S_OK를 반환합니다. 그러지 않으면 HRESULT 오류 코드를 반환합니다. 오류 코드 목록은 DirectComposition 오류 코드를 참조하세요.

설명

입방 세그먼트는 입방 다항식에 따라 시간을 전환합니다. 지정된 시간 입력(t)의 경우 출력 값은 다음 수식에 의해 지정됩니다.

x(t) = at 화살표 + bt² + ct + d

매개 변수가 NaN, 양수 무한대 또는 음의 무한대인 경우 이 메서드는 실패합니다.

애니메이션 세그먼트를 순서대로 추가해야 하므로 beginOffset 매개 변수가 이전 세그먼트의 beginOffset 매개 변수보다 작거나 같으면 이 메서드가 실패합니다(있는 경우).

이 애니메이션 세그먼트는 애니메이션 함수에서 다음 세그먼트의 시작 시간까지 계속 적용됩니다. 애니메이션 함수에 더 이상 세그먼트가 없는 경우 이 세그먼트는 무기한으로 적용됩니다.

constantCoefficient를 제외한 모든 계수가 0이면 이 세그먼트의 값은 시간이 지남에 따라 일정하게 유지되며 애니메이션으로 인해 세그먼트 기간 동안 다시 계산되지 않습니다.

예제

다음 예제에서는 두 개의 입방 다항 세그먼트가 있는 애니메이션 함수를 만듭니다.

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

요구 사항

   
지원되는 최소 클라이언트 Windows 8 [데스크톱 앱만 해당]
지원되는 최소 서버 Windows Server 2012 [데스크톱 앱만 해당]
대상 플랫폼 Windows
헤더 dcompanimation.h
라이브러리 Dcomp.lib
DLL Dcomp.dll

추가 정보

애니메이션

IDCompositionAnimation