Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $gd = imagecreate(120, 120);
- $code = str_baseconvert(md5("image_shape_salt_" + $id), 16, 8);
- $color = str_baseconvert(md5("image_color_salt_" + $id), 16, 36);
- $background = imagecolorallocatealpha($gd, 255, 255, 255, 0);
- $maincolor = imagecolorallocate($gd, base_convert($color[0], 36, 10) * 10 + 100, base_convert($color[1], 36, 10) * 10 + 100, base_convert($color[2], 36, 10) * 10 + 100);
- for ($x = 0; $x < 4; $x++) {
- for ($z = 0; $z < 4; $z++) {
- $number = (int) $code[$x * 4 + $z];
- switch ($number) {
- case 0:
- break;
- case 1: // Full square
- imagefilledrectangle($gd, $x * 30, $z * 30, $x * 30 + 29, $z * 30 + 29, $maincolor);
- break;
- case 2: // top
- imagefilledrectangle($gd, $x * 30, $z * 30, $x * 30 + 14, $z * 30 + 29, $maincolor);
- break;
- case 3: // left
- imagefilledrectangle($gd, $x * 30, $z * 30, $x * 30 + 29, $z * 30 + 14, $maincolor);
- break;
- case 4: // bottom
- imagefilledrectangle($gd, $x * 30 + 15, $z * 30, $x * 30 + 29, $z * 30 + 29, $maincolor);
- break;
- case 5: // right
- imagefilledrectangle($gd, $x * 30, $z * 30 + 15, $x * 30 + 29, $z * 30 + 29, $maincolor);
- break;
- case 6: // middle
- imagefilledrectangle($gd, $x * 30 + 5, $z * 30 + 5, $x * 30 + 24, $z * 30 + 24, $maincolor);
- break;
- case 7: // hollow
- imagefilledrectangle($gd, $x * 30, $z * 30, $x * 30 + 29, $z * 30 + 29, $maincolor);
- imagefilledrectangle($gd, $x * 30 + 7, $z * 30 + 7, $x * 30 + 22, $z * 30 + 22, $background);
- break;
- }
- }
- }
- $pattern = imagecreate(60, 60);
- imagecopyresized($pattern, $gd, 0, 0, 0, 0, 60, 60, 120, 120);
- imagecopy($gd, $pattern, 0, 0, 0, 0, 60, 60);
- imageflip($pattern, IMG_FLIP_HORIZONTAL);
- imagecopy($gd, $pattern, 60, 0, 0, 0, 60, 60);
- imageflip($pattern, IMG_FLIP_VERTICAL);
- imagecopy($gd, $pattern, 60, 60, 0, 0, 60, 60);
- imageflip($pattern, IMG_FLIP_HORIZONTAL);
- imagecopy($gd, $pattern, 0, 60, 0, 0, 60, 60);
- imagedestroy($pattern);
- imagepng($gd);
- imagedestroy($gd);
Advertisement
Add Comment
Please, Sign In to add comment