RedeyeVentures\GeoPattern\GeoPattern::geoSineWaves PHP Method

geoSineWaves() protected method

protected geoSineWaves ( )
    protected function geoSineWaves()
    {
        $period = floor($this->map($this->hexVal(0, 1), 0, 15, 100, 400));
        $quarterPeriod = $period / 4;
        $xOffset = $period / 4 * 0.7;
        $amplitude = floor($this->map($this->hexVal(1, 1), 0, 15, 30, 100));
        $waveWidth = floor($this->map($this->hexVal(2, 1), 0, 15, 3, 30));
        $amplitudeString = number_format($amplitude);
        $halfPeriod = number_format($period / 2);
        $halfPeriodMinusXOffset = number_format($period / 2 - $xOffset);
        $periodMinusXOffset = number_format($period - $xOffset);
        $twoAmplitude = number_format(2 * $amplitude);
        $onePointFivePeriodMinusXOffset = number_format($period * 1.5 - $xOffset);
        $onePointFivePeriod = number_format($period * 1.5);
        $str = "M0 {$amplitudeString} C {$xOffset} 0, {$halfPeriodMinusXOffset} 0, {$halfPeriod} {$amplitudeString} S {$periodMinusXOffset} {$twoAmplitude}, {$period} {$amplitudeString} S {$onePointFivePeriodMinusXOffset} 0, {$onePointFivePeriod}, {$amplitudeString}";
        $this->svg->setWidth($period)->setHeight($waveWidth * 36);
        for ($i = 0; $i <= 35; $i++) {
            $val = $this->hexVal($i, 1);
            $opacity = $this->opacity($val);
            $fill = $this->fillColor($val);
            $styles = ['fill' => 'none', 'stroke' => $fill, 'style' => ['opacity' => $opacity, 'stroke-width' => "{$waveWidth}px"]];
            $iWaveWidthMinusOnePointFiveAmplitude = $waveWidth * $i - $amplitude * 1.5;
            $iWaveWidthMinusOnePointFiveAmplitudePlusThirtySixWaveWidth = $waveWidth * $i - $amplitude * 1.5 + $waveWidth * 36;
            $this->svg->addPath($str, array_merge($styles, ['transform' => "translate(-{$quarterPeriod}, {$iWaveWidthMinusOnePointFiveAmplitude})"]));
            $this->svg->addPath($str, array_merge($styles, ['transform' => "translate(-{$quarterPeriod}, {$iWaveWidthMinusOnePointFiveAmplitudePlusThirtySixWaveWidth})"]));
        }
    }