MCPcopy Create free account
hub / github.com/comaps/comaps / GetPrettyFollowAnimation

Function GetPrettyFollowAnimation

libs/drape_frontend/screen_animations.cpp:71–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71drape_ptr<SequenceAnimation> GetPrettyFollowAnimation(ScreenBase const & startScreen, m2::PointD const & userPos,
72 double targetScale, double targetAngle,
73 m2::PointD const & endPixelPos)
74{
75 auto sequenceAnim = make_unique_dp<SequenceAnimation>();
76 sequenceAnim->SetCustomType(kPrettyFollowAnim);
77
78 m2::RectD const viewportRect = startScreen.PixelRectIn3d();
79
80 ScreenBase tmp = startScreen;
81 tmp.SetAngle(targetAngle);
82 tmp.MatchGandP3d(userPos, viewportRect.Center());
83
84 double const moveDuration = PositionInterpolator::GetMoveDuration(startScreen.GetOrg(), tmp.GetOrg(), startScreen);
85 ASSERT_GREATER(moveDuration, 0.0, ());
86
87 double const scaleFactor = moveDuration / kMaxAnimationTimeSec * 2.0;
88
89 tmp = startScreen;
90
91 if (moveDuration > 0.0)
92 {
93 tmp.SetScale(startScreen.GetScale() * scaleFactor);
94
95 auto zoomOutAnim = make_unique_dp<MapLinearAnimation>();
96 zoomOutAnim->SetScale(startScreen.GetScale(), tmp.GetScale());
97 zoomOutAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);
98 sequenceAnim->AddAnimation(std::move(zoomOutAnim));
99
100 tmp.MatchGandP3d(userPos, viewportRect.Center());
101
102 auto moveAnim = make_unique_dp<MapLinearAnimation>();
103 moveAnim->SetMove(startScreen.GetOrg(), tmp.GetOrg(), viewportRect, tmp.GetScale());
104 moveAnim->SetMaxDuration(kMaxAnimationTimeSec);
105 sequenceAnim->AddAnimation(std::move(moveAnim));
106 }
107
108 auto followAnim =
109 make_unique_dp<MapFollowAnimation>(tmp, userPos, endPixelPos, targetScale, targetAngle, false /* isAutoZoom */);
110 followAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);
111 sequenceAnim->AddAnimation(std::move(followAnim));
112 return sequenceAnim;
113}
114
115drape_ptr<MapLinearAnimation> GetRectAnimation(ScreenBase const & startScreen, ScreenBase const & endScreen)
116{

Callers 1

SetFollowAndRotateMethod · 0.85

Calls 9

MatchGandP3dMethod · 0.80
SetMoveMethod · 0.80
SetCustomTypeMethod · 0.45
SetAngleMethod · 0.45
CenterMethod · 0.45
SetScaleMethod · 0.45
GetScaleMethod · 0.45
SetMaxDurationMethod · 0.45
AddAnimationMethod · 0.45

Tested by

no test coverage detected