Skip to main content
Participant
November 10, 2009
Question

Code draws odd rectangle (probably simple solution).

  • November 10, 2009
  • 1 reply
  • 469 views

Here is something I am having trouble explaining.

What I would like to do is draw a colored rectangular box with stripes of another color at 45 degrees.  Below is the code I wrote to do this.  It does what I want, but also puts a rectangular border of the stripe color around the whole rectangle, which I do not want.

Anybody willing to look at this quickly for me?

%!

/boxH 200 def
/boxW 150 def

100 100 translate

.5 1 .5 setrgbcolor

newpath
0 0 moveto
0 boxH lineto
boxW boxH lineto
boxW 0 lineto
closepath
fill

newpath
0 0 moveto
0 boxH lineto
boxW boxH lineto
boxW 0 lineto
closepath
clip

-45 rotate

1 1 .67 setrgbcolor

boxW 6 div 2 div setlinewidth

/drawstripe {boxW 6 div mul 0 moveto 0 2 boxH mul rlineto stroke} def

-12 1 6 {drawstripe} for

showpage

This topic has been closed for replies.

1 reply

kevincsAuthor
Participant
November 10, 2009

I was missing a 'newpath' command in my /drawstripe procedure.  Yay.