Created
March 1, 2019 09:05
-
-
Save Kyslik/5b9a66b9b0852c91f1310c279a9f2543 to your computer and use it in GitHub Desktop.
small optim for https://stackoverflow.com/q/54934885/1564365
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$points = []; | |
for ($x = 0; $x <= 349; $x++) { | |
for($y = 0; $y <= 349; $y++) { | |
$point = ['x' => $x, 'y' => $y, 'is_water' => false]; | |
$rgb = imagecolorat($imageResource, $x, $y); | |
$r = ($rgb >> 16) & 0xFF; | |
$g = ($rgb >> 8) & 0xFF; | |
$b = $rgb & 0xFF; | |
if ($r === $waterR && $g === $waterG && $b === $waterB) { | |
$point['is_water'] = true; | |
} | |
$points[] = $point; | |
} | |
} | |
Location::insert($points); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ($x = 0; $x <= 349; $x++) { | |
$points = []; | |
for($y = 0; $y <= 349; $y++) { | |
$point = ['x' => $x, 'y' => $y, 'is_water' => false]; | |
$rgb = imagecolorat($imageResource, $x, $y); | |
$r = ($rgb >> 16) & 0xFF; | |
$g = ($rgb >> 8) & 0xFF; | |
$b = $rgb & 0xFF; | |
if ($r === $waterR && $g === $waterG && $b === $waterB) { | |
$point['is_water'] = true; | |
} | |
$points[] = $point; | |
} | |
Location::insert($points); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment