[pstricks] grid as background in an environment
Martin Buchmann
Martin_Buchmann at gmx.net
Thu Oct 9 19:04:55 CEST 2003
Herbert,
>draw the grid by yourself.
Well, that's a good idea! I never thought of that but in your
approach i have to give the number of lines. I would prefer to set
the distance between the lines, let's say 0.5cm in each direction for
a square grid and then calculate the number of grid lines in each
direction.
Something like this:
\makeatletter
\newcommand\grid[2]{{%
\newdimen\xMax \xMax=#2%
\newdimen\yMax \yMax=#1%
\newcount\xLines
\newcount\yLines
\newdimen\dx \dx=0.5cm \xLines=\xMax \divide\xLines by \dx%
\newdimen\dy \dy=0.5cm \yLines=\yMax \divide\yLines by \dy%
\psset{unit=1pt, linecolor=yellow}%
\advance\xLines by 1%
\advance\yLines by 1%
\yMax=\dy \multiply\yMax by \yLines
\xMax=\dx \multiply\xMax by \xLines
\advance\xLines by 1%
\advance\yLines by 1%
\multido{\rA=0+\strip at pt\dx}{\xLines}{\psline(\rA,0)(\rA,\yMax)}%
\multido{\rA=0+\strip at pt\dy}{\yLines}{\psline(0,\rA)(\xMax,\rA)}%
}}
\makeatother
I'm not sure if this is really bug free. I never did arithmetics in
TeX beforebut it is working for my minimal example.
Thanks
Martin
--
Psychiatrists say that 1 of 4 people are mentally ill.
Check 3 friends. If they're OK, you're it.
More information about the PSTricks
mailing list