* [NTG-context] how to apply metapost effects to section title?
@ 2024-04-09 12:53 seyal.zavira
2024-04-09 15:56 ` [NTG-context] " Wolfgang Schuster
0 siblings, 1 reply; 2+ messages in thread
From: seyal.zavira @ 2024-04-09 12:53 UTC (permalink / raw)
To: ntg-context
i want to produce a gradient header
i tried this code but it does not produce any result:
\startext
\def\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
}
\definehead[Myhead][section]
\setuphead[Myhead][
style=\Mystyle,
]
\startMyhead[title=sample] a sample text \stopMyhead
\stoptext
and the code below works but does not colorize numbers of this heads:
\starttext
\def\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
}
\def\startMysection#1{\startsection[title=\Mystyle{#1}]}
\def\stopMysection{\stopsection}
\startMysection{hello}
what is best method?
\stopMysection
\stoptext
what is your suggestion?
___________________________________________________________________________________
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: how to apply metapost effects to section title?
2024-04-09 12:53 [NTG-context] how to apply metapost effects to section title? seyal.zavira
@ 2024-04-09 15:56 ` Wolfgang Schuster
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Schuster @ 2024-04-09 15:56 UTC (permalink / raw)
To: mailing list for ConTeXt users, seyal.zavira
seyal.zavira@gmail.com schrieb am 09.04.2024 um 14:53:
> i want to produce a gradient header
> i tried this code but it does not produce any result:
>
> \startext
> \def\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
> }
>
> \definehead[Myhead][section]
> \setuphead[Myhead][
> style=\Mystyle,
> ]
> \startMyhead[title=sample] a sample text \stopMyhead
> \stoptext
You can't use commands with parameters as argument for the style key.
To format single parts (number or title) of a section title you have to
apply a command to the "deep...command" key but even then you have to
make manual changes to the vertical alignment of the text.
%%%% begin example
\starttexdefinition spaces Mystyle #1
\setbox\scratchboxone\hbox{#1}%
\setbox\scratchboxtwo\hbox\bgroup
\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
\egroup
\boxyoffset\scratchboxtwo-\dp\scratchboxone
\box\scratchboxtwo
\stoptexdefinition
\starttext
\setuphead
[section]
[
deeptextcommand=\Mystyle,
% deepnumbercommand=\Mystyle,
]
\startsection[title=Lorem ipsum]
\samplefile{lorem}
\stopsection
\stoptext
%%%% end example
> and the code below works but does not colorize numbers of this heads:
> \starttext
>
> \def\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
> }
>
> \def\startMysection#1{\startsection[title=\Mystyle{#1}]}
> \def\stopMysection{\stopsection}
>
> \startMysection{hello}
> what is best method?
> \stopMysection
>
> \stoptext
>
> what is your suggestion?
To apply the format the the complete section title you have to create
your own style and apply it with the "command" key, to get the number
and title for the current section use the \structurenumber and
\structuretitle macros.
%%%% begin example
\starttexdefinition spaces protected Mystyle #1#2
\startMPcode
picture tt ; tt := lmt_outline [
kind = "path",
text = "\structurenumber\space\structuretitle",
];
fill
for i within tt : pathpart i && endfor cycle
withshademethod "linear"
withshadedirection up
withshadecolors (red, blue) ;
\stopMPcode
\stoptexdefinition
\starttext
\setuphead
[section]
[command=\Mystyle]
\startsection[title=Lorem ipsum]
\samplefile{lorem}
\stopsection
\stoptext
%%%% end example
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-04-09 16:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09 12:53 [NTG-context] how to apply metapost effects to section title? seyal.zavira
2024-04-09 15:56 ` [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).