Skip to content

Instantly share code, notes, and snippets.

Created November 24, 2015 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7e2fcd9e774f8d4d51f0 to your computer and use it in GitHub Desktop.
Save anonymous/7e2fcd9e774f8d4d51f0 to your computer and use it in GitHub Desktop.
//激重なのでリリースでの実行を推奨
# include <Siv3D.hpp>
void DrawCarpet(int left, int top, int size);
void Main()
{
Graphics::SetBackground(Palette::Black);
int size = Window::Width();
while (System::Update())
{
DrawCarpet(0, 0, size);
size *= 1.02;
if (size > Window::Width() * 3)size /= 3;
}
}
void DrawCarpet(int left, int top, int size){
//再帰的に白い正方形を描いていくだけ
Rect(left + size / 3, top + size / 3,size / 3,size / 3).draw(Palette::White);
if (size < 3)return;
DrawCarpet(left, top, size / 3);
if (size / 3 < Window::Width())
{
DrawCarpet(left + size / 3, top, size / 3);
DrawCarpet(left, top + size / 3, size / 3);
if (size * 2 / 3 < Window::Width())
{
DrawCarpet(left + size * 2 / 3, top, size / 3);
DrawCarpet(left + size * 2 / 3, top + size / 3, size / 3);
DrawCarpet(left, top + size * 2 / 3, size / 3);
DrawCarpet(left + size / 3, top + size * 2 / 3, size / 3);
DrawCarpet(left + size * 2 / 3, top + size * 2 / 3, size / 3);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment