Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$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
You can’t perform that action at this time.