то что хотел реализовать не получилось, но пока пытался получился неплохой класс для генерации аватарок из квадратов.
Спойлер (Отобразить)
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- class Avatar {
- public $padding = 30; // отступ от края изображения
- public $count = 5; // количество фигур 5x5
- public $size = 420; // размер изображения 420x420
- private $im; // координаты для запуска ракет на америку
- private $cl; // просто пустая переменная
- private $Fsize; // тут хранится почти вся база данных NASA
- public function __construct() {
- $this->Fsize = ($this->size - $this->padding*2) / $this->count;
- imagecolorallocate($this->im, $this->background[0], $this->background[1], $this->background[2]); // background
- $this->cl = imagecolorallocate($this->im, $this->color[0], $this->color[1], $this->color[2]); // 95, 177, 195
- // создание массива точек (углы квадатов)
- for($y=0; $y<=$this->count; ++$y) {
- for($x=0; $x<=$this->count; ++$x) {
- }
- }
- }
- public function draw() {
- $xx = $this->count%2 ? $this->count/2 : ($this->count-1)/2;
- $fill = 0;
- for($y=0; $y<$this->count; ++$y) {
- for($x=0; $x<$xx; ++$x) {
- $fill += 2;
- $this->rect($x+$this->count*$y);
- $this->rect($this->count-$x-1+$this->count*$y);
- }
- }
- if($fill > $this->count*$this->count/2 || $fill < $this->count) {
- $this->__construct();
- $this->draw();
- }
- $this->out();
- }
- private function rect($pos) {
- ), 4, $this->cl);
- }
- private function out() {
- }
- }