ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: seyal.zavira@gmail.com
To: ntg-context@ntg.nl
Subject: [NTG-context] how to apply metapost effects to section title?
Date: Tue, 09 Apr 2024 12:53:42 -0000	[thread overview]
Message-ID: <171266722269.3369327.8131443943302856031@cgl.ntg.nl> (raw)

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
___________________________________________________________________________________

             reply	other threads:[~2024-04-09 12:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 12:53 seyal.zavira [this message]
2024-04-09 15:56 ` [NTG-context] " Wolfgang Schuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=171266722269.3369327.8131443943302856031@cgl.ntg.nl \
    --to=seyal.zavira@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).