[OS X TeX] [External] creating a ps object

Herbert Voss Herbert.Voss at fu-berlin.de
Sat Jun 14 04:13:08 EDT 2025



Am 13.06.25 um 23:47 schrieb Nitecki, Zbigniew H.:
>
> First,  consider the following example of a single (3cm x 3cm) “tile”:
>

...
>
>
> *Question 1: * If I want to create a (9cm x 9cm) square which is tiled 
> as a 3x3 array of copies of this tile,
> one way is to do so is to write

% !TEX TS-program = lualatex
\DocumentMetadata{}
\documentclass{article}
\usepackage{pstricks}
\usepackage{multido}

\def\Img{%
     \begin{pspicture}[unit=3cm](0,0)(1,1)
         \psframe[fillcolor=green, fillstyle=solid](0.02,0.02)(0.98,0.98)
         \psline[linecolor=black, linestyle=dashed, linewidth=1.5pt]{<-}%
         (0.16,0.16)(0.16, 0.84)(0.5,0.84)(0.5,0.16)(0.84,0.16)(0.84,0.84)
     \end{pspicture}}

\begin{document}

\begin{pspicture}[unit=3cm](3,3)
\multido{\iX=0+1}{3}{%
   \multido{\iY=0+1}{3}{%
     \rput[lb](\iX,\iY){\Img}}}
\end{pspicture}

\end{document}


You can modify the \Img macro to pass arguments for the scaling,
coordinates of the poygin, the color, whatever ...

\def\Img#1#2#3 ...

Herbert




>
> *Question 2:* Suppose instead I have several (say3) other /variants/ 
> of this tile, all in the same formal, and differing
> in color (say, red, blue and yellow in place of green as well as the 
> exact nature of the \psline in the original
> (ie, differing in the coordinates of the “turning points” of the 
> curve, given by changing the coordinates in the
> fourth line of the content above.
> Suppose I want to create a 3x3 array using these four variants, 
> arranged according to some pattern—for example,
> the variant used depends on the parity of their position witin the array.
> Again, this can be done by hand, writing out nine variants of the four 
> lines above.
> Or, if there is a good answer to question 1, we could write four 
> variants of our oriiginal tile, and use four different
> multirput commands to create the array.
> But can it be done by creating a singlen template as imagined in 
> question 1, but using parameters for the color and the curve (or the 
> coordinates of the turning points of the curve) and applying several 
> multirput commands?
>
> *Question 3:* Suppose I want to fill a 9cm x 9cm square whith a _9x9 
> array _ of these various tiles (again with some
> principle underlyng the choice of variant in each given spot). 
>  Writing out 81 versions of the four lines above, together with 
> rescaling the descriptions, is not only tedious but also forbiddingly 
> error-prone.
> Is it possible to insert a sizing parameter in addition to those 
> imagined in Question 2 and then use 4 multirput commands on this?
>
> I think it could be done with the kind of language in your example, 
> but is it possible to do this pretty much inside
> the PsTricks umbrella?
>
> Any exgra ideas would be very welcome here!
>
> Thanks
>
> ZN
>
>
>
> Zbigniew Nitecki
> Professor Emeritus
> Department of Mathematics
> Tufts University
> Medford, MA 02155
>
> telephones:
> Dept.(617)627-3234
> Dept. fax(617)627-3966
> http://www.tufts.edu/~znitecki/
>
>
>> On Jun 12, 2025, at 05:34, Herbert Voss <Herbert.Voss at fu-berlin.de> 
>> wrote:
>>
>>
>>
>> Am 11.06.25 um 22:00 schrieb Nitecki, Zbigniew H.:
>>> I want to tile a large rectangular area with tiles.  All the tiles are
>>> (congruent) squares filled with a specific color and with some curves
>>> drawn on them.  They come in more than one variety, but there are
>>> enough of each variety that
>>> I want to create  “tile” templates (for thesevarieties, with color and
>>> the specific curve defined by parameters)
>>> and use multirput to do the tiling.
>>>
>>> I’m looking for a way to define a graphical object which is
>>> self-contained, perhaps with a few parameters that
>>> need to be filled in, which can then be treated like other
>>> system-defined objects (e.g. pscircles, pslines)—specifically which
>>> can be rput anywhere in a larger picture, with some internal
>>> coordinates which get treated
>>> as relative coordinates.  I thought \newpsobject could work, but that
>>> is only for adding bells and whistles to
>>> already defined objects.
>>>
>>> Any suggestons?
>>
>> Here comes a starter ...
>>
>> Herbert
>>
>> \documentclass{article}
>> \usepackage{pstricks,pst-plot}
>>
>> \makeatletter
>> \def\foo{\@ifnextchar[\foo at i{\foo at i[]}}
>> \def\foo at i[#1]#2#3#4{%
>>  \begingroup
>>  \if$#1$\else\psset{#1}\fi
>>  \psframebox{%
>>      \begin{pspicture}(-2.25,-2.5)(2.25,2.5)
>>       \rput(0,2.25){\textbf{#2}}
>>       \rput(0,0){%
>>          \begin{pspicture*}(-2,-2)(2,2)
>>            \psgrid(0,0)(-2,-2)(2,2)
>>          #3
>>    \end{pspicture*}}%
>>    \rput(0,-2.25){#4}
>>      \end{pspicture}}
>>  \endgroup
>> }
>>
>> \begin{document}
>>
>> \foo{Demo 1}%
>>    {\psplot[linewidth=1.5pt,algebraic]{-1.5}{1.5}{x^2}}%
>>    {A quadratic function}
>> \foo{Demo 2}%
>> {\psplot[linewidth=1.25pt,linecolor=red,algebraic]{-1.5}{1.5}{x^3}}%
>>    {A cubicic function}
>>
>> \foo[unit=1.5]{Demo 3}%
>>  {\psline[linewidth=2pt,linestyle=dashed](-2,-2)(2,2)}%
>>  {A dashed line}
>> \end{document}
>>
>> Caution: This message originated from outside of the Tufts University 
>> organization. Please exercise caution when clicking links or opening 
>> attachments. When in doubt, email the TTS Service Desk at 
>> it at tufts.edu<mailto:it at tufts.edu> or call them directly at 617-627-3376.
>>
>> Bildschirmfoto 2025-06-12 um 11.32.34.png----------- Please Consult 
>> the Following Before Posting -----------
>> TeX FAQ: https://www.tug.org/mactex/faq/index.html
>> List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/TeX/
>> List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
>>                https://email.esm.psu.edu/pipermail/macosx-tex/
>> TeX on Mac OS X Website: https://www.tug.org/mactex/index.html
>> List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
>
>
> ----------- Please Consult the Following Before Posting -----------
> TeX FAQ: https://www.tug.org/mactex/faq/index.html
> List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/TeX/
> List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
>                  https://email.esm.psu.edu/pipermail/macosx-tex/
> TeX on Mac OS X Website: https://www.tug.org/mactex/index.html
> List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bildschirmfoto 2025-06-14 um 10.08.14.png
Type: image/png
Size: 30042 bytes
Desc: not available
URL: <https://email.esm.psu.edu/pipermail/macosx-tex/attachments/20250614/cc8eb177/attachment.png>


More information about the MacOSX-TeX mailing list