Skip to content

Instantly share code, notes, and snippets.

@Reputeless
Last active December 10, 2015 02:15
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 Reputeless/988593cb38c443076e5c to your computer and use it in GitHub Desktop.
Save Reputeless/988593cb38c443076e5c to your computer and use it in GitHub Desktop.
# include <Siv3D.hpp> // Siv3D June 2015 v2
void Main()
{
Graphics2D::SetSamplerState(SamplerState::ClampPoint);
Image img(128, 96, Color(0));
DynamicTexture tex;
for (auto& p : img)
p.r = Random(1);
while (System::Update())
{
for (auto b : step(img.size))
{
int s = 0;
for (auto d : step({ -1, -1 }, { 3, 3 }))
s += img.getPixel<ImageAddressMode::Wrap>(b.y + d.y, b.x + d.x).r;
auto& p = img[b.y][b.x];
p.b = (s == 3) || (p.r && s == 4);
}
tex.fill(img.forEach([](Color& p){p.g = (p.r = p.b) ? 255 : 0; }));
tex.scale(5).draw();
System::Sleep(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment