ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] applying style to frame content
@ 2024-05-14  7:57 seyal.zavira
  2024-05-14 10:51 ` [NTG-context] " Wolfgang Schuster
  0 siblings, 1 reply; 2+ messages in thread
From: seyal.zavira @ 2024-05-14  7:57 UTC (permalink / raw)
  To: ntg-context

Hi all,

what is the better way to apply a metapost effect to a piece of any structure text
for example when defining footnotes, frames , etc.
i use this method for frames:

this is my MWE:
\defineframed[Myframe][frame=off]
\starttexdefinition spaces protected Mystyle #1
   \startMPcode
     picture tt ; tt:= lmt_outline [
       kind = "path",
       text = "\Myframe{#1}",
     ];
   fill
     for i within tt : pathpart i && endfor cycle
     withshademethod "linear"
     withshadedirection up
     withshadecolors (red,blue);
   \stopMPcode
\stoptexdefinition

\starttext
\Mystyle{hello}
\stoptext


but what is the proper way if i want to use this style as simple as \tfb in definition of this structures? such as:
\defineframed[Myframe][frame=off,style=\tfb\Mystyle,]

Thanks in advance.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: applying style to frame content
  2024-05-14  7:57 [NTG-context] applying style to frame content seyal.zavira
@ 2024-05-14 10:51 ` Wolfgang Schuster
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Schuster @ 2024-05-14 10:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users, seyal.zavira

seyal.zavira@gmail.com schrieb am 14.05.2024 um 09:57:
> Hi all,
> 
> what is the better way to apply a metapost effect to a piece of any structure text
> for example when defining footnotes, frames , etc.
> i use this method for frames:
> 
> this is my MWE:
> \defineframed[Myframe][frame=off]
> \starttexdefinition spaces protected Mystyle #1
>     \startMPcode
>       picture tt ; tt:= lmt_outline [
>         kind = "path",
>         text = "\Myframe{#1}",
>       ];
>     fill
>       for i within tt : pathpart i && endfor cycle
>       withshademethod "linear"
>       withshadedirection up
>       withshadecolors (red,blue);
>     \stopMPcode
> \stoptexdefinition
> 
> \starttext
> \Mystyle{hello}
> \stoptext
> 
> 
> but what is the proper way if i want to use this style as simple as \tfb in definition of this structures? such as:
> \defineframed[Myframe][frame=off,style=\tfb\Mystyle,]

You can't apply commands which take arguments (like \Mystyle) to pass 
content fro TeX to Metapost with the style key. The only solution here 
is to create a new commands which takes the content as argument and 
combine the frame and shade in the command definition.

\defineframed[Myframe][frame=off]

\starttexdefinition spaces protected Mystyle #1
    \startMPcode
      picture tt ; tt:= lmt_outline [
        kind = "path",
        text = "#1",
      ];
    fill
      for i within tt : pathpart i && endfor cycle
      withshademethod "linear"
      withshadedirection up
      withshadecolors (red,blue);
    \stopMPcode
\stoptexdefinition

\define[1]\Mycommand
   {\Myframe{\Mystyle{#1}}}

% \define[1]\Mycommand
%   {\Mystyle{\Myframe{#1}}}

\starttext
\Mycommand{hello}
\stoptext

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2024-05-14 10:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-14  7:57 [NTG-context] applying style to frame content seyal.zavira
2024-05-14 10:51 ` [NTG-context] " Wolfgang Schuster

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).