Example #1
0
 /**
  * @param Stem     $stem
  * @param HeadTube $headTube
  * @param          $color
  *
  * @return bool
  */
 protected function drawStem(Stem $stem, HeadTube $headTube, $color)
 {
     $spacers = $stem->getSpacers();
     $x1 = $this->width / 5 * 2 - $headTube->getLength($spacers);
     $y1 = $this->height - $headTube->getHeight($spacers);
     $x2 = $x1 + $stem->getLength();
     $y2 = $y1 - $stem->getHeight();
     if ($spacers > 0) {
         $virtualHeadTube = clone $headTube;
         $virtualHeadTube->addSpacers($spacers);
         $this->drawTube($virtualHeadTube, $color, 8);
     }
     $color = $this->createColor($color);
     $this->draw($x1, $y1, $x2, $y2, $color, 8);
 }
Example #2
0
 /**
  * @param Stem $stem
  * @param HeadTube $headTube
  *
  * @return array
  */
 public function compare(Stem $stem, HeadTube $headTube)
 {
     // Calculate the offset the spacers will cause in the stem
     $currentSpacersOffsetX = $headTube->getLength($this->getSpacers()) - $headTube->getLength();
     $currentSpacersOffsetY = $headTube->getHeight($this->getSpacers()) - $headTube->getHeight();
     $currentStemLength = $this->getLength() - $currentSpacersOffsetX;
     $currentStemHeight = $this->getHeight() + $currentSpacersOffsetY;
     $comparedSpacersOffsetX = $headTube->getLength($stem->getSpacers()) - $headTube->getLength();
     $comparedSpacersOffsetY = $headTube->getHeight($stem->getSpacers()) - $headTube->getHeight();
     $comparedStemLength = $stem->getLength() - $comparedSpacersOffsetX;
     $comparedStemHeight = $stem->getHeight() + $comparedSpacersOffsetY;
     $length = number_format($currentStemLength - $comparedStemLength, 1);
     // $lengthStr = 'The 1st stem is ' . abs($length) . 'mm longerlonger than de 2nd one';
     $lengthStr = 'longer';
     if ($length < 0) {
         $lengthStr = 'shorter';
     }
     $height = number_format($currentStemHeight - $comparedStemHeight, 1);
     $heightStr = 'higher';
     if ($height < 0) {
         $heightStr = 'lower';
     }
     $comparison = ['length' => 'The red stem is ' . abs($length) . 'mm ' . $lengthStr . ' than de blue one', 'height' => 'The red stem is ' . abs($height) . 'mm ' . $heightStr . ' than de blue one'];
     return $comparison;
 }