simulate-chunk-selector: do not reallocate colours on every frame

This commit is contained in:
Dylan K. Taylor 2021-11-04 19:38:40 +00:00
parent 4c3a5fdd73
commit 8abc952c74
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -57,16 +57,16 @@ function render(int $radius, int $baseX, int $baseZ, int $chunksPerStep, int $sc
$middleOffsetX = $scale * ($radius + $offsetX);
$middleOffsetZ = $scale * ($radius + $offsetZ);
$black = imagecolorallocate($image, 0, 0, 0);
$yellow = imagecolorallocate($image, 255, 255, 51);
$red = imagecolorallocate($image, 255, 0, 0);
if($black === false || $yellow === false || $red === false) throw new AssumptionFailedError();
$frame = 0;
$seen = [];
while($iterator->valid()){
$frame++;
$black = imagecolorallocate($image, 0, 0, 0);
$yellow = imagecolorallocate($image, 255, 255, 51);
$red = imagecolorallocate($image, 255, 0, 0);
if($black === false || $yellow === false || $red === false) throw new AssumptionFailedError();
for($i = 0; $i < $chunksPerStep; ++$i){
$chunkHash = $iterator->current();
if(!isset($seen[$chunkHash])){