RedeyeVentures\GeoPattern\GeoPattern::geoPlusSigns PHP Method

geoPlusSigns() protected method

protected geoPlusSigns ( )
    protected function geoPlusSigns()
    {
        $squareSize = $this->map($this->hexVal(0, 1), 0, 15, 10, 25);
        $plusSize = $squareSize * 3;
        $plusShape = $this->buildPlusShape($squareSize);
        $this->svg->setWidth($squareSize * 12)->setHeight($squareSize * 12);
        $i = 0;
        for ($y = 0; $y <= 5; $y++) {
            for ($x = 0; $x <= 5; $x++) {
                $val = $this->hexVal($i, 1);
                $opacity = $this->opacity($val);
                $fill = $this->fillColor($val);
                $dx = $y % 2 == 0 ? 0 : 1;
                $styles = ['fill' => $fill, 'stroke' => self::STROKE_COLOR, 'stroke-opacity' => self::STROKE_OPACITY, 'style' => ['fill-opacity' => $opacity]];
                $group = new Group();
                $group->addItem($plusShape[0])->addItem($plusShape[1]);
                $t1 = $x * $plusSize - $x * $squareSize + $dx * $squareSize - $squareSize;
                $t2 = $y * $plusSize - $y * $squareSize - $plusSize / 2;
                $this->svg->addGroup($group, array_merge($styles, ['transform' => "translate({$t1}, {$t2})"]));
                // Add an extra column on the right for tiling.
                if ($x == 0) {
                    $xT1 = 4 * $plusSize - $x * $squareSize + $dx * $squareSize - $squareSize;
                    $xT2 = $y * $plusSize - $y * $squareSize - $plusSize / 2;
                    $this->svg->addGroup($group, array_merge($styles, ['transform' => "translate({$xT1}, {$xT2})"]));
                }
                // Add an extra row on the bottom that matches the first row, for tiling.
                if ($y == 0) {
                    $yT1 = $x * $plusSize - $x * $squareSize + $dx * $squareSize - $squareSize;
                    $yT2 = 4 * $plusSize - $y * $squareSize - $plusSize / 2;
                    $this->svg->addGroup($group, array_merge($styles, ['transform' => "translate({$yT1}, {$yT2})"]));
                }
                // Add an extra one at top-right and bottom-right, for tiling.
                if ($x == 0 && $y == 0) {
                    $xyT1 = 4 * $plusSize - $x * $squareSize + $dx * $squareSize - $squareSize;
                    $xyT2 = 4 * $plusSize - $y * $squareSize - $plusSize / 2;
                    $this->svg->addGroup($group, array_merge($styles, ['transform' => "translate({$xyT1}, {$xyT2})"]));
                }
                $i++;
            }
        }
    }