object-like behaviour in tikz-pgf

View: New views
3 Messages — Rating Filter:   Alert me  

object-like behaviour in tikz-pgf

by kib2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

How can we make an object in tikz-pgf ?
It's easily done in PostScript or SVG, but I had a look at the manual and found nothing about it.

ie suppose and wanted to build a new object "labeled_square" composed of a square with four labels, then manipulate it later with geometrical transformations : is such a behaviour implemented ?

Thanks.

Re: object-like behaviour in tikz-pgf

by Till Tantau-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

this is such a common request that perhaps it might be a good idea to  
add something in the manual concering this.

No, there is no special tikz command for defining objects. Actually,  
there is a system-layer command for this, but that is not intended for  
direct use.

The idea is that objects can be defined using TeX-macros, so that  
there is no need for a special command. For the labeled_square  
example, try this:

\begin{tikzpicture}

   \def\labeledsquare{
     \draw (0,0) node [below left] {lower left}
       -- (1,0) node [below right] {below right}
       -- (1,1) node [above right] {foo}
       -- (0,1) node [above left] {bar}
       -- cycle;
   }

   \draw ...;
   \labeledsquare % shows a square
   \begin{scope}[xshift=5cm]
     \labeledsquare % another
   \end{scope}
   \begin{scope}[yshift=5cm]
     \labeledsquare % yet another
   \end{scope}

\end{tikzpicture}


However, I admit that it *might* be a good idea to write some library  
that makes code such as the above simpler.


Hoping this helps,
Till


Am 20.07.2008 um 17:02 schrieb kib2:

>
> Hi,
>
> How can we make an object in tikz-pgf ?
> It's easily done in PostScript or SVG, but I had a look at the  
> manual and
> found nothing about it.
>
> ie suppose and wanted to build a new object "labeled_square"  
> composed of a
> square with four labels, then manipulate it later with geometrical
> transformations : is such a behaviour implemented ?
>
> Thanks.
> --
> View this message in context: http://www.nabble.com/object-like-behaviour-in-tikz-pgf-tp18555263p18555263.html
> Sent from the pgf-users mailing list archive at Nabble.com.
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's  
> challenge
> Build the coolest Linux based applications with Moblin SDK & win  
> great prizes
> Grand prize is a trip for two to an Open Source event anywhere in  
> the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> pgf-users mailing list
> pgf-users@...
> https://lists.sourceforge.net/lists/listinfo/pgf-users
>

--
Prof. Dr. Till Tantau <tantau@...>
www.tcs.uni-luebeck.de/mitarbeiter/tantau


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: object-like behaviour in tikz-pgf

by kib2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the answer Till Tantau,
in fact that was exactly what I was looking for.

It could be a good idea to put some lines about this in the official manual.
I wasn't aware that I can use TeX macros for this, but I would certainly prefer a special library for that.

Cheers.
LightInTheBox - Buy quality products at wholesale price