• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Code draws odd rectangle (probably simple solution).

New Here ,
Nov 10, 2009 Nov 10, 2009

Copy link to clipboard

Copied

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

TOPICS
Programming

Views

416

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 10, 2009 Nov 10, 2009

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines