Beispiel #1
0
$spotcolors[] = array("id" => 0, "name" => "PANTONE 5565 C", "colorspace" => "cmyk", "c1" => 0.37, "c2" => 0.0, "c3" => 0.34, "c4" => 0.34);
$spotcolors[] = array("id" => 0, "name" => "RGB Blue", "colorspace" => "rgb", "c1" => 0.0, "c2" => 0.0, "c3" => 1.0, "c4" => 0.0);
$spotcolors[] = array("id" => 0, "name" => "Gray Black", "colorspace" => "gray", "c1" => 0.0, "c2" => 0.0, "c3" => 0.0, "c4" => 0.0);
$ps = PS_new();
if (0 > PS_open_file($ps, "spotcolor.ps")) {
    printf("Cannot open PostScript file\n");
    exit(1);
}
PS_set_parameter($ps, "warning", "true");
PS_set_info($ps, "Creator", __FILE__);
PS_set_info($ps, "Author", "Uwe Steinmann");
PS_set_info($ps, "Title", "Spotcolor demonstration");
PS_set_info($ps, "Keywords", "Spot color");
for ($i = 0; $i < 5; $i++) {
    PS_setcolor($ps, "fill", $spotcolors[$i]["colorspace"], $spotcolors[$i]["c1"], $spotcolors[$i]["c2"], $spotcolors[$i]["c3"], $spotcolors[$i]["c4"]);
    $spotcolors[$i]["id"] = PS_makespotcolor($ps, $spotcolors[$i]["name"], 0);
}
PS_begin_page($ps, 596, 842);
footer($ps, "");
$psfont = PS_findfont($ps, "Helvetica", "", 0);
PS_setfont($ps, $psfont, 7.0);
for ($i = 1; $i <= 10; $i++) {
    $buffer = sprintf("%d %%", $i * 10);
    PS_show_xy($ps, $buffer, 60, 55 + $i * 65);
}
colorline($ps, 100.0, $spotcolors[0]);
colorline($ps, 190.0, $spotcolors[1]);
colorline($ps, 280.0, $spotcolors[2]);
colorline($ps, 370.0, $spotcolors[3]);
colorline($ps, 460.0, $spotcolors[4]);
PS_end_page($ps);
Beispiel #2
0
PS_clip($ps);
PS_shfill($ps, $shading5);
PS_restore($ps);
PS_end_page($ps);
/* Page 2 */
PS_begin_page($ps, 596, 842);
PS_setcolor($ps, "fill", "rgb", 1, 1, 1, 0);
$shading1 = PS_shading($ps, "radial", 100.0, 100.0, 550.0, 550.0, 0.5, 0.0, 0.0, 0.0, "N 1 r0 40 r1 795 extend1 false antialias true");
PS_setcolor($ps, "fill", "rgb", 0, 0.7, 0, 0);
$shading2 = PS_shading($ps, "radial", 50.0, 50.0, 50.0, 50.0, 1.0, 1.0, 1.0, 0.0, "N 1 r0 40 r1 0 extend1 false extend0 false antialias true");
$shading3 = PS_shading($ps, "radial", 50.0, 50.0, 50.0, 50.0, 1.0, 1.0, 1.0, 0.0, "N 1 r0 40 r1 0 extend0 true antialias true");
PS_setcolor($ps, "fill", "rgb", 0, 0, 1, 0);
$shading4 = PS_shading($ps, "radial", 50.0, 50.0, 50.0, 50.0, 1.0, 1.0, 0.0, 0.0, "N 1 r0 40 r1 0 extend0 true antialias true");
$shading5 = PS_shading($ps, "radial", 30.0, 30.0, 53.0, 53.0, 0.0, 0.0, 0.9, 0.0, "N 1 r0 20 r1 35 extend0 false extend1 false");
PS_setcolor($ps, "fill", "cmyk", 0.37, 0.0, 0.34, 0.34);
$spotcolor = PS_makespotcolor($ps, "PANTONE 5565 C", 0);
PS_setcolor($ps, "fill", "spot", (double) $spotcolor, 0.2, 0.0, 0.0);
$shading6 = PS_shading($ps, "radial", 50.0, 50.0, 50.0, 50.0, (double) $spotcolor, 0.8, 0.0, 0.0, "N 1 r0 40 r1 0 extend1 false extend0 false antialias true");
PS_shfill($ps, $shading1);
PS_setcolor($ps, "fill", "rgb", 0, 0, 0.7, 0);
PS_setfont($ps, $antiqua, 20.0);
PS_show_xy($ps, "The world of color shading", LEFT_BORDER, 763);
PS_setfont($ps, $antiqua, 10.0);
PS_set_value($ps, "leading", 15.0);
PS_show_boxed($ps, "I suppose it does not really supprise you that gradient fills can be colorful. The first example is the background of this page which is a radial gradient fill from white to red (RGB [0,0,0.7]). Its outer circle has a very large radius of 795 pixels. The inner circle's radius is just 40 pixels. If there was something behind the gradient fill it would shine through the inner circle, because the gradient fill does not extend into that direction. There is a continuation of the red color beyond the outer circle, but that does not make a difference in this case, because its outside of the page and therefore not visible.\n\nShading 1 and Shading 2 illustrate the difference of the extend1 parameter being set to false in Shading 1 or true in Shading 2. Using extend is always a bit dangerous because it easily fills up the whole page, unless you clip the drawing area, which was done in all the examples on this page.\n\nUsing white as the start or end color is quite common but not nessecary. Shading 3 shows that any other color can be used as well.\n\nThe tube in Shading 4 is a bit of a misuse of shadings. It used alsmost identical start and end colors for the shading without any extend parameter set. This only works if the two colors are not identical. If they were identical you would see just the start and circle overlapping, because the gradient function has no domain it can run over. Well, this is anyway not the way to draw tubes.\n\nYou wonder if this all works with CMYK colors? Yes, of course it does! And what about spot colors? No problem either, with one little restriction. The start and end spot color must be same one, but with different tint value. That means that the gradient just changes the tint value but not the color itself. I am not sure if this is an unbearable restriction or not. Shading 5 shows an example of Pantone 5565 C starting at a tint value of 0.2 (the outer circle) and ending with 0.8 (the middle point).", LEFT_BORDER, 170, 260, 580, "left", NULL);
PS_save($ps);
PS_translate($ps, 350, 650);
PS_show_xy($ps, "Shading 1", 0, -12);
PS_rect($ps, 0, 0, 100, 100);
PS_clip($ps);
PS_setcolor($ps, "fill", "rgb", 1, 1, 1, 0);