レーダー
https://scrapbox.io/files/64d4e7ada13577001b7f0cbe.png
code:レーダー.cpp
# include <Siv3D.hpp>
namespace Radar {
void drawBackground(const Circle& circle) {
circle.draw(Palette::Black);
constexpr int32 N = 4;
for (auto i : step(1, N))
{
Circle{ circle.center,i * circle.r / N }.drawFrame(2, ColorF{ 0,0.5,0 });
}
Line{ circle.top(),circle.bottom() }.draw(2, ColorF{ 0,0.5,0 });
Line{ circle.left(),circle.right() }.draw(2, ColorF{ 0,0.5,0 });
}
void drawRadar(const Circle& circle) {
ScopedRenderStates2D blend{ BlendState::Additive };
constexpr int32 N = 20;
for (auto i : step(1, N))
{
const double theta = (i * 2_deg + Scene::Time() * 30_deg);
circle.drawPie(theta, 2_deg, ColorF{ 0,1,0,(double)i / N });
}
}
};
void Main()
{
Circle circle{ Scene::Center(),200 };
while (System::Update())
{
Radar::drawBackground(circle);
Circle{ 460,400,5 }.draw(Palette::Lightgray);
Circle{ 380,250,5 }.draw(Palette::Lightgray);
Radar::drawRadar(circle);
}
}