Exemplo n.º 1
0
TEST(fade_effect, set_color) {
    fade = FadeEffect(purple, purple, 200);
    EXPECT_EQ_COLORS(fade.get_color(), purple);

    wait_for(fade, 10);
    EXPECT_EQ_COLORS(fade.get_color(), purple);
}
Exemplo n.º 2
0
TEST(fade_effect, tick_100ms) {
    fade        = FadeEffect(RGB(0x2030FF), RGB(0x1000E0), 200);
    RGB halfWay = RGB(0x1818EF);
    EXPECT_FLOAT_EQ(0.5, fade.progressAt(fade.get_startTime() + fade.get_duration() / 2));
//    wait_for(fade, 103);
//    EXPECT_EQ_COLORS(fade.get_color(), halfWay);
}
Exemplo n.º 3
0
bool Label::updateState(const glm::mat4& _mvp, const glm::vec2& _screenSize, float _dt, float _zoomFract) {
    if (m_currentState == State::dead) {
        return false;
    }

    bool occludedLastFrame = m_occludedLastFrame;
    m_occludedLastFrame = false;

    bool ruleSatisfied = updateScreenTransform(_mvp, _screenSize);

    // one of the label rules has not been satisfied
    if (!ruleSatisfied) {

        // go to dead state, this breaks determinism, but reduce potential label set since a lot
        // of discarded labels are discared for line exceed (lots of tiny small lines on a curve
        // for example), which won't have their rule satisfied
        enterState(State::dead, 0.0);
        return false;
    }

    // update the view-space bouding box
    updateBBoxes(_zoomFract);

    // checks whether the label is out of the viewport
    if (offViewport(_screenSize)) {
        enterState(State::out_of_screen, 0.0);
    }

    bool animate = false;

    switch (m_currentState) {
        case State::visible:
            if (occludedLastFrame) {
                m_fade = FadeEffect(false, m_options.hideTransition.ease, m_options.hideTransition.time);
                enterState(State::fading_out, 1.0);
            }
            break;
        case State::fading_in:
            if (occludedLastFrame) {
                enterState(State::sleep, 0.0);
                break;
            }
            setAlpha(m_fade.update(_dt));
            animate = true;
            if (m_fade.isFinished()) {
                enterState(State::visible, 1.0);
            }
            break;
        case State::fading_out:
            setAlpha(m_fade.update(_dt));
            animate = true;
            if (m_fade.isFinished()) {
                enterState(State::sleep, 0.0);
            }
            break;
        case State::out_of_screen:
            if (!offViewport(_screenSize)) {
                enterState(State::wait_occ, 0.0);
            }
            break;
        case State::wait_occ:
            if (m_occlusionSolved) {
                if (occludedLastFrame) {
                    enterState(State::dead, 0.0); // dead
                }  else {
                    m_fade = FadeEffect(true, m_options.showTransition.ease, m_options.showTransition.time);
                    enterState(State::fading_in, 0.0);
                }
            }
            break;
        case State::sleep:
            if (!occludedLastFrame) {
                m_fade = FadeEffect(true, m_options.showTransition.ease, m_options.showTransition.time);
                enterState(State::fading_in, 0.0);
            }
            break;
        case State::dead:
            break;
    }

    return animate;
}
Exemplo n.º 4
0
TEST(fade_effect, fade_same_colors) {
    fade = FadeEffect(purple, purple, 100);
    EXPECT_EQ_COLORS(fade.get_color(), purple);
    wait_for(fade, 90);
    EXPECT_EQ_COLORS(fade.get_color(), purple);
}
Exemplo n.º 5
0
bool Label::evalState(const glm::vec2& _screenSize, float _dt) {

    bool animate = false;

    switch (m_state) {
        case State::visible:
            if (m_occluded) {
                m_fade = FadeEffect(false, m_options.hideTransition.ease,
                                    m_options.hideTransition.time);
                enterState(State::fading_out, 1.0);
                animate = true;
            }
            break;
        case State::fading_in:
            if (m_occluded) {
                enterState(State::sleep, 0.0);
                // enterState(State::fading_out, m_transform.state.alpha);
                // animate = true;
                break;
            }
            setAlpha(m_fade.update(_dt));
            animate = true;
            if (m_fade.isFinished()) {
                enterState(State::visible, 1.0);
            }
            break;
        case State::fading_out:
            setAlpha(m_fade.update(_dt));
            animate = true;
            if (m_fade.isFinished()) {
                enterState(State::sleep, 0.0);
            }
            break;
        case State::out_of_screen:
            if (!offViewport(_screenSize)) {
                enterState(State::wait_occ, 0.0);
            }
            break;
        case State::wait_occ:
            if (m_occluded) {
                enterState(State::dead, 0.0);

            } else {
                m_fade = FadeEffect(true, m_options.showTransition.ease,
                                    m_options.showTransition.time);
                enterState(State::fading_in, 0.0);
                animate = true;
            }
            break;
        case State::skip_transition:
            if (m_occluded) {
                enterState(State::dead, 0.0);

            } else {
                enterState(State::visible, 1.0);
            }
            break;
        case State::sleep:
            if (!m_occluded) {
                m_fade = FadeEffect(true, m_options.showTransition.ease,
                                    m_options.showTransition.time);
                enterState(State::fading_in, 0.0);
                animate = true;
            }
            break;
        case State::dead:
            break;
    }

    m_occludedLastFrame = m_occluded;
    m_occluded = false;

    return animate;
}