Postscript clipping box, why a line when not stroked

Hello All, I have a Postscript calendar program which I use to print out a calendar I can put up on a wall for planning purposes. From what I have seen, a clipping box should not "appear", but it does with the following code. For the interested, I can email the main calendar code as well, but not included here for brevity. There are two routines, callmonth and calendar defined prior in the one file. If you have other suggestions, I will read with interest, it is all a learning exercise, but with a practical useful result. --begin code-- % Set margins and working area /leftmargin 20 def /botmargin 20 def /pagewidth 555 def /pageheight 802 def newpath % box for clipping path leftmargin botmargin moveto 0 pageheight rlineto pagewidth 0 rlineto 0 pageheight neg rlineto closepath clip 1 1 12 { /callmonth exch def 0 1 1 { gsave pagewidth mul neg 0 translate 1.95 2 scale callmonth 2014 calendar gsave showpage grestore grestore } for } for --end code-- Regards, Mark Trickett

On 10/03/14 12:31, Mark Trickett wrote: ...
newpath % box for clipping path leftmargin botmargin moveto 0 pageheight rlineto pagewidth 0 rlineto 0 pageheight neg rlineto closepath clip
Does inserting a newpath after "clip" make any difference?
1 1 12 { /callmonth exch def 0 1 1 { gsave pagewidth mul neg 0 translate 1.95 2 scale callmonth 2014 calendar gsave showpage grestore grestore } for } for
--end code--

On Mon, Mar 10, 2014 at 12:31:30PM +1100, Mark Trickett wrote:
I have a Postscript calendar program which I use to print out a calendar I can put up on a wall for planning purposes. From what I have seen, a clipping box should not "appear", but it does with the following code. For the interested, I can email the main calendar code as well, but not included here for brevity. There are two routines, callmonth and calendar defined prior in the one file. If you have other suggestions, I will read with interest, it is all a learning exercise, but with a practical useful result.
your clip code seems to work ok for me. what is inside the clip boundaries should appear and the rest shouldn't. your margin coordinates setup the clip region to be almost the whole page, so you should be drawing everywhere except a 20pt ~= 0.7cm blank white boundary. that's what happens when I add your clip code as a fn to a .ps file of mine and look at it in evince (+/- evince using Letter for some reason instead of A4). I don't get a line drawn around the clip path. BTW, my postscript is very rusty, but if you previously define a "callmonth" fn then isn't it being overridden by an int (1 to 12) in this line /callmonth exch def ? maybe the rest of the code and a description of what you are trying to achieve would be helpful from here. I'm guessing you're doing a 1 year calendar with each month spread over 2 A4 portrait pages - 24 pages total? I haven't written multi-page PS programs before - are there '%' directives that are needed to make viewers/printers happy? evince just displays the last page of 24 with the simple header I gave your code :-/ ghostscript sees 24 pages though. cheers, robin -- % /l{lineto}def/s{scale}def/m{moveto}def/a{1 arcto 4 2 roll pop pop m}def/c{0 360 arc}def/C{c fill}def/S{stroke}def 10 8 s 10 30 5 c S 21 30 5 c S 12 28 2 C 19 28 2 C 15 22 1 C 1 0.3 s 9 30 4 C 21 30 4 C 1 3.5 s 6 6 1 C 9 6 1 C 12 6 1 C 18 6 1 C 21 6 1 C 24 6 1 C 1 23 m 6 22 l 1 21 m 6 21 l 2 20 m 6 21 l 31 23 m 25 23 l 30 22 m 26 22 l 30 20 m 25 21 l 9 38 m 11 42 l 13 38 l 17 38 m 20 42 l 22 37 l 9 19 m 10 18 10 17 a 11 17 12 18 a 12 18 14 17 a 14 17 16 18 a 16 18 20 18 a 20 18 l 30 15 m 35 17 33 35 43 38 curveto 35 35 38 13 31 12 curveto S showpage
--begin code--
% Set margins and working area
/leftmargin 20 def /botmargin 20 def /pagewidth 555 def /pageheight 802 def
newpath % box for clipping path leftmargin botmargin moveto 0 pageheight rlineto pagewidth 0 rlineto 0 pageheight neg rlineto closepath clip
1 1 12 { /callmonth exch def 0 1 1 { gsave pagewidth mul neg 0 translate 1.95 2 scale callmonth 2014 calendar gsave showpage grestore grestore } for } for
--end code--

Hello All, Responding to a couple of responses from Robin, but with information for all. On Sat, 2014-03-15 at 11:12 -0400, Robin Humble wrote:
On Mon, Mar 10, 2014 at 12:31:30PM +1100, Mark Trickett wrote:
I have a Postscript calendar program which I use to print out a calendar I can put up on a wall for planning purposes. From what I have seen, a clipping box should not "appear", but it does with the following code. For the interested, I can email the main calendar code as well, but not included here for brevity. There are two routines, callmonth and calendar defined prior in the one file. If you have other suggestions, I will read with interest, it is all a learning exercise, but with a practical useful result.
your clip code seems to work ok for me. what is inside the clip boundaries should appear and the rest shouldn't. your margin coordinates setup the clip region to be almost the whole page, so you should be drawing everywhere except a 20pt ~= 0.7cm blank white boundary. that's what happens when I add your clip code as a fn to a .ps file of mine and look at it in evince (+/- evince using Letter for some reason instead of A4). I don't get a line drawn around the clip path.
I wished to use the printable page, or at least most of that, and have the printed pages being joined after printing. It does require trimming or folding one of the sheets. I wanted there to be no duplication so that the abutment is more apparent to certain parties, and easier to join given that it is not possible to print right to the edge of the paper, at least on my printers. What worked to remove the line of the clipping box was adding a newpath operator following the clip operator. The subsequent parts "stroked" various lines and "show" was invoked on text, which meant that the clipping box was also "stroked", but with the outer half of the line clipped, with the resulting line looking to be half width. There were reasons that it was appropriate that the clipping was not a function, this time. A brief comment for Robin, the variant you emailed back, the invocation of the clipping function was commented out, that is what the "%" does in Postscript.
BTW, my postscript is very rusty, but if you previously define a "callmonth" fn then isn't it being overridden by an int (1 to 12) in this line /callmonth exch def ?
This provides me with retention of the loop counter for multiple uses, which would be consumed from the stack without this. I use it twice.
maybe the rest of the code and a description of what you are trying to achieve would be helpful from here. I'm guessing you're doing a 1 year calendar with each month spread over 2 A4 portrait pages - 24 pages total?
I haven't written multi-page PS programs before - are there '%' directives that are needed to make viewers/printers happy? evince just displays the last page of 24 with the simple header I gave your code :-/ ghostscript sees 24 pages though.
Yes, evince will run the whole thing without pause, while ghostscript will pause at each showpage. When I find suitable tutorial materials, and the time to study, I wish to learn about the various directives, usually prefaced with two percent symbols.
cheers, robin
Regards, Mark Trickett

Hello All, Responding to a couple of responses from Robin, but with information for all. On Sat, 2014-03-15 at 11:12 -0400, Robin Humble wrote:
On Mon, Mar 10, 2014 at 12:31:30PM +1100, Mark Trickett wrote:
I have a Postscript calendar program which I use to print out a calendar I can put up on a wall for planning purposes. From what I have seen, a clipping box should not "appear", but it does with the following code. For the interested, I can email the main calendar code as well, but not included here for brevity. There are two routines, callmonth and calendar defined prior in the one file. If you have other suggestions, I will read with interest, it is all a learning exercise, but with a practical useful result.
your clip code seems to work ok for me. what is inside the clip boundaries should appear and the rest shouldn't. your margin coordinates setup the clip region to be almost the whole page, so you should be drawing everywhere except a 20pt ~= 0.7cm blank white boundary. that's what happens when I add your clip code as a fn to a .ps file of mine and look at it in evince (+/- evince using Letter for some reason instead of A4). I don't get a line drawn around the clip path.
I wished to use the printable page, or at least most of that, and have the printed pages being joined after printing. It does require trimming or folding one of the sheets. I wanted there to be no duplication so that the abutment is more apparent to certain parties, and easier to join given that it is not possible to print right to the edge of the paper, at least on my printers. What worked to remove the line of the clipping box was adding a newpath operator following the clip operator. The subsequent parts "stroked" various lines and "show" was invoked on text, which meant that the clipping box was also "stroked", but with the outer half of the line clipped, with the resulting line looking to be half width. There were reasons that it was appropriate that the clipping was not a function, this time. A brief comment for Robin, the variant you emailed back, the invocation of the clipping function was commented out, that is what the "%" does in Postscript.
BTW, my postscript is very rusty, but if you previously define a "callmonth" fn then isn't it being overridden by an int (1 to 12) in this line /callmonth exch def ?
This provides me with retention of the loop counter for multiple uses, which would be consumed from the stack without this. I use it twice.
maybe the rest of the code and a description of what you are trying to achieve would be helpful from here. I'm guessing you're doing a 1 year calendar with each month spread over 2 A4 portrait pages - 24 pages total?
I haven't written multi-page PS programs before - are there '%' directives that are needed to make viewers/printers happy? evince just displays the last page of 24 with the simple header I gave your code :-/ ghostscript sees 24 pages though.
Yes, evince will run the whole thing without pause, while ghostscript will pause at each showpage. When I find suitable tutorial materials, and the time to study, I wish to learn about the various directives, usually prefaced with two percent symbols.
cheers, robin
Regards, Mark Trickett

On 23/03/14 18:54, Mark Trickett wrote:
Hello All,
Responding to a couple of responses from Robin, but with information for all. ... What worked to remove the line of the clipping box was adding a newpath operator following the clip operator. The subsequent parts "stroked"
The reason that I suggested using newpath was not my great insight into postscript but just a reading of the Adobe reference manual re clip, which ends: "Unlike fill and stroke, clip does not implicitly perform newpath after it has finished using the current path. Any subsequent path construction operators will append to the current path unless newpath is executed explicitly. This can cause unexpected behaviour." It's just postscript going on its usual obscure way.
participants (4)
-
Allan Duncan
-
Mark Trickett
-
Mark Trickett
-
Robin Humble