Example #1
0
function frame($psdoc)
{
    ps_setlinewidth($psdoc, 60);
    ps_moveto($psdoc, 150, 50);
    ps_lineto($psdoc, 750, 50);
    ps_arc($psdoc, 750, 150, 100, 270, 360);
    ps_lineto($psdoc, 850, 750);
    ps_arc($psdoc, 750, 750, 100, 0, 90);
    ps_lineto($psdoc, 150, 850);
    ps_arc($psdoc, 150, 750, 100, 90, 180);
    ps_lineto($psdoc, 50, 150);
    ps_arc($psdoc, 150, 150, 100, 180, 270);
    ps_stroke($psdoc);
}
Example #2
0
 function begin_example_box($p, $llx, $lly, $title, $font)
 {
     ps_save($p);
     ps_translate($p, $llx, $lly);
     ps_setcolor($p, "fill", "gray", 0.5, 0.0, 0.0, 0.0);
     ps_rect($p, 0, EXAMPLE_BOX_HEIGHT - EXAMPLE_BOX_TITLE_HEIGHT, EXAMPLE_BOX_WIDTH, EXAMPLE_BOX_TITLE_HEIGHT);
     ps_fill($p);
     ps_setcolor($p, "stroke", "gray", 1.0, 0.0, 0.0, 0.0);
     ps_setfont($p, $font, 12.0);
     ps_show_xy($p, $title, 10, EXAMPLE_BOX_HEIGHT - EXAMPLE_BOX_TITLE_HEIGHT + 5);
     ps_setlinewidth($p, 1.0);
     ps_setcolor($p, "stroke", "gray", 0.0, 0.0, 0.0, 0.0);
     ps_rect($p, 0, 0, EXAMPLE_BOX_WIDTH, EXAMPLE_BOX_HEIGHT);
     ps_stroke($p);
     ps_moveto($p, 0, EXAMPLE_BOX_HEIGHT - EXAMPLE_BOX_TITLE_HEIGHT);
     ps_lineto($p, EXAMPLE_BOX_WIDTH, EXAMPLE_BOX_HEIGHT - EXAMPLE_BOX_TITLE_HEIGHT);
     ps_stroke($p);
 }
Example #3
0
 function drawPie($centerX, $centerY, $radius, $begin, $end, $style)
 {
     $this->_convertPosition($centerX, $centerY);
     $radius = $radius * min($this->width, $this->height);
     ps_setcolor($this->ps, 'stroke', $style['line'][0], $style['line'][1], $style['line'][2], $style['line'][3], $style['line'][4]);
     if (isset($style['fill'])) {
         ps_setcolor($this->ps, 'fill', $style['fill'][0], $style['fill'][1], $style['fill'][2], $style['fill'][3], $style['fill'][4]);
     }
     ps_setlinewidth($this->ps, $style['line-width']);
     ps_moveto($this->ps, $centerX, $centerY);
     ps_arc($this->ps, $centerX, $centerY, $radius, $begin, $end);
     ps_lineto($this->ps, $centerX, $centerY);
     ps_closepath($this->ps);
     if (isset($style['fill'])) {
         ps_fill_stroke($this->ps);
     } else {
         ps_stroke($this->ps);
     }
 }
Example #4
0
 for ($j = 0; $j < 16; $j++) {
     $text = sprintf("%Xx", $j);
     ps_show_xy($ps, $text, $leftmargin - 1.7 * $fontsize, $bottommargin + (15 - $j) * $rowheight + $rowheight / 2 - $fontsize / 2);
 }
 /* The symbol itself */
 ps_setfont($ps, $samplefont, $fontsamplesize);
 ps_setlinewidth($ps, 0.4);
 for ($j = 0; $j < 16; $j++) {
     for ($i = 0; $i < 16; $i++) {
         $textwidth = ps_symbol_width($ps, $j * 16 + $i, $psfont, $fontsize);
         ps_set_value($ps, "textx", $leftmargin + $i * $colwidth + $colwidth / 2 - $textwidth / 2);
         ps_set_value($ps, "texty", $bottommargin + (15 - $j) * $rowheight + $rowheight / 2 + 3 - $fontsize / 2);
         //ps_show_xy($ps, $text, $leftmargin+$i*$colwidth+$colwidth/2-$textwidth/2, $bottommargin+(15-$j)*$rowheight+$rowheight/2-$fontsize/2);
         //			ps_show($ps, $text);
         ps_symbol($ps, $j * 16 + $i);
         ps_moveto($ps, $leftmargin + $i * $colwidth + $colwidth / 2 - $textwidth / 2, $bottommargin + (15 - $j) * $rowheight + $rowheight / 2 + 3 - $fontsize / 2);
         ps_lineto($ps, $leftmargin + $i * $colwidth + $colwidth / 2 + $textwidth / 2, $bottommargin + (15 - $j) * $rowheight + $rowheight / 2 + 3 - $fontsize / 2);
         ps_stroke($ps);
     }
 }
 /* The name of the symbol */
 ps_setfont($ps, $psfont, 3);
 for ($j = 0; $j < 16; $j++) {
     for ($i = 0; $i < 16; $i++) {
         $text = ps_symbol_name($ps, $j * 16 + $i, $samplefont);
         ps_set_value($ps, "textx", $leftmargin + $i * $colwidth + 2);
         ps_set_value($ps, "texty", $bottommargin + (15 - $j) * $rowheight + 2);
         ps_show($ps, $text);
         $text = sprintf(" (%d)", $j * 16 + $i);
         ps_show($ps, $text);
     }
Example #5
0
 /**
  * Draw an ellipse
  *
  * Parameter array:
  * 'x': int X center point
  * 'y': int Y center point
  * 'rx': int X radius
  * 'ry': int Y radius
  * 'fill': mixed [optional] The fill color
  * 'line': mixed [optional] The line color
  * @param array $params Parameter array
  */
 function ellipse($params)
 {
     $x = $params['x'];
     $y = $params['y'];
     $rx = $params['rx'];
     $ry = $params['ry'];
     $fillColor = isset($params['fill']) ? $params['fill'] : false;
     $lineColor = isset($params['line']) ? $params['line'] : false;
     $line = $this->_setLineStyle($lineColor);
     $fill = $this->_setFillStyle($fillColor);
     if ($line || $fill) {
         if ($rx == $ry) {
             ps_circle($this->_ps, $this->_getX($x), $this->_getY($y), $rx);
         } else {
             ps_moveto($this->_ps, $this->_getX($x - $rx), $this->_getY($y));
             ps_curveto($this->_ps, $this->_getX($x - $rx), $this->_getY($y), $this->_getX($x - $rx), $this->_getY($y - $ry), $this->_getX($x), $this->_getY($y - $ry));
             ps_curveto($this->_ps, $this->_getX($x), $this->_getY($y - $ry), $this->_getX($x + $rx), $this->_getY($y - $ry), $this->_getX($x + $rx), $this->_getY($y));
             ps_curveto($this->_ps, $this->_getX($x + $rx), $this->_getY($y), $this->_getX($x + $rx), $this->_getY($y + $ry), $this->_getX($x), $this->_getY($y + $ry));
             ps_curveto($this->_ps, $this->_getX($x), $this->_getY($y + $ry), $this->_getX($x - $rx), $this->_getY($y + $ry), $this->_getX($x - $rx), $this->_getY($y));
         }
         if ($line && $fill) {
             ps_fill_stroke($this->_ps);
         } elseif ($line) {
             ps_stroke($this->_ps);
         } elseif ($fill) {
             ps_fill($this->_ps);
         }
     }
     parent::ellipse($params);
 }
Example #6
0
    ps_restore($ps);
    /* draw minute hand */
    ps_save($ps);
    ps_rotate($ps, -($ltime['seconds'] / 60.0 + $ltime['minutes'] - 15.0) * 6.0);
    ps_moveto($ps, -$radius / 10, -$radius / 20);
    ps_lineto($ps, $radius * 0.8, 0.0);
    ps_lineto($ps, -$radius / 10, $radius / 20);
    ps_closepath($ps);
    ps_fill($ps);
    ps_restore($ps);
    /* draw second hand */
    //    ps_setrgbcolor($ps, 1.0, 0.0, 0.0);
    ps_setlinewidth($ps, 2);
    ps_save($ps);
    ps_rotate($ps, -(($ltime['seconds'] - 15.0) * 6.0));
    ps_moveto($ps, -$radius / 5, 0.0);
    ps_lineto($ps, $radius, 0.0);
    ps_stroke($ps);
    ps_restore($ps);
    /* draw little circle at center */
    ps_circle($ps, 0, 0, $radius / 30);
    ps_fill($ps);
    ps_end_page($ps);
    # to see some difference
    //	sleep(1);
}
/*$buf = ps_get_buffer($ps);
$len = strlen($buf);

header("Content-type: application/pdf");
header("Content-Length: $len");