Functions
WebDev/*nix assorted functions & hacks
Search
find all
Array
-
Bash
-
Classes
-
Config
-
DateTime
-
Debug
-
dotjs
-
File
-
foooo
-
Git
-
HTML
-
Images
-
Javascript
-
Linux
-
Math
-
Misc
-
MySQL
-
OS X
-
Reading
-
Redis
-
Shell scripts
-
snippets
-
SQL
-
Strings
-
TextMate
-
Web
-
\(^o^)/ Fun!
-
_Misc hacks
-
_Pages
\(^o^)/ Fun!
* Readme
Alphanumeric images to ascii
Conway's Game of Life as TextMate command
Langton's Ant
Quine
Sierpiński Carpet
Sierpiński Triangle
Towers of Hanoi
8
found
auth
Name:
Category: \(^o^)/ Fun!
Body:
/* Similar to the Sierpiński Carpet, except with three colours and 3 points to choose from at random. */ header("Content-type: image/png"); $w = 500; $h = 500; $im = imagecreatetruecolor($w, $h); $white = imagecolorallocate($im, 250, 250, 250); $red = imagecolorallocate($im, 250, 0, 0); $green = imagecolorallocate($im, 0, 250, 0); $blue = imagecolorallocate($im, 0, 0, 250); $colors = array(1=>$red, $green, $blue); imagefill($im, 1, 1, $white); $x = $y = round($w/2); $crs = array(1=>array(round($w/2),0), 2=>array(0,$h), 3=>array($w,$h)); for($i=0;$i < 40000;$i++) { $c = rand(1, 3); $x = round((($crs[$c][0])+$x)/2); $y = round((($crs[$c][1])+$y)/2); imagesetpixel($im, $x, $y, $colors[$c]); } imagepng($im); imagedestroy($im);
Footer