Difference between revisions of "Command/MPcode"
< Command
Jump to navigation
Jump to search
Line 29: | Line 29: | ||
Similar to the environment {{cmd|startMPcode}} but see the example. | Similar to the environment {{cmd|startMPcode}} but see the example. | ||
− | <tt>\MPcode</tt> introduces an horizontal space after, and the | + | <tt>\MPcode</tt> introduces an horizontal space after, and the bounding box of the graphic keep the drawing origine (more accurate description, and/or more explanation probably required). |
− | </cd:description> | + | |
+ | |||
+ | It was introduced in 2010 to reduce needed calls with lua. | ||
+ | Source: https://mailman.ntg.nl/archives/users/73e723be437f45319340df29d9b5c94c/ | ||
+ | |||
+ | Before : | ||
+ | |||
+ | <context source="yes"> | ||
+ | \startluacode | ||
+ | context.MPdrawingdonetrue() | ||
+ | context.startMPdrawing() | ||
+ | context("fill fullcircle scaled 2cm withcolor darkyellow;") | ||
+ | context.stopMPdrawing() | ||
+ | context.getMPdrawing() | ||
+ | \stopluacode | ||
+ | </context> | ||
+ | |||
+ | After | ||
+ | |||
+ | <context source="yes"> | ||
+ | \startluacode | ||
+ | context.MPdrawingdonetrue() | ||
+ | context.MPdrawing("fill fullcircle scaled 2cm withcolor darkgreen;") | ||
+ | context.getMPdrawing() | ||
+ | </context></cd:description> | ||
<cd:examples><cd:example title=""><context source="yes"> | <cd:examples><cd:example title=""><context source="yes"> | ||
Revision as of 12:37, 8 May 2024
Contents
\MPcode
Summary
The command \MPcode is used for Metapost inline graphics.
Settings
\MPcode{...}{...} | |
{...} | metafun minifun extrafun lessfun doublefun binaryfun decimalfun mprun metapost nofun doublepost binarypost decimalpost simplefun |
{...} | content |
Description
Similar to the environment \startMPcode but see the example.
\MPcode introduces an horizontal space after, and the bounding box of the graphic keep the drawing origine (more accurate description, and/or more explanation probably required).
It was introduced in 2010 to reduce needed calls with lua.
Source: https://mailman.ntg.nl/archives/users/73e723be437f45319340df29d9b5c94c/
Before :
\startluacode context.MPdrawingdonetrue() context.startMPdrawing() context("fill fullcircle scaled 2cm withcolor darkyellow;") context.stopMPdrawing() context.getMPdrawing() \stopluacode
After
\startluacode context.MPdrawingdonetrue() context.MPdrawing("fill fullcircle scaled 2cm withcolor darkgreen;") context.getMPdrawing()
Examples
Example 1
With \tex{startMPcode} and no shift, text before \startMPcode fill fullcircle scaled 1cm withcolor darkred; \stopMPcode and text after With \tex{MPcode} and no shift, text before \MPcode{fill fullcircle scaled 1cm withcolor darkred;} and text after With \tex{MPcode} and with shift, text before \MPcode{fill fullcircle scaled 1cm shifted (0,0.5cm) withcolor darkred;} and text after With \tex{startMPcode} and with shift, text before \startMPcode fill fullcircle scaled 1cm shifted (0,0.5cm) withcolor darkred; \stopMPcode and text after