WP File Manager
Current Path:
/
home
/
argothem
/
www
/
organecyberpresse
/
plugins
/
auto
/
adaptive_images
/
v3.4.0
/
lib
/
geometrize
/
geometrize
/
Name
Action
..
AbstractEnumTools.class.php
Edit
Core.class.php
Edit
Model.class.php
Edit
State.class.php
Edit
_ArraySet
bitmap
exporter
rasterizer
runner
shape
Editing: Model.class.php
<?php // Generated by Haxe 3.4.7 class geometrize_Model { /** * @var int */ protected $width; /** * @var int */ protected $height; /** * @var geometrize_bitmap_Bitmap */ protected $target; /** * @var geometrize_bitmap_Bitmap */ protected $current; /** * @var geometrize_bitmap_Bitmap */ protected $buffer; /** * @var float */ protected $shapeSizeFactor; /** * @var float */ protected $score; public function __construct($target, $backgroundColor){ if (!($target!==null)){ throw new HException("FAIL: target != null"); } $this->width = $target->width; $this->height = $target->height; $this->target = $target; $this->current = geometrize_bitmap_Bitmap::create($this->width,$this->height,$backgroundColor); $this->score = geometrize_Core::differenceFull($target, $this->current); $this->buffer = clone $this->current; $this->shapeSizeFactor = 1.0; } /** * @param array $shapeTypes * @param int $alpha * @param int $nRandom * @param int $maxMutationAge * @return array * @throws HException */ public function step($shapeTypes, $alpha, $nRandom, $maxMutationAge){ $state = geometrize_Core::bestHillClimbState($shapeTypes, $this->shapeSizeFactor, $alpha, $nRandom, $maxMutationAge, $this->target, $this->current, $this->buffer, $this->score); $results = [$this->addShape($state->getShape(), $state->getAlpha())]; return $results; } /** * @param geometrize_shape_Shape $shape * @param int $alpha * @return array * @throws HException */ public function addShape($shape, $alpha){ if (!($shape!==null)){ throw new HException("FAIL: shape != null"); } $before = clone $this->current; $lines = $shape->rasterize(); if (!isset($shape->color)){ $shape->color = geometrize_Core::computeColor($this->target, $this->current, $lines, $alpha); } geometrize_rasterizer_Rasterizer::drawLines($this->current, $shape->color, $lines); $this->score = geometrize_Core::differencePartial($this->target, $before, $this->current, $this->score, $lines); $score_normalization = $before->width * $before->height * 4 * 255; $result = ["score" => $this->score/$score_normalization, "color" => $shape->color, "shape" => $shape]; $this->shapeSizeFactor = 0.75 * $this->shapeSizeFactor + 0.25 * $shape->getSizeFactor(); $this->shapeSizeFactor = max(min($this->shapeSizeFactor, 1.0),0.1); return $result; } /** * @return geometrize_bitmap_Bitmap */ public function getCurrent() { return $this->current; } /** * @return int */ public function getHeight() { return $this->height; } /** * @return int */ public function getWidth() { return $this->width; } function __toString(){ return 'geometrize.Model'; } }