Example #1
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 #2
0
ps_circle($psdoc, 250, 450, 80);
ps_fill($psdoc);
ps_circle($psdoc, 250, 650, 80);
ps_fill($psdoc);
ps_circle($psdoc, 450, 250, 80);
ps_fill($psdoc);
ps_circle($psdoc, 450, 450, 80);
ps_fill($psdoc);
ps_circle($psdoc, 450, 650, 80);
ps_fill($psdoc);
ps_circle($psdoc, 650, 250, 80);
ps_fill($psdoc);
ps_circle($psdoc, 650, 450, 80);
ps_fill($psdoc);
ps_circle($psdoc, 650, 650, 80);
ps_fill($psdoc);
ps_end_glyph($psdoc);
ps_add_kerning($psdoc, "one", "two", 100);
ps_add_ligature($psdoc, "one", "two", "nine");
ps_add_ligature($psdoc, "nine", "three", "zero");
ps_end_font($psdoc);
ps_begin_page($psdoc, 596, 842);
ps_setfont($psdoc, $myfont, 80.0);
ps_show_xy($psdoc, "123456", 80, 700);
ps_setfont($psdoc, $myfont, 60.0);
ps_show_xy($psdoc, "12345678", 80, 600);
ps_setfont($psdoc, $myfont, 40.0);
ps_show_xy($psdoc, "1234567890", 80, 500);
ps_setfont($psdoc, $myfont, 20.0);
ps_show_xy($psdoc, "1234567890", 80, 400);
ps_setfont($psdoc, $myfont, 10.0);
Example #3
0
<?php

define("LEFT_BORDER", 50);
function footer($ps, $text)
{
    $psfont = ps_findfont($ps, "Helvetica", "", 0);
    ps_setfont($ps, $psfont, 8.0);
    $buffer = "This file has been created with pslib " . ps_get_parameter($ps, "dottedversion", 0.0);
    ps_show_xy($ps, $buffer, LEFT_BORDER, 25);
}
$ps = ps_new();
if (!ps_open_file($ps, "overprint.ps")) {
    print "Cannot open PostScript file\n";
    exit;
}
ps_set_info($ps, "Creator", "draw.php");
ps_set_info($ps, "Author", "Uwe Steinmann");
ps_set_info($ps, "Title", "Overprint");
ps_begin_page($ps, 596, 842);
footer($ps, "");
ps_setcolor($ps, "fill", "cmyk", 1.0, 0.0, 0.0, 0.0);
ps_rect($ps, 100, 100, 200, 200);
ps_fill($ps);
ps_setoverprintmode($ps, 1);
ps_rect($ps, 120, 120, 100, 100);
ps_fill($ps);
ps_end_page($ps);
ps_close($ps);
ps_delete($ps);
Example #4
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);
 }