Difference between revisions of "Command/startMPinclusions"
< Command
Jump to navigation
Jump to search
m (/MetaPost) |
m |
||
Line 34: | Line 34: | ||
<texcode> | <texcode> | ||
\startMPinclusions | \startMPinclusions | ||
− | + | vardef create_wave = | |
− | + | path wave; | |
− | + | wave := (0, 0); | |
− | + | ||
− | + | % Number of bezier points along the wave. | |
+ | wave_resolution := 20; | ||
+ | |||
+ | % Number of full wave cycles. | ||
+ | wave_cycles := 2; | ||
+ | |||
+ | for x = 0 step (1 / wave_resolution) until 2 wave_cycles: | ||
+ | wave := wave .. (x, sin( x * pi )); | ||
+ | endfor; | ||
+ | |||
+ | % Return the path | ||
+ | wave | ||
+ | enddef; | ||
\stopMPinclusions | \stopMPinclusions | ||
+ | |||
+ | \startuseMPgraphic{page:ThemeBackground} | ||
+ | path wave; | ||
+ | wave := create_wave; | ||
+ | draw wave xyscaled( 60, 20 ) withpen pencircle scaled 1mm; | ||
+ | \stopuseMPgraphic | ||
+ | |||
+ | \defineoverlay[page:ThemeBackground][\uniqueMPgraphic{page:ThemeBackground}] | ||
+ | |||
+ | \starttext | ||
+ | \setupbackgrounds[page][background={page:ThemeBackground}] | ||
+ | \startchapter | ||
+ | \input knuth | ||
+ | \stopchapter | ||
+ | \stoptext | ||
</texcode> | </texcode> | ||
Revision as of 01:32, 8 October 2013
\startMPinclusions
Syntax
\startMPinclusions[...][...][...] | |
[...] | text |
[...] | text |
[...] | text |
Description
Inside \startMPinclusions one can specify MetaFun code that you would like to be present in your MetaPost instance. It is generally used to define MetaPost functions, or to input files that contain them.
Example
\startMPinclusions vardef create_wave = path wave; wave := (0, 0); % Number of bezier points along the wave. wave_resolution := 20; % Number of full wave cycles. wave_cycles := 2; for x = 0 step (1 / wave_resolution) until 2 wave_cycles: wave := wave .. (x, sin( x * pi )); endfor; % Return the path wave enddef; \stopMPinclusions \startuseMPgraphic{page:ThemeBackground} path wave; wave := create_wave; draw wave xyscaled( 60, 20 ) withpen pencircle scaled 1mm; \stopuseMPgraphic \defineoverlay[page:ThemeBackground][\uniqueMPgraphic{page:ThemeBackground}] \starttext \setupbackgrounds[page][background={page:ThemeBackground}] \startchapter \input knuth \stopchapter \stoptext
See also
- \defineMPinstance
- \setupMPinstance
- \startMPinclusions
- \startMPenvironment — deprecated
- \startMPcode
- \startuseMPgraphic — dynamic graphics that are recompiled at every use
- \useMPgraphic — use a dynamic graphic
- \startuniqueMPgraphic — dynamic graphics that are recompiled when parameters (width, height, depth, background color, line color) change
- \uniqueMPgraphic — use a dynamic graphic
- \startreusableMPgraphic — static graphics that are compiled once
- \reuseMPgraphic — use a static graphic
- \startstaticMPfigure — standalone graphics
- \usestaticMPfigure — use a standalone graphic
- \startMPpage — a page just large enough to fit its MetaPost contents
- MetaFun - MetaPost in ConTeXt
Help from ConTeXt-Mailinglist/Forum
All issues with: