Пример #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);
}
Пример #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);
 }
Пример #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);
     }
 }
Пример #4
0
     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);
     }
 }
 $text = "This fontsample matrix is created with the ps_symbol() function. It prints a glyph by its decimal value in the font encoding vector. pslib can use the TeXBase1 encoding (default) or the encoding shipped with the font itself, which is usually AdobeStandardEncoding. The above matrix uses the encoding of the font which is used when the parameter 'encoding' of ps_findfont() is set to 'builtin'. This usually results in a subset of all available glyphs of the font.\n\nQuite a lot of glyphs cannot be reached without the ps_symbol() function. The reason is simple: If text is output with ps_show(), then each character will be first mapped to a glyph by applying the ISO-8859-1 input encoding on it. Since ISO-8859-1 has less characters then a font usually provides glyphs, there will be some glyphs not reachable with regular text.";
Пример #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);
 }