다음을 통해 공유


애니메이션 변수 값 읽기

애플리케이션이 그릴 때마다 애니메이션 효과를 적용할 시각적 특성을 나타내는 애니메이션 변수의 현재 값을 읽어야 합니다.

개요

프레임을 그릴 때 애플리케이션은 IUIAnimationVariable::GetValue 또는 IUIAnimationVariable::GetIntegerValue 메서드를 사용하여 프레임 내의 시각적 개체에 영향을 주는 애니메이션 변수의 값을 요청할 수 있습니다. 애니메이션 변수를 값 범위(SetLowerBoundSetUpperBound)로 클리핑하고 지정된 반올림 체계(SetRoundingMode)를 사용하여 해당 값을 정수로 반올림하도록 요청할 수 있습니다.

모든 프레임에 대한 모든 변수의 값을 읽는 대신 애플리케이션은 IUIAnimationVariable::SetVariableChangeHandler 또는 IUIAnimationVariable::SetVariableIntegerChangeHandler 메서드를 사용하여 알림을 받을 하나 이상의 변수 변경 처리기를 등록할 수 있습니다. 변수 값 변경(IUIAnimationVariableChangeHandler::OnValueChanged) 또는 반올림된 값(IUIAnimationVariableIntegerChangeHandler::OnIntegerValueChanged) ). 변수 변경 처리기에 전달된 변수를 식별하기 위해 애플리케이션은 IUIAnimationVariable::SetTag 메서드를 사용하여 변수에 태그를 적용할 수 있습니다. 이러한 개체(IUnknown*), 애플리케이션에서 해석되는 정수 쌍입니다.

코드 예

다음 예제 코드는 Windows 애니메이션 샘플 그리드 레이아웃의 Thumbnail.cpp에서 가져옵니다. CMainWindow::Render 메서드를 참조하세요. GetValue 메서드를 사용하여 값을 부동 소수점 값으로 읽습니다.

// Get the x-coordinate and y-coordinate animation variable values

DOUBLE x=0;
hr = m_pAnimationVariableX->GetValue(&x);
if (SUCCEEDED(hr))
{
    DOUBLE y=0;
    hr = m_pAnimationVariableY->GetValue(&y);
    if (SUCCEEDED(hr))
    {
        // Draw the object

        ...

    }
}

다음 예제 코드는 Windows 애니메이션 샘플 타이머 기반 애니메이션의 MainWindow.cpp에서 가져온 것입니다. CMainWindow::D rawBackground 메서드를 참조하세요. GetIntegerValue 메서드를 사용하여 값을 정수 값으로 읽습니다.

// Get the RGB animation variable values

INT32 red;
HRESULT hr = m_pAnimationVariableRed->GetIntegerValue(
    &red
    );
if (SUCCEEDED(hr))
{
    INT32 green;
    hr = m_pAnimationVariableGreen->GetIntegerValue(
        &green
        );
    if (SUCCEEDED(hr))
    {
        INT32 blue;
        hr = m_pAnimationVariableBlue->GetIntegerValue(
            &blue
            );
        if (SUCCEEDED(hr))
        {
            // Set the RGB of the background brush to the new animated value

            ...
                
            // Paint the background

            ...

        }
    }

    ...

}

이전 단계

이 단계를 시작하기 전에 애니메이션 관리자 업데이트 및 프레임 그리기 단계를 완료해야 합니다.

다음 단계

이 단계를 완료한 후 다음 단계는 Storyboard 만들기 및 전환 추가입니다.

IUIAnimationVariable::GetIntegerValue

IUIAnimationVariable::GetValue

Windows 애니메이션 개요