ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* scaling reusableMPgraphic & some ConTeXt programming
@ 2006-07-23  6:14 Mojca Miklavec
  2006-07-24  9:03 ` Taco Hoekwater
  2006-07-24  9:03 ` Hans Hagen
  0 siblings, 2 replies; 7+ messages in thread
From: Mojca Miklavec @ 2006-07-23  6:14 UTC (permalink / raw)


Hello,

the answers to these three questions are most probably one-liners, but
I don't know which ones ;)

1. How can I scale (an already defined) reusableMPgraphic? Simplified
example of what I currently (want to) have:

% how should I change this definition?
\def\usemygraphic[#1][#2]{\reuseMPgraphic{#1}}
\usemygraphic[name][width=.7\textwidth]


2. I have several graphics defined as

\startGNUPLOTgraphic[1][name]
	draw fullcircle scaled 3cm withcolor .625red;
\stopGNUPLOTgraphic
\startGNUPLOTgraphic[2][name]
	draw fullcircle scaled 3cm withcolor .625green;
\stopGNUPLOTgraphic
\startGNUPLOTgraphic[3][name]
	draw fullcircle scaled 3cm withcolor .625blue;
\stopGNUPLOTgraphic

\startGNUPLOTgraphic[1][othername]
	fill fullcircle scaled 3cm withcolor .625red;
\stopGNUPLOTgraphic
\startGNUPLOTgraphic[2][othername]
	fill fullcircle scaled 3cm withcolor .625green;
\stopGNUPLOTgraphic

and a pretty stupid definition:

\long\def\startGNUPLOTgraphic
	{\dodoubleargument\dostartGNUPLOTgraphic}

\long\def\dostartGNUPLOTgraphic[#1][#2]#3\stopGNUPLOTgraphic % [number][name]
	{% add to counter to note the nuber of the graphic
         % define a new counter for the first time when you use it
	 \doif{#1}{1}{\doglobal\newcounter\abc}% counter name has to depend on #2
	 \doglobal\increment\abc % assigning the value #1 to it would also be OK
	 \startreusableMPgraphic{gpg:#2:#1}#3\stopreusableMPgraphic}

How can I give a better name than \abc to the counter (the name should
depend on #2 in order to be unique)?


3. I would like to change \usemygraphic, so that
\usemygraphic[othername] or \usemygraphic[othername][height=5cm] would
resolve to
    \dorecurse{2}{\useMPgraphic{gpg:othername:\recurselevel}}
and \usemygraphic[name][n={1,3},width=8cm] (syntax might be different
if necessary) to
    \reuseMPgraphic{gpg:name:1}
    \reuseMPgraphic{gpg:name:3}
(with proper scaling if possible).

How should I start?

Thank you a lot for any hints,
    Mojca Miklavec

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scaling reusableMPgraphic & some ConTeXt programming
  2006-07-23  6:14 scaling reusableMPgraphic & some ConTeXt programming Mojca Miklavec
@ 2006-07-24  9:03 ` Taco Hoekwater
  2006-07-24  9:03 ` Hans Hagen
  1 sibling, 0 replies; 7+ messages in thread
From: Taco Hoekwater @ 2006-07-24  9:03 UTC (permalink / raw)




Mojca Miklavec wrote:
> Hello,
> 
> the answers to these three questions are most probably one-liners, but
> I don't know which ones ;)
> 
> 1. How can I scale (an already defined) reusableMPgraphic? Simplified
> example of what I currently (want to) have:
> 
> % how should I change this definition?
> \def\usemygraphic[#1][#2]{\reuseMPgraphic{#1}}
> \usemygraphic[name][width=.7\textwidth]

Guessing:

   \def\usemygraphic[#1][#2]{\scaled[#2]{\reuseMPgraphic{#1}}}

> 
> 2. I have several graphics defined as
 > ....
> How can I give a better name than \abc to the counter (the name should
> depend on #2 in order to be unique)?

Better use \definenumber instead of the low-level command.

> 
> 3. I would like to change \usemygraphic, so that
> \usemygraphic[othername] or \usemygraphic[othername][height=5cm] would
> resolve to
>     \dorecurse{2}{\useMPgraphic{gpg:othername:\recurselevel}}

Where does this '2' come from?

> and \usemygraphic[name][n={1,3},width=8cm] (syntax might be different
> if necessary) to
>     \reuseMPgraphic{gpg:name:1}
>     \reuseMPgraphic{gpg:name:3}
> (with proper scaling if possible).
> 
> How should I start?

Create a commalist of desired numbers first (possibly using recursion),
then run \processcommalist on each item.

Cheers, Taco

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scaling reusableMPgraphic & some ConTeXt programming
  2006-07-23  6:14 scaling reusableMPgraphic & some ConTeXt programming Mojca Miklavec
  2006-07-24  9:03 ` Taco Hoekwater
@ 2006-07-24  9:03 ` Hans Hagen
  2006-07-25 13:55   ` Mojca Miklavec
  1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2006-07-24  9:03 UTC (permalink / raw)


Mojca Miklavec wrote:
> Hello,
>
> the answers to these three questions are most probably one-liners, but
> I don't know which ones ;)
>
> 1. How can I scale (an already defined) reusableMPgraphic? Simplified
> example of what I currently (want to) have:
>
> % how should I change this definition?
> \def\usemygraphic[#1][#2]{\reuseMPgraphic{#1}}
> \usemygraphic[name][width=.7\textwidth]
>   
\def\usemygraphic[#1][#2]{\scale[#2]{\reuseMPgraphic{#1}}

\usempgraphic[name][width=4cm,height=5cm]

\scale accepts the same scaling options as externalfigure

>
> 2. I have several graphics defined as
>
> \startGNUPLOTgraphic[1][name]
> 	draw fullcircle scaled 3cm withcolor .625red;
> \stopGNUPLOTgraphic
> \startGNUPLOTgraphic[2][name]
> 	draw fullcircle scaled 3cm withcolor .625green;
> \stopGNUPLOTgraphic
> \startGNUPLOTgraphic[3][name]
> 	draw fullcircle scaled 3cm withcolor .625blue;
> \stopGNUPLOTgraphic
>
> \startGNUPLOTgraphic[1][othername]
> 	fill fullcircle scaled 3cm withcolor .625red;
> \stopGNUPLOTgraphic
> \startGNUPLOTgraphic[2][othername]
> 	fill fullcircle scaled 3cm withcolor .625green;
> \stopGNUPLOTgraphic
>
> and a pretty stupid definition:
>
> \long\def\startGNUPLOTgraphic
> 	{\dodoubleargument\dostartGNUPLOTgraphic}
>
> \long\def\dostartGNUPLOTgraphic[#1][#2]#3\stopGNUPLOTgraphic % [number][name]
> 	{% add to counter to note the nuber of the graphic
>          % define a new counter for the first time when you use it
> 	 \doif{#1}{1}{\doglobal\newcounter\abc}% counter name has to depend on #2
> 	 \doglobal\increment\abc % assigning the value #1 to it would also be OK
> 	 \startreusableMPgraphic{gpg:#2:#1}#3\stopreusableMPgraphic}
>
> How can I give a better name than \abc to the counter (the name should
> depend on #2 in order to be unique)?
>   
why do you need a counter

\long\def\dostartGNUPLOTgraphic[#1][#2]#3\stopGNUPLOTgraphic
  {\startreusableMPgraphic{gpg:#2:#1}#3\stopreusableMPgraphic}


>
> 3. I would like to change \usemygraphic, so that
> \usemygraphic[othername] or \usemygraphic[othername][height=5cm] would
> resolve to
>     \dorecurse{2}{\useMPgraphic{gpg:othername:\recurselevel}}
> and \usemygraphic[name][n={1,3},width=8cm] (syntax might be different
> if necessary) to
>     \reuseMPgraphic{gpg:name:1}
>     \reuseMPgraphic{gpg:name:3}
> (with proper scaling if possible).
>   
you want all graphics?

\def\usemygraphic#1%
  {\doloop
     {\doifMPgraphicelse{gpg:#1:\recurselevel}
        {\reuseMPgraphic{gpg:name:\recurselevel}}
        {\exitloop}}} 

or so ... 


Hans 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scaling reusableMPgraphic & some ConTeXt programming
  2006-07-24  9:03 ` Hans Hagen
@ 2006-07-25 13:55   ` Mojca Miklavec
  2006-07-25 21:51     ` Hans Hagen
  2006-07-25 21:52     ` Hans Hagen
  0 siblings, 2 replies; 7+ messages in thread
From: Mojca Miklavec @ 2006-07-25 13:55 UTC (permalink / raw)


On 7/24/06, Hans Hagen wrote:
> Mojca Miklavec wrote:
> > Hello,
> >
> > the answers to these three questions are most probably one-liners, but
> > I don't know which ones ;)
> >
> > 1. How can I scale (an already defined) reusableMPgraphic? Simplified
> > example of what I currently (want to) have:
> >
> > % how should I change this definition?
> > \def\usemygraphic[#1][#2]{\reuseMPgraphic{#1}}
> > \usemygraphic[name][width=.7\textwidth]
> >
> \def\usemygraphic[#1][#2]{\scale[#2]{\reuseMPgraphic{#1}}
>
> \usempgraphic[name][width=4cm,height=5cm]
>
> \scale accepts the same scaling options as externalfigure

Thanks to both you and Taco!

> why do you need a counter

> > 3. I would like to change \usemygraphic, so that
> > \usemygraphic[othername] or \usemygraphic[othername][height=5cm] would
> > resolve to
> >     \dorecurse{2}{\useMPgraphic{gpg:othername:\recurselevel}}
> > and \usemygraphic[name][n={1,3},width=8cm] (syntax might be different
> > if necessary) to
> >     \reuseMPgraphic{gpg:name:1}
> >     \reuseMPgraphic{gpg:name:3}
> > (with proper scaling if possible).
> >
> you want all graphics?
>
> \def\usemygraphic#1%
>   {\doloop
>      {\doifMPgraphicelse{gpg:#1:\recurselevel}
>         {\reuseMPgraphic{gpg:name:\recurselevel}}
>         {\exitloop}}}
>
> or so ...

Wow! No, I don't need a counter in that case ;)

Just a little detail: Yes, I want all the graphics except if the user
provides "n={1,3}" or "n=4", then I would like to output only the ones
specified. I know that this is a trivial question, but how do I
extract the argument of "n=..." to \processcommalist on it?

And yet another short&stupid question: when does \c!something=\v!value
work? I tried to change \setupGNUPLOT[terminal=context] into
[\c!terminal=\v!context] (in \unprotect-ed area), but I get a
command-undefined error.

Thanks,
    Mojca

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scaling reusableMPgraphic & some ConTeXt programming
  2006-07-25 13:55   ` Mojca Miklavec
@ 2006-07-25 21:51     ` Hans Hagen
  2006-07-25 21:52     ` Hans Hagen
  1 sibling, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2006-07-25 21:51 UTC (permalink / raw)


Mojca Miklavec wrote:
> On 7/24/06, Hans Hagen wrote:
>   
>> Mojca Miklavec wrote:
>>     
>>> Hello,
>>>
>>> the answers to these three questions are most probably one-liners, but
>>> I don't know which ones ;)
>>>
>>> 1. How can I scale (an already defined) reusableMPgraphic? Simplified
>>> example of what I currently (want to) have:
>>>
>>> % how should I change this definition?
>>> \def\usemygraphic[#1][#2]{\reuseMPgraphic{#1}}
>>> \usemygraphic[name][width=.7\textwidth]
>>>
>>>       
>> \def\usemygraphic[#1][#2]{\scale[#2]{\reuseMPgraphic{#1}}
>>
>> \usempgraphic[name][width=4cm,height=5cm]
>>
>> \scale accepts the same scaling options as externalfigure
>>     
>
> Thanks to both you and Taco!
>
>   
>> why do you need a counter
>>     
>
>   
>>> 3. I would like to change \usemygraphic, so that
>>> \usemygraphic[othername] or \usemygraphic[othername][height=5cm] would
>>> resolve to
>>>     \dorecurse{2}{\useMPgraphic{gpg:othername:\recurselevel}}
>>> and \usemygraphic[name][n={1,3},width=8cm] (syntax might be different
>>> if necessary) to
>>>     \reuseMPgraphic{gpg:name:1}
>>>     \reuseMPgraphic{gpg:name:3}
>>> (with proper scaling if possible).
>>>
>>>       
>> you want all graphics?
>>
>> \def\usemygraphic#1%
>>   {\doloop
>>      {\doifMPgraphicelse{gpg:#1:\recurselevel}
>>         {\reuseMPgraphic{gpg:name:\recurselevel}}
>>         {\exitloop}}}
>>
>> or so ...
>>     
>
> Wow! No, I don't need a counter in that case ;)
>
> Just a little detail: Yes, I want all the graphics except if the user
> provides "n={1,3}" or "n=4", then I would like to output only the ones
> specified. I know that this is a trivial question, but how do I
> extract the argument of "n=..." to \processcommalist on it?
>   
depends on how you store it (say in requestedlist), anyhow testing is simple



\def\usemygraphic#1%
  {\doloop
     {\doifMPgraphicelse{gpg:#1:\recurselevel}
        {\expanded{\doifinset{\recurselevel}{requestedlist}}{\reuseMPgraphic{gpg:name:\recurselevel}}}
        {\exitloop}}}


or so

> And yet another short&stupid question: when does \c!something=\v!value
> work? I tried to change \setupGNUPLOT[terminal=context] into
> [\c!terminal=\v!context] (in \unprotect-ed area), but I get a
> command-undefined error.
>
> Thanks,
>     Mojca
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>   


-- 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scaling reusableMPgraphic & some ConTeXt programming
  2006-07-25 13:55   ` Mojca Miklavec
  2006-07-25 21:51     ` Hans Hagen
@ 2006-07-25 21:52     ` Hans Hagen
  2006-07-26  7:58       ` Mojca Miklavec
  1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2006-07-25 21:52 UTC (permalink / raw)


Mojca Miklavec wrote:
> And yet another short&stupid question: when does \c!something=\v!value
> work? I tried to change \setupGNUPLOT[terminal=context] into
> [\c!terminal=\v!context] (in \unprotect-ed area), but I get a
> command-undefined error.
>   
only predefined key/values (in mult-con) are stored in their efficient ! form (and get translated when needed) 

Hans 


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scaling reusableMPgraphic & some ConTeXt programming
  2006-07-25 21:52     ` Hans Hagen
@ 2006-07-26  7:58       ` Mojca Miklavec
  0 siblings, 0 replies; 7+ messages in thread
From: Mojca Miklavec @ 2006-07-26  7:58 UTC (permalink / raw)


On 7/25/06, Hans Hagen wrote:
> Mojca Miklavec wrote:
> > And yet another short&stupid question: when does \c!something=\v!value
> > work? I tried to change \setupGNUPLOT[terminal=context] into
> > [\c!terminal=\v!context] (in \unprotect-ed area), but I get a
> > command-undefined error.
> >
> only predefined key/values (in mult-con) are stored in their efficient ! form (and get translated when needed)

Thanks. I never understood what
    \def\c!first     {first}
    \def\c!last      {last}
    \def\c!quotechar {quotechar}
was doing in m-database.

Mojca

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-07-26  7:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-23  6:14 scaling reusableMPgraphic & some ConTeXt programming Mojca Miklavec
2006-07-24  9:03 ` Taco Hoekwater
2006-07-24  9:03 ` Hans Hagen
2006-07-25 13:55   ` Mojca Miklavec
2006-07-25 21:51     ` Hans Hagen
2006-07-25 21:52     ` Hans Hagen
2006-07-26  7:58       ` Mojca Miklavec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).