Created
September 24, 2021 11:20
-
-
Save voidproc/f439389981aae5537d9b6a64020755f3 to your computer and use it in GitHub Desktop.
SimpleAnimationを視る
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <Siv3D.hpp> // OpenSiv3D v0.6.0 | |
void Main() | |
{ | |
Scene::SetBackground(ColorF{ 0, 0, 0 }); | |
Font font{ 16 }; | |
SimpleAnimation anim; | |
anim.setLoop(5s) | |
.set(U"value", { 0s, 0 }, { 2s, 0.5 }, EaseInOutCubic) | |
.set(U"value", { 2.5s, 0.5 }, { 3.5s, 1.0 }, EaseInOutSine) | |
.set(U"value", { 3.75s, 1.0 }, { 4.99s, 0 }, EaseInOutCubic) | |
.start(); | |
while (System::Update()) | |
{ | |
const SizeF graphSize{ 300, 300 }; | |
const Vec2 graphPos = Scene::Size() / 2 - graphSize / 2; | |
RectF{ graphPos, graphSize }.drawFrame(); | |
const double x = anim.posSec() / 5.0 * graphSize.x + graphPos.x; | |
const double y = (1.0 - anim[U"value"]) * graphSize.y + graphPos.y; | |
Line{ x, graphPos.y, x, graphPos.y + graphSize.y }.draw(LineStyle::SquareDot, 1); | |
Line{ graphPos.x, y, graphPos.x + graphSize.x, y }.draw(LineStyle::SquareDot, 1); | |
font(U"{:.1f}"_fmt(anim.posSec())).drawAt(x, graphPos.y + graphSize.y + 16); | |
font(U"{:.1f}"_fmt(anim[U"value"])).drawAt(graphPos.x - 24, y); | |
Circle{ Vec2{ x, y }, 10 }.draw(); | |
} | |
} |
Author
voidproc
commented
Sep 24, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment