function _GetLED($aLedIdx, $aColor = 0) { $width = $this->iLED_X * $this->iRad * 2 + ($this->iLED_X + 1) * $this->iMarg + $this->iRad; $height = $this->iLED_Y * $this->iRad * 2 + $this->iLED_Y * $this->iMarg + $this->iRad * 2; // Adjust radious for supersampling $rad = $this->iRad * $this->iSuperSampling; // Margin in between "Led" dots $marg = $this->iMarg * $this->iSuperSampling; $swidth = $width * $this->iSuperSampling; $sheight = $height * $this->iSuperSampling; $simg = new RotImage($swidth, $sheight, 0, DEFAULT_GFORMAT, false); $simg->SetColor($this->iColorSchema[$aColor][2]); $simg->FilledRectangle(0, 0, $swidth - 1, $sheight - 1); if (array_key_exists($aLedIdx, $this->iLEDSpec)) { $d = $this->iLEDSpec[$aLedIdx]; } else { $d = array(0, 0, 0, 0, 0, 0, 0); } for ($r = 0; $r < 7; ++$r) { $dr = $d[$r]; for ($c = 0; $c < 4; ++$c) { if (($dr & pow(2, 3 - $c)) !== 0) { $color = $this->iColorSchema[$aColor][0]; } else { $color = $this->iColorSchema[$aColor][1]; } $x = 2 * $rad * $c + $rad + ($c + 1) * $marg + $rad; $y = 2 * $rad * $r + $rad + ($r + 1) * $marg + $rad; $simg->SetColor($color); $simg->FilledCircle($x, $y, $rad); } } $img = new Image($width, $height, DEFAULT_GFORMAT, false); $img->Copy($simg->img, 0, 0, 0, 0, $width, $height, $swidth, $sheight); $simg->Destroy(); unset($simg); return $img; }
function Stroke($aGraph) { $aImg = $aGraph->img; if ($this->iX > 0 && $this->iX < 1) { $this->iX = round($aImg->width * $this->iX); } if ($this->iY > 0 && $this->iY < 1) { $this->iY = round($aImg->height * $this->iY); } if ($this->iSize > 0 && $this->iSize < 1) { $this->iSize *= min($aImg->width, $aImg->height); } if ($this->iCenterSize > 0 && $this->iCenterSize < 1) { $this->iCenterSize *= $this->iSize; } $this->scale->AutoScale(($this->iSize - $this->iCenterSize) / 2, round(2.5 * $this->scale->iFontSize)); $scaling = $this->iAntiAlias ? 2 : 1; $value = new Text(); $value->SetFont($this->iFontFamily, $this->iFontStyle, $this->iFontSize * $scaling); $value->SetColor($this->iFontColor); $legendheight = round($this->legend->iShow ? 1 : 0); $legendheight *= max($this->legend->iCircleRadius * 2, $this->legend->iTxtFontSize * 2) + $this->legend->iMargin + $this->legend->iBottomMargin + 2; $legendheight *= $scaling; $w = $scaling * $this->getWidth($aImg); $h = $scaling * $this->getHeight($aImg); // Copy back the double buffered image to the proper canvas $ww = $w / $scaling; $hh = $h / $scaling; // Create the double buffer if ($this->iAntiAlias) { $dblImg = new RotImage($w, $h); // Set the background color $dblImg->SetColor($this->iColor); $dblImg->FilledRectangle(0, 0, $w, $h); } else { $dblImg = $aImg; // Make sure the ix and it coordinates correpond to the new top left center $dblImg->SetTranslation($this->iX - $w / 2, $this->iY - $h / 2); } if (__DEBUG) { $dblImg->SetColor('red'); $dblImg->Rectangle(0, 0, $w - 1, $h - 1); } $dblImg->SetColor('black'); if ($this->iShowBox) { $dblImg->SetColor($this->iBoxColor); $old = $dblImg->SetLineWeight($this->iBoxWeight); $dblImg->SetLineStyle($this->iBoxStyle); $dblImg->Rectangle(0, 0, $w - 1, $h - 1); $dblImg->SetLineWeight($old); } $xc = round($w / 2); $yc = round(($h - $legendheight) / 2); if (__DEBUG) { $dblImg->SetColor('red'); $old = $dblImg->SetLineWeight(2); $dblImg->Line($xc - 5, $yc - 5, $xc + 5, $yc + 5); $dblImg->Line($xc + 5, $yc - 5, $xc - 5, $yc + 5); $dblImg->SetLineWeight($old); } $this->iSize *= $scaling; // Inner circle size $ri = $this->iCenterSize / 2; // Full circle radius $r = round($this->iSize / 2); // Get number of grid circles $n = $this->scale->GetNumCirc(); // Plot circle grids $ri *= $scaling; $rr = round(($r - $ri) / $n); for ($i = 1; $i <= $n; ++$i) { $this->_ThickCircle($dblImg, $xc, $yc, $rr * $i + $ri, $this->iCircGridWeight, $this->iGridColor1); } $num = 0; if ($this->iType == WINDROSE_TYPEFREE) { $this->_StrokeFreeRose($dblImg, $value, $scaling, $xc, $yc, $r, $ri); } else { // Check if we need to re-code the interpretation of the ordinal // number in the data. Internally ordinal value 0 is East and then // counted anti-clockwise. The user might choose an encoding // that have 0 being the first axis to the right of the "N" axis and then // counted clock-wise if ($this->iOrdinalEncoding == KEYENCODING_CLOCKWISE) { if ($this->iType == WINDROSE_TYPE16) { $const1 = 19; $const2 = 16; } elseif ($this->iType == WINDROSE_TYPE8) { $const1 = 9; $const2 = 8; } else { $const1 = 4; $const2 = 4; } $tmp = array(); $n = count($this->iData); foreach ($this->iData as $key => $val) { if (is_numeric($key)) { $key = ($const1 - $key) % $const2; } $tmp[$key] = $val; } $this->iData = $tmp; } $this->_StrokeRegularRose($dblImg, $value, $scaling, $xc, $yc, $r, $ri); } // Stroke the labels $this->scale->iFontSize *= $scaling; $this->scale->iZFontSize *= $scaling; $this->scale->StrokeLabels($dblImg, $xc, $yc, $ri, $rr); // Stroke the inner circle again since the legs // might have written over it $this->_ThickCircle($dblImg, $xc, $yc, $ri, $this->iCircGridWeight, $this->iGridColor1); if ($ww > $aImg->width) { JpgraphError::RaiseL(22020); //('Windrose plot is too large to fit the specified Graph size. Please use WindrosePlot::SetSize() to make the plot smaller or increase the size of the Graph in the initial WindroseGraph() call.'); } $x = $xc; $y = $h; $this->_StrokeLegend($dblImg, $x, $y, $scaling); if ($this->iAntiAlias) { $aImg->Copy($dblImg->img, $this->iX - $ww / 2, $this->iY - $hh / 2, 0, 0, $ww, $hh, $w, $h); } // We need to restore the translation matrix $aImg->SetTranslation(0, 0); }