Skip to content

Instantly share code, notes, and snippets.

@Techmind
Created December 18, 2015 12:45
Show Gist options
  • Save Techmind/5d17d8e966c8c07d184a to your computer and use it in GitHub Desktop.
Save Techmind/5d17d8e966c8c07d184a to your computer and use it in GitHub Desktop.
$image = imagecreatefrompng("/home/vagrant/Code/image.png");
$cmds = [[],[]];
for ($y = 0; $y < 30; $y++) {
for ($x = 0; $x < 30; $x++) {
// 0 - black,
// 127 - grey
// 255 - white
$color = imagecolorat($image, $x, $y);
// black
if (
// $color == 0
$color <= 127 / 2
) {
$cmds[0][] = $y * 30 + $x;
// white
} else if (
$color >= 127 / 2 * 3
// $color == 255
) {
// grey
} else {
$cmds[1][] = $y * 30 + $x;
}
}
}
foreach ($cmds[1] as $index) {
echo "jQuery(jQuery('#grid .c-keeper .line .cell')[$index]).click();\n";
}
foreach ($cmds[0] as $index) {
echo "jQuery(jQuery('#grid .c-keeper .line .cell')[$index]).click();\n$('#paint-orange').click();\n";
}
die;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment