Skip to content

Instantly share code, notes, and snippets.

@Cvar1984
Created February 17, 2023 05:30
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 Cvar1984/4d5a2a99e84d38dd75c442931995aeb3 to your computer and use it in GitHub Desktop.
Save Cvar1984/4d5a2a99e84d38dd75c442931995aeb3 to your computer and use it in GitHub Desktop.
fibonnaci eclipse
<?php
$count = 10;
function f(int $n)
{
$nPrev = 1;
$nCurrent = 1;
for ($x = 0; $x < $n - 1; $x++) {
$nNext = $nPrev + $nCurrent;
$nPrev = $nCurrent;
$nCurrent = $nNext;
yield $nCurrent;
}
}
$x = 300;
$y = 350;
$image = imagecreatetruecolor($x, $y); // horizontal, vertical
$white = imagecolorallocatealpha($image, 255, 255, 255, 75);
$yellow = imagecolorallocatealpha($image, 255, 255, 0, 75);
foreach (f($count) as $fbn) {
imageellipse($image, (70 + $fbn), (100 + $fbn), (100 + $fbn), (150 + $fbn), $yellow);
}
header('Content-type: image/png');
ImagePNG($image);
ImageDestroy($image);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment