本文整理汇总了PHP中Canvas::rect方法的典型用法代码示例。如果您正苦于以下问题:PHP Canvas::rect方法的具体用法?PHP Canvas::rect怎么用?PHP Canvas::rect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas::rect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: drawProfile
protected function drawProfile($profile, $width, $height)
{
$margint = 50;
$marginr = 50;
$marginb = 50;
$marginl = 50;
$last = end($profile);
$maxdist = $last[0];
$minalti = array(array(0, INF));
$maxalti = array(array(0, -INF));
foreach ($profile as $coords) {
$alti = $coords[1];
if ($alti == $minalti[0][1]) {
$minalti[] = array($coords[0], $alti);
} else {
if ($alti < $minalti[0][1]) {
$minalti = array(array($coords[0], $alti));
}
}
if ($alti == $maxalti[0][1]) {
$maxalti[] = array($coords[0], $alti);
} else {
if ($alti > $maxalti[0][1]) {
$maxalti = array(array($coords[0], $alti));
}
}
}
$canvas = new Canvas($width, $height, $margint, $marginr, $marginb, $marginl);
$canvas->setViewBox(0, $minalti[0][1], $maxdist, $maxalti[0][1]);
$canvas->rect(0, 0, $width, $height, "FFFFFF");
$slopecolor = function ($slope) {
if ($slope > 18) {
return "FF0000";
// red
} else {
if ($slope > 12) {
return "FF4000";
} else {
if ($slope > 7) {
return "FF8000";
} else {
if ($slope > 3) {
return "FFC000";
} else {
if ($slope > 0) {
return "FFFF00";
// yellow
} else {
if ($slope > -3) {
return "00FFFF";
} else {
if ($slope > -7) {
return "00C0FF";
} else {
if ($slope > -12) {
return "0080FF";
} else {
if ($slope > -18) {
return "0040FF";
} else {
return "0000FF";
// blue;
}
}
}
}
}
}
}
}
}
};
$canvas->setThickness(2);
$prev = null;
foreach ($profile as $coord) {
if (!is_null($prev)) {
$dist = $coord[0];
$alti = $coord[1];
$prevdist = $prev[0];
$prevalti = $prev[1];
$slope = 100 * ($alti - $prevalti) / ($dist - $prevdist);
$canvas->line($canvas->canvasXPos($prevdist), $canvas->canvasYPos($prevalti), $canvas->canvasXPos($dist), $canvas->canvasYPos($alti), $slopecolor($slope), true);
}
$prev = $coord;
}
$canvas->setThickness(1);
$canvas->setFont(APPLICATION_PATH . '/resources/' . 'DejaVuSans.ttf', 10);
list($minx, $miny, $maxx, $maxy) = $canvas->getViewBox();
$deltax = pow(10, floor(log10($maxx - $minx)));
foreach (range($minx, $maxx, $deltax) as $x) {
$canvas->line($canvas->canvasXPos($x), $height - $marginb + 10, $canvas->canvasXPos($x), $height - $marginb, "000000");
if ($deltax < 1000) {
$text = $x . "m";
} else {
$text = round($x / 1000) . "km";
}
$canvas->text($canvas->canvasXPos($x), $height - $marginb + 10 + 3, $text, "000000", "cb");
}
$canvas->line($marginl, $height - $marginb, $width - $marginr, $height - $marginb, "000000");
$deltay = pow(10, floor(log10($maxy - $miny)));
//.........这里部分代码省略.........