| 1 |
\ifnum\outputmode > 0 |
| 2 |
\DocumentMetadata{ lang=en-US, pdfversion=2.0, pdfstandard=ua-2, |
| 3 |
tagging=on, tagging-setup={math/setup=mathml-SE}, |
| 4 |
% debug=BBox, |
| 5 |
} |
| 6 |
\documentclass{article} |
| 7 |
\else |
| 8 |
\documentclass[dvipdfmx]{article} |
| 9 |
\pagewidth=\paperwidth |
| 10 |
\pageheight=\paperheight |
| 11 |
\special{papersize=\the\paperwidth,\the\paperheight} |
| 12 |
\fi |
| 13 |
\usepackage{fontspec} |
| 14 |
\setmainfont{latin modern roman} |
| 15 |
\newfontfamily\hangulfont{NotoSansCJKKR}[Script=Hangul,Language=Korean] |
| 16 |
\usepackage{luamplib} |
| 17 |
\usepackage{geometry,lua-unicode-math,graphicx,xcolor,hyperref} |
| 18 |
\everymplib{ beginfig(0); } |
| 19 |
\everyendmplib{ endfig; } |
| 20 |
\mpliblegacybehavior{true}% |
| 21 |
\begin{document} |
| 22 |
\title{testing LuaMPlib} |
| 23 |
\parindent0pt |
| 24 |
\mplibalttext{testing} |
| 25 |
\tracingcommands1 |
| 26 |
A% |
| 27 |
\begin{mplibcode} |
| 28 |
%% test all printable ascii chars in comments |
| 29 |
%% ( 2 < F P Z d n x |
| 30 |
%% ) 3 = G Q [ e o y |
| 31 |
%% * 4 > H R \ f p z |
| 32 |
%% ! + 5 ? I S ] g q { |
| 33 |
%% " , 6 @ J T ^ h r | |
| 34 |
%% # - 7 A K U _ i s } |
| 35 |
%% $ . 8 B L V ` j t ~ |
| 36 |
%% % / 9 C M W a k u DEL |
| 37 |
%% & 0 : D N X b l v |
| 38 |
%% ´ 1 ; E O Y c m w |
| 39 |
fill fullcircle scaled 20; %% actual <tab> to make sure it works |
| 40 |
\end{mplibcode}% |
| 41 |
B% |
| 42 |
|
| 43 |
\everymplib{}\everyendmplib{}% reset toks |
| 44 |
A% |
| 45 |
\begin{mplibcode} |
| 46 |
verbatimtex \lower.2em etex |
| 47 |
beginfig(0); |
| 48 |
draw origin--(1cm,0) withcolor \mpcolor{teal}; |
| 49 |
draw btex g etex withcolor \mpcolor{orange}; |
| 50 |
draw btex\tracingcommands0 |
| 51 |
multi% |
| 52 |
\begin{huge}line\end{huge} |
| 53 |
texcode |
| 54 |
with \% |
| 55 |
etex shifted (10,0); |
| 56 |
draw bbox currentpicture; |
| 57 |
endfig; |
| 58 |
|
| 59 |
beginfig(18); |
| 60 |
numeric u; |
| 61 |
u = 1cm; |
| 62 |
draw (0,2u)--(0,0)--(4u,0); |
| 63 |
pickup pencircle scaled 1pt; |
| 64 |
draw (0,0){up} |
| 65 |
for i=1 upto 8: ..(i/2,sqrt(i/2))*u endfor; |
| 66 |
label.lrt(btex $\sqrt x$ etex, (3,sqrt 3)*u); |
| 67 |
label.bot(btex $x$ etex, (2u,0)); |
| 68 |
label.lft(btex $y$ etex, (0,u)); |
| 69 |
endfig; |
| 70 |
\end{mplibcode}% |
| 71 |
B% |
| 72 |
|
| 73 |
A% |
| 74 |
\begin{mplibcode} |
| 75 |
beginfig(2); |
| 76 |
numeric u; u=1cm; |
| 77 |
z1=-z2=(-u,0); |
| 78 |
for i = 1 upto 3: |
| 79 |
draw z1..(0, i*u)..z2; |
| 80 |
label.top(TEX("$e_{" & decimal(i) & "}$"), (0, i*u)) |
| 81 |
withcolor \mpcolor{red!70!blue}; |
| 82 |
endfor; |
| 83 |
endfig; |
| 84 |
\end{mplibcode}% |
| 85 |
B% |
| 86 |
|
| 87 |
\mplibforcehmode |
| 88 |
\mplibcodeinherit{enable}% |
| 89 |
\mplibglobaltextext{enable}% |
| 90 |
\everymplib{ beginfig(0);}\everyendmplib{ endfig;}% |
| 91 |
\begin{mplibcode}[text] |
| 92 |
label(btex $\sqrt 2$ etex, origin); |
| 93 |
draw fullcircle scaled 20; |
| 94 |
picture pic; pic := currentpicture; |
| 95 |
\end{mplibcode}% |
| 96 |
\begin{mplibcode} |
| 97 |
currentpicture := pic scaled 2; |
| 98 |
\end{mplibcode}% |
| 99 |
\mplibnoforcehmode |
| 100 |
\everymplib{}\everyendmplib{}% |
| 101 |
\mplibcodeinherit{disable}% |
| 102 |
\mplibglobaltextext{disable}% |
| 103 |
|
| 104 |
\mplibsetformat{metafun}% |
| 105 |
\begin{mplibcode}[alt=alt inside mp code] |
| 106 |
message "Hello World!"; |
| 107 |
verbatimtex \moveright 0.4\hsize etex |
| 108 |
beginfig(0); |
| 109 |
path p; p:= fullcircle scaled 2cm yshifted .5cm; |
| 110 |
fill p withcolor transparent("normal", 0.5, red); |
| 111 |
fill p rotated 120 withcolor transparent("normal", 0.5, green); |
| 112 |
fill p rotated 240 withcolor transparent("normal", 0.5, blue); |
| 113 |
endfig; |
| 114 |
verbatimtex \mplibalttext{MetaPost}\leavevmode etex |
| 115 |
picture p; p := btex MetaPost etex scaled 2; |
| 116 |
beginfig(1); |
| 117 |
linear_shade(bbox p,0,blue,.7white); |
| 118 |
draw p withcolor white; |
| 119 |
endfig; |
| 120 |
verbatimtex \mplibalttext{MetaPost again}\kern10pt etex |
| 121 |
beginfig(2); |
| 122 |
circular_shade(bbox p,0,blue,.7white); |
| 123 |
draw p withcolor white; |
| 124 |
endfig; |
| 125 |
\end{mplibcode}% |
| 126 |
|
| 127 |
\begin{mplibgroup}{mympbox}% |
| 128 |
\begin{mplibcode}[off] |
| 129 |
%verbatimtex \global\setbox\mympbox etex |
| 130 |
beginfig(0); |
| 131 |
breadth=.667\mpdim\linewidth; |
| 132 |
height=2pt; |
| 133 |
x1=0; x2=x6=.333x4; x5=x3=.667x4; |
| 134 |
x4=breadth; |
| 135 |
y1=y4=height/2; y2=y3=height; y5=y6=0; |
| 136 |
fill z1--z2--z3--z4--z5--z6--cycle; |
| 137 |
endfig; |
| 138 |
\end{mplibcode}% |
| 139 |
\end{mplibgroup}% |
| 140 |
\usemplibgroup[artifact]{mympbox}% |
| 141 |
\usemplibgroup[artifact]{mympbox}% |
| 142 |
\usemplibgroup[artifact]{mympbox}% |
| 143 |
\usemplibgroup[artifact]{mympbox}% |
| 144 |
|
| 145 |
\mplibnoforcehmode |
| 146 |
\mplibnumbersystem{double}% |
| 147 |
\begin{mplibcode}[off] |
| 148 |
beginfig(0); |
| 149 |
u := 10**5*(10**-4); |
| 150 |
draw unitsquare scaled u; |
| 151 |
endfig; |
| 152 |
\end{mplibcode}% |
| 153 |
\mplibsetformat{plain}% |
| 154 |
\begin{mplibcode} |
| 155 |
input graph; |
| 156 |
beginfig(0); |
| 157 |
draw begingraph(100,100); |
| 158 |
gdraw (10,10)--(30,35)--(50,25)--(70,80)--(90,90); |
| 159 |
autogrid(otick.bot,); |
| 160 |
for y=20,40,60,80: |
| 161 |
grid.lft(format("%e",1000y), y) withcolor .85white; |
| 162 |
endfor |
| 163 |
endgraph; |
| 164 |
endfig; |
| 165 |
\end{mplibcode}% |
| 166 |
\mplibtextextlabel{enable}% |
| 167 |
\begin{mplibcode}[text] |
| 168 |
beginfig(0); |
| 169 |
dotlabel.rt("$\sqrt 2$",origin); |
| 170 |
endfig; |
| 171 |
\end{mplibcode}% |
| 172 |
\leavevmode |
| 173 |
\begin{mplibcode}[artifact] |
| 174 |
D := sqrt(2)**7; |
| 175 |
beginfig(0); |
| 176 |
draw fullcircle scaled D; |
| 177 |
VerbatimTeX("\gdef\Dia{" & decimal D & "}"); |
| 178 |
endfig; |
| 179 |
\end{mplibcode}% |
| 180 |
diameter:\Dia bp.% |
| 181 |
\begin{mplibcode}[off] |
| 182 |
vardef rotatedlabel@#(expr str, loc, angl) = |
| 183 |
draw thelabel@#(str, loc) rotatedaround(loc, angl) |
| 184 |
enddef; |
| 185 |
|
| 186 |
beginfig(1); |
| 187 |
rotatedlabel.top(textext "Rotated!", origin, 40); |
| 188 |
endfig; |
| 189 |
\end{mplibcode}% |
| 190 |
\tracingcommands0 |
| 191 |
|
| 192 |
\begin{mplibcode}[text] |
| 193 |
beginfig(1) |
| 194 |
draw mplibgraphictext "\bfseries Funny$\sqrt 2$" |
| 195 |
fakebold 2 % fontspec option |
| 196 |
drawcolor blue fillcolor "red!50" % l3color expression |
| 197 |
scaled 3 rotated 30 ; |
| 198 |
draw mplibgraphictext "\bfseries\itshape xyz" scaled 3 shifted (40,0); |
| 199 |
endfig; |
| 200 |
\end{mplibcode}% |
| 201 |
|
| 202 |
%\mplibsetformat{metafun}% |
| 203 |
\begin{mplibcode}[alt=testing shading] |
| 204 |
beginfig(1) |
| 205 |
fill unitsquare xscaled \mpdim\textwidth yscaled 1cm |
| 206 |
withshadingmethod "linear" |
| 207 |
withshadingvector (0,1) |
| 208 |
withshadingstep ( |
| 209 |
withshadingfraction .5 |
| 210 |
withshadingcolors (red,"blue!50") |
| 211 |
) |
| 212 |
withshadingstep ( |
| 213 |
withshadingfraction 1 |
| 214 |
withshadingcolors ("blue!50",green) |
| 215 |
) |
| 216 |
; |
| 217 |
endfig; |
| 218 |
\end{mplibcode}% |
| 219 |
\leavevmode |
| 220 |
\mpfig[alt=Que] |
| 221 |
color yellow; yellow = (1,1,0); |
| 222 |
picture Q, u, e; |
| 223 |
Q := mplibglyph "Q" of "texgyrepagella-bolditalic.otf" scaled .1; |
| 224 |
u := mplibglyph "u" of "texgyrepagella-bolditalic.otf" scaled .1 shifted lrcorner Q; |
| 225 |
e := mplibglyph "e" of "texgyrepagella-bolditalic.otf" scaled .1 shifted lrcorner u; |
| 226 |
i:=0; |
| 227 |
totallen := length Q + length u + length e; |
| 228 |
for pic=Q, u, e: |
| 229 |
for item within pic: |
| 230 |
i:=i+1; |
| 231 |
fill pathpart item |
| 232 |
if i < totallen: withpostscript "collect"; fi |
| 233 |
endfor |
| 234 |
endfor |
| 235 |
withshadingmethod "linear" |
| 236 |
withshadingdirection (0.5,2.5) |
| 237 |
withshadingcolors (.7red,.7yellow) |
| 238 |
withshadingstroke "yes" |
| 239 |
withpen pencircle scaled 2 withcolor 2/3red |
| 240 |
; |
| 241 |
\endmpfig |
| 242 |
\everymplib[@mpfig]{ drawoptions(withcolor mplibrgbtexcolor "olive"); }% |
| 243 |
\mpfig* input boxes \endmpfig |
| 244 |
\mpfig circleit.a(btex Box 1 etex); drawboxed(a); \endmpfig |
| 245 |
\def\mpfiginstancename{mympfig}% |
| 246 |
\mpfig[tag=Formula,alt=$1/(1-x^2)$] |
| 247 |
draw mpliboutlinetext.b ("$\displaystyle\frac{1}{1-x^2}$") |
| 248 |
(withcolor .6[red,white]) |
| 249 |
(withpen pencircle scaled .2 withcolor red) |
| 250 |
scaled 4 ; |
| 251 |
\endmpfig |
| 252 |
|
| 253 |
\mpfig[alt=Question] |
| 254 |
draw mpliboutlinetext.r |
| 255 |
("Question") |
| 256 |
( withpen pencircle scaled .3 ) |
| 257 |
( |
| 258 |
withshadingmethod "linear" |
| 259 |
withshadingdirection (2.5, 0.5) |
| 260 |
withshadingcolors(red, blue) |
| 261 |
) |
| 262 |
scaled 4; |
| 263 |
\endmpfig |
| 264 |
|
| 265 |
\leavevmode |
| 266 |
\mppattern{mypatt} |
| 267 |
[ |
| 268 |
matrix = "rotated -45 scaled 2/3", |
| 269 |
] |
| 270 |
\mpfig[off] |
| 271 |
draw (origin -- 4 right) shifted 2 up withcolor 2/3 red; |
| 272 |
setbounds currentpicture to unitsquare scaled 4; |
| 273 |
\endmpfig |
| 274 |
\endmppattern |
| 275 |
\mpfig |
| 276 |
draw unitsquare shifted -center unitsquare scaled 45 withpostscript "collect" ; |
| 277 |
filldraw fullcircle scaled 100 withmppattern "mypatt" withpen pencircle scaled 1 |
| 278 |
withcolor \mpcolor{red!50!blue!50} withpostscript "evenodd" ; |
| 279 |
\endmpfig |
| 280 |
\begin{mppattern}{pattuncolored} |
| 281 |
[ |
| 282 |
colored = false, |
| 283 |
matrix = "slanted .3 rotated 30", |
| 284 |
] |
| 285 |
\SuspendTagging{}% |
| 286 |
\tiny\TeX |
| 287 |
\end{mppattern}\relax |
| 288 |
\mpfig[actualtext=TeX] |
| 289 |
picture tex; |
| 290 |
tex = mpliboutlinetext.p ("\bfseries \TeX"); |
| 291 |
for i=1 upto mpliboutlinenum: |
| 292 |
draw image( |
| 293 |
j:=0; |
| 294 |
for item within mpliboutlinepic[i]: |
| 295 |
j:=j+1; |
| 296 |
filldraw pathpart item scaled 10 |
| 297 |
if j < length mpliboutlinepic[i]: |
| 298 |
withpostscript "collect" |
| 299 |
else: |
| 300 |
withmppattern "pattuncolored" |
| 301 |
withpen pencircle scaled 1/2 |
| 302 |
withcolor (i/4)[red,blue] |
| 303 |
fi; |
| 304 |
endfor |
| 305 |
) |
| 306 |
withfademethod "linear" |
| 307 |
; |
| 308 |
endfor |
| 309 |
\endmpfig |
| 310 |
|
| 311 |
\leavevmode |
| 312 |
\mpfig[alt=test fading] |
| 313 |
picture mill; mill = btex \includegraphics[width=100bp]{mill} etex; |
| 314 |
draw mill; |
| 315 |
mill := mill shifted 125right; |
| 316 |
draw mill |
| 317 |
withfademethod "circular" |
| 318 |
withfadecenter (center mill, center mill) |
| 319 |
withfaderadius (30, abs(lrcorner mill - llcorner mill)/2) |
| 320 |
withfadeopacity (1, 0) |
| 321 |
; |
| 322 |
\endmpfig |
| 323 |
|
| 324 |
\def\test#1{% |
| 325 |
\mpfig |
| 326 |
fill unitsquare shifted -center unitsquare scaled 200 |
| 327 |
withshadingmethod "linear" |
| 328 |
withshadingcolors (.3[red,white], .3[blue,white]) |
| 329 |
; |
| 330 |
label( btex MetaPost etex scaled 3, origin) ; |
| 331 |
draw image( |
| 332 |
fill fullcircle scaled 100 shifted 25left |
| 333 |
withcolor .8white |
| 334 |
withtransparency (2,1) |
| 335 |
; |
| 336 |
fill fullcircle scaled 100 shifted 25right |
| 337 |
withcolor .8white |
| 338 |
withtransparency (2,1) |
| 339 |
; |
| 340 |
) |
| 341 |
asgroup "#1" |
| 342 |
withgroupname "test:#1" |
| 343 |
withtransparency (1,.5) |
| 344 |
; |
| 345 |
currentpicture := currentpicture scaled 2/3; |
| 346 |
label.ulft(TEX"#1", lrcorner currentpicture) withcolor 3/4white; |
| 347 |
\endmpfig |
| 348 |
}% |
| 349 |
\hbox{\test{isolated,knockout}\,\test{isolated} |
| 350 |
\mpfig usemplibgroup "test:isolated" scaled 2/3 rotated 15 ; \endmpfig |
| 351 |
} |
| 352 |
\hbox{\test{knockout}\,\test{} |
| 353 |
\mpfig usemplibgroup "test:knockout" scaled 2/3 rotated 15 ; \endmpfig |
| 354 |
}% |
| 355 |
\marginpar{\leavevmode\llap{acrobat/foxit/texworks/(mupdf)}} |
| 356 |
|
| 357 |
\bigskip |
| 358 |
\mpfig[text] |
| 359 |
draw mplibgraphictext "\textbf{MPLIB}" |
| 360 |
fakebold 1 fillcolor "red!70" drawcolor .7red scaled 7 |
| 361 |
withmppattern "mypatt" ; |
| 362 |
\endmpfig |
| 363 |
|
| 364 |
\leavevmode |
| 365 |
\begin{mplibgroup}{mytex}[matrix="rotated 15"] \SuspendTagging{}\TeX \end{mplibgroup}% |
| 366 |
\csname tag_mc_artifact_group_begin:n\endcsname {}% |
| 367 |
\hbox to0pt{\hss\vrule width.5pt height5pt depth5pt\hss}% |
| 368 |
\hbox to0pt{\hss\vrule width10pt height.25pt depth.25pt\hss}% |
| 369 |
\csname tag_mc_artifact_group_end:\endcsname |
| 370 |
\usemplibgroup[actualtext=TeX]{mytex}% |
| 371 |
\mpfig[actualtext=TeX] usemplibgroup "mytex"; draw (left--right) scaled 5; draw (up--down) scaled 5; \endmpfig |
| 372 |
\mpfig[text] |
| 373 |
draw mplibgraphictext "\bfseries\TeX" rotated 15 scaled 4 |
| 374 |
withshadingmethod "linear" |
| 375 |
withshadingvector (3,0) |
| 376 |
withshadingstep ( |
| 377 |
withshadingfraction 1/2 |
| 378 |
withshadingcolors (red,green) |
| 379 |
) |
| 380 |
withshadingstep ( |
| 381 |
withshadingfraction 1 |
| 382 |
withshadingcolors (green,blue) |
| 383 |
) |
| 384 |
; |
| 385 |
\endmpfig |
| 386 |
|
| 387 |
\leavevmode |
| 388 |
\mpfig[off] |
| 389 |
string Test; Test="abçdéf"; |
| 390 |
for k=0 upto mpliblength(Test)-1: |
| 391 |
draw TEX(mplibsubstring (k,k+1) of Test) scaled 2 shifted (20k,0); |
| 392 |
endfor |
| 393 |
\endmpfig |
| 394 |
\qquad |
| 395 |
\mpliblegacybehavior{false}% |
| 396 |
\begingroup\ifdefined\tagpdfsetup\tagpdfsetup{text/lang=ko-KR}\fi |
| 397 |
\mpfig[actualtext=나랏말씀이] |
| 398 |
verbatimtex \hangulfont etex; |
| 399 |
string Test; Test="나랏말ᄊᆞ미"; |
| 400 |
for k=0 upto mplibuclength(Test)-1: |
| 401 |
draw TEX(mplibucsubstring (k,k+1) of Test) scaled 1.5 shifted (20k,0); |
| 402 |
endfor |
| 403 |
\endmpfig |
| 404 |
\endgroup |
| 405 |
|
| 406 |
\mplibforcehmode |
| 407 |
\mppattern{p1} |
| 408 |
\mpfig[off] |
| 409 |
fill fullcircle scaled 3 |
| 410 |
withcolor .7red |
| 411 |
; |
| 412 |
\endmpfig |
| 413 |
\endmppattern |
| 414 |
\mppattern{p2} |
| 415 |
\mpfig[off] |
| 416 |
fill fullcircle scaled 9 |
| 417 |
withmppattern "p1" |
| 418 |
; |
| 419 |
\endmpfig |
| 420 |
\endmppattern |
| 421 |
\mppattern{p3} |
| 422 |
\mpfig[off] |
| 423 |
fill fullcircle scaled 27 |
| 424 |
withmppattern "p2" |
| 425 |
; |
| 426 |
\endmpfig |
| 427 |
\endmppattern |
| 428 |
\mpfig[alt=testing nested pattern] |
| 429 |
fill fullcircle scaled 108 |
| 430 |
withmppattern "p3" |
| 431 |
; |
| 432 |
\endmpfig |
| 433 |
\mpfig |
| 434 |
picture pic; |
| 435 |
pic = mplibglyph "R" of "texgyrepagella-regular.otf" scaled 1/10; |
| 436 |
mplibfillandstrokeglyph pic |
| 437 |
slanted 0.25 |
| 438 |
withpen pencircle scaled 1 |
| 439 |
withmplibcolors ("orange", 2/3red) |
| 440 |
; |
| 441 |
\endmpfig |
| 442 |
\mpfig |
| 443 |
mplibdrawglyph mplibglyph "R" of "utmr8a.pfb" scaled 1/10 withcolor 2/3red; |
| 444 |
\endmpfig |
| 445 |
|
| 446 |
\mplibnoforcehmode |
| 447 |
\mpliblegacybehavior{true}% |
| 448 |
|
| 449 |
\vskip 2\baselineskip |
| 450 |
\mplibcodeinherit{disable}% |
| 451 |
|
| 452 |
\everymplib[instanceOne]{beginfig(1);} |
| 453 |
\everyendmplib[instanceOne]{endfig;} |
| 454 |
|
| 455 |
\begin{mplibcode}[instanceOne] |
| 456 |
picture TeX; |
| 457 |
TeX := btex \TeX etex; |
| 458 |
a := 1cm; |
| 459 |
draw fullcircle scaled a; |
| 460 |
draw btex a circle with $d=a$ etex shifted (a,0); |
| 461 |
draw TeX; |
| 462 |
\end{mplibcode}% |
| 463 |
Current instance name is: \currentmpinstancename \vskip 2\baselineskip |
| 464 |
|
| 465 |
\begin{mplibcode}[instanceTwo] |
| 466 |
beginfig(1); |
| 467 |
if not known a: |
| 468 |
draw btex code is not inherited from an instance with a different name etex; |
| 469 |
else: |
| 470 |
errmessage("Variable was inherited from a different instance"); |
| 471 |
fi; |
| 472 |
endfig; |
| 473 |
\end{mplibcode}% |
| 474 |
Current instance name is: \currentmpinstancename \vskip 2\baselineskip |
| 475 |
|
| 476 |
\begin{mplibcode} |
| 477 |
beginfig(1); |
| 478 |
if not known a: |
| 479 |
draw btex code is not inherited if instance name is not listed etex; |
| 480 |
else: |
| 481 |
errmessage("Variable was inherited from a different instance"); |
| 482 |
fi; |
| 483 |
a := 1cm; |
| 484 |
endfig; |
| 485 |
\end{mplibcode}% |
| 486 |
Current instance name is: \currentmpinstancename (should be empty) \vskip 2\baselineskip |
| 487 |
|
| 488 |
\begin{mplibcode} |
| 489 |
beginfig(1); |
| 490 |
if not known a: |
| 491 |
draw btex code is not inherited if mplibcodeinherit is disabled and instance name is not explicitly set etex; |
| 492 |
else: |
| 493 |
errmessage("Variable was inherited when code inheritance is turned off and instance name is not set"); |
| 494 |
fi; |
| 495 |
endfig; |
| 496 |
\end{mplibcode}% |
| 497 |
Current instance name is: \currentmpinstancename (should be empty) \vskip 2\baselineskip |
| 498 |
|
| 499 |
\begin{mplibcode}[instanceOne] |
| 500 |
draw unitsquare scaled a; |
| 501 |
draw btex a square with side $=a$, inherited from the same instance etex shifted (3/2a, 1/2a); |
| 502 |
draw TeX; |
| 503 |
\end{mplibcode}% |
| 504 |
Current instance name is: \currentmpinstancename \vskip 2\baselineskip |
| 505 |
|
| 506 |
\begin{center}* \qquad * \qquad *\end{center} |
| 507 |
|
| 508 |
\section{My Section}\label{sec:my_section} |
| 509 |
|
| 510 |
pattern after masking |
| 511 |
\mpfig* |
| 512 |
picture pic; pic = btex \sffamily\bfseries\Huge Meta etex scaled 2; |
| 513 |
\endmpfig |
| 514 |
\mplibgroup{mymask}[asgroup="masking"] |
| 515 |
\mpfig[off] |
| 516 |
draw pic withcolor 1; |
| 517 |
\endmpfig |
| 518 |
\endmplibgroup |
| 519 |
\mpfig[alt=test general masking] |
| 520 |
draw image( |
| 521 |
for i=-7 upto 8 : |
| 522 |
fill unitsquare |
| 523 |
xscaled (xpart lrcorner pic + 3 bboxmargin) |
| 524 |
yscaled 5 |
| 525 |
rotated 15 |
| 526 |
shifted (0, 5i) |
| 527 |
withcolor ((i+7)/14)[blue,red] ; |
| 528 |
endfor |
| 529 |
) withmaskinggroup "mymask" |
| 530 |
withmaskingbgcolor 1/10 ; |
| 531 |
clip currentpicture to bbox pic; |
| 532 |
\endmpfig |
| 533 |
\mppattern{mypatt2}[ xstep = 3, ystep = 3 ] |
| 534 |
\mpfig[off] |
| 535 |
fill fullcircle scaled 2 withcolor 2/3 red; |
| 536 |
\endmpfig |
| 537 |
\endmppattern |
| 538 |
\mpfig |
| 539 |
draw mplibgraphictext "\bfseries POST" fakebold 1/2 drawcolor 2/3red scaled 5 |
| 540 |
withmppattern "mypatt2"; |
| 541 |
\endmpfig |
| 542 |
|
| 543 |
pattern inside masking |
| 544 |
\mppattern{mypattern}[colored=false] |
| 545 |
\SuspendTagging\relax |
| 546 |
\tiny\TeX |
| 547 |
\endmppattern |
| 548 |
\mplibgroup{mygroup}[asgroup="masking"] |
| 549 |
\mpfig[off] |
| 550 |
path p; p = fullcircle xscaled 120 yscaled 50 ; |
| 551 |
fill p withmppattern "mypattern" withcolor 1 ; |
| 552 |
\endmpfig |
| 553 |
\endmplibgroup |
| 554 |
\mpfig |
| 555 |
draw image(fill p |
| 556 |
withshadingmethod "linear" withshadingcolors (red,blue) |
| 557 |
withmaskinggroup "mygroup" |
| 558 |
) asgroup "" withgroupname "mygroup2" ; |
| 559 |
\endmpfig |
| 560 |
\mpfig |
| 561 |
usemplibgroup "mygroup2" rotated 15 ; |
| 562 |
\endmpfig |
| 563 |
|
| 564 |
masking inside pattern\marginpar{\leavevmode\llap{acrobat/foxit/firefox/chrome/mupdf/texworks}} |
| 565 |
\mplibgroup{mymask2}[asgroup="masking"] |
| 566 |
\mpfig[off] |
| 567 |
picture tex; |
| 568 |
tex = TEX "\tiny\TeX"; |
| 569 |
draw tex withcolor 1; |
| 570 |
\endmpfig |
| 571 |
\endmplibgroup |
| 572 |
\mppattern{mypattern} |
| 573 |
\mpfig[off] |
| 574 |
bboxmargin:=1/5; |
| 575 |
fill bbox tex |
| 576 |
withshadingmethod"linear" withshadingcolors(2/3[white,red], 2/3[white,blue]) |
| 577 |
withmaskinggroup "mymask2" withmaskingbgcolor 1/10; |
| 578 |
\endmpfig |
| 579 |
\endmppattern |
| 580 |
\mpfig |
| 581 |
fill p withmppattern "mypattern"; |
| 582 |
\endmpfig |
| 583 |
\mplibgroup{mygroup3} |
| 584 |
\mpfig[off] |
| 585 |
fill p withmppattern "mypattern" ; |
| 586 |
\endmpfig |
| 587 |
\endmplibgroup |
| 588 |
\mpfig |
| 589 |
usemplibgroup "mygroup3" rotated 15 ; |
| 590 |
\endmpfig |
| 591 |
|
| 592 |
just shading in pattern |
| 593 |
\mppattern{myshpatt} |
| 594 |
\mpfig[off] |
| 595 |
bboxmargin:=1/5; |
| 596 |
fill bbox tex |
| 597 |
withshadingmethod"linear" withshadingcolors(2/3[white,red], 2/3[white,blue]) |
| 598 |
withtransparency (1, 1/10) |
| 599 |
; |
| 600 |
draw tex |
| 601 |
withshadingmethod"linear" withshadingcolors(2/3[white,red], 2/3[white,blue]) ; |
| 602 |
\endmpfig |
| 603 |
\endmppattern |
| 604 |
\mpfig |
| 605 |
fill p withmppattern "myshpatt"; |
| 606 |
\endmpfig |
| 607 |
\mplibgroup{mygroup4} |
| 608 |
\mpfig[off] |
| 609 |
fill p withmppattern "myshpatt" ; |
| 610 |
\endmpfig |
| 611 |
\endmplibgroup |
| 612 |
\mpfig |
| 613 |
usemplibgroup "mygroup4" rotated 15 ; |
| 614 |
\endmpfig |
| 615 |
|
| 616 |
shading pattern and xobject\marginpar{\leavevmode\llap{acrobat/mupdf}} |
| 617 |
\mpfig* |
| 618 |
picture pic[]; |
| 619 |
pic1 = image( |
| 620 |
fill fullcircle scaled 44 withoutcolor; |
| 621 |
fill fullcircle scaled 44 shifted 22right withoutcolor; |
| 622 |
) ; |
| 623 |
pic2 = image( draw pic1 |
| 624 |
withshadingmethod "circular" |
| 625 |
withshadingcolors (red, blue) % shading inside group |
| 626 |
) ; |
| 627 |
\endmpfig |
| 628 |
\mpfig |
| 629 |
draw pic2 |
| 630 |
asgroup "" |
| 631 |
withtransparency (1, 2/3) ; |
| 632 |
\endmpfig |
| 633 |
\mplibgroup{mygrshpic}[asgroup=""] |
| 634 |
\mpfig[off] |
| 635 |
draw pic2 ; |
| 636 |
\endmpfig |
| 637 |
\endmplibgroup |
| 638 |
\mpfig |
| 639 |
usemplibgroup "mygrshpic" |
| 640 |
withtransparency (1, 2/3) ; |
| 641 |
\endmpfig |
| 642 |
\mpfig % shading outside group |
| 643 |
draw pic1 |
| 644 |
asgroup "" |
| 645 |
withshadingmethod "circular" |
| 646 |
withshadingcolors (red, blue) |
| 647 |
withtransparency (1, 2/3) ; |
| 648 |
\endmpfig |
| 649 |
|
| 650 |
\leavevmode\qquad\qquad but this is the best:\marginpar{\leavevmode\llap{acrobat/foxit/firefox/chrome/mupdf/texworks/preview}} |
| 651 |
\mplibgroup{myshading} |
| 652 |
\mpfig[off] |
| 653 |
draw pic2; |
| 654 |
\endmpfig |
| 655 |
\endmplibgroup |
| 656 |
\mpfig |
| 657 |
usemplibgroup "myshading" asgroup "" withtransparency (1, 2/3) ; |
| 658 |
\endmpfig |
| 659 |
|
| 660 |
\mpfig[text] |
| 661 |
drawdot origin withpen pencircle scaled 2; |
| 662 |
draw btex go to section \ref{sec:my_section} \dots etex rotated 15 scaled 2 shifted (50,10); |
| 663 |
\endmpfig |
| 664 |
|
| 665 |
\leavevmode |
| 666 |
\mpfig |
| 667 |
color myorange; myorange = (1,3/4,0); |
| 668 |
draw image(fill makepath pensquare xscaled 160 yscaled 100 withoutcolor) |
| 669 |
withshadingmethod "circular" |
| 670 |
withshadingradius (0,80) |
| 671 |
withshadingmatrix "yscaled .5 rotated 23.5" |
| 672 |
withshadingtransform "no" |
| 673 |
withshadingfactor 1 |
| 674 |
withshadingextend (false, false) |
| 675 |
withshadingstep( |
| 676 |
withshadingfraction 1/8 |
| 677 |
withshadingcolors (myorange,red) |
| 678 |
) |
| 679 |
withshadingstep( |
| 680 |
withshadingfraction 2/8 |
| 681 |
withshadingcolors (red,myorange) |
| 682 |
) |
| 683 |
withshadingstep( |
| 684 |
withshadingfraction 3/8 |
| 685 |
withshadingcolors (myorange,red) |
| 686 |
) |
| 687 |
withshadingstep( |
| 688 |
withshadingfraction 4/8 |
| 689 |
withshadingcolors (red,myorange) |
| 690 |
) |
| 691 |
withshadingstep( |
| 692 |
withshadingfraction 5/8 |
| 693 |
withshadingcolors (myorange,red) |
| 694 |
) |
| 695 |
withshadingstep( |
| 696 |
withshadingfraction 6/8 |
| 697 |
withshadingcolors (red,myorange) |
| 698 |
) |
| 699 |
withshadingstep( |
| 700 |
withshadingfraction 7/8 |
| 701 |
withshadingcolors (myorange,red) |
| 702 |
) |
| 703 |
withshadingstep( |
| 704 |
withshadingfraction 8/8 |
| 705 |
withshadingcolors (red,myorange) |
| 706 |
) ; |
| 707 |
\endmpfig |
| 708 |
\mpfig |
| 709 |
fill makepath pensquare xscaled 160 yscaled 100 |
| 710 |
withshadingmethod "linear" |
| 711 |
withshadingcolors (red,blue) |
| 712 |
; |
| 713 |
draw image(fill makepath pensquare xscaled 160 yscaled 100 withcolor myorange) |
| 714 |
withfademethod "circular" |
| 715 |
withfaderadius (0,80) |
| 716 |
withfadematrix "yscaled .5 rotated 23.5" |
| 717 |
withfadestep( |
| 718 |
withfadefraction 1/8 |
| 719 |
withfadeopacity (0,1) |
| 720 |
) |
| 721 |
withfadestep( |
| 722 |
withfadefraction 2/8 |
| 723 |
withfadeopacity (1,0) |
| 724 |
) |
| 725 |
withfadestep( |
| 726 |
withfadefraction 3/8 |
| 727 |
withfadeopacity (0,1) |
| 728 |
) |
| 729 |
withfadestep( |
| 730 |
withfadefraction 4/8 |
| 731 |
withfadeopacity (1,0) |
| 732 |
) |
| 733 |
withfadestep( |
| 734 |
withfadefraction 5/8 |
| 735 |
withfadeopacity (0,1) |
| 736 |
) |
| 737 |
withfadestep( |
| 738 |
withfadefraction 6/8 |
| 739 |
withfadeopacity (1,0) |
| 740 |
) |
| 741 |
withfadestep( |
| 742 |
withfadefraction 7/8 |
| 743 |
withfadeopacity (0,1) |
| 744 |
) |
| 745 |
withfadestep( |
| 746 |
withfadefraction 8/8 |
| 747 |
withfadeopacity (1,0) |
| 748 |
) ; |
| 749 |
\endmpfig |
| 750 |
|
| 751 |
\mplibgroup{myshading}[asgroup="isolated, wrapped",matrix="rotated 15",colorspace="/DeviceGray"] |
| 752 |
\mpfig[off] |
| 753 |
draw image( |
| 754 |
pickup pencircle scaled 1; |
| 755 |
filldraw fullcircle scaled 60 withoutcolor; |
| 756 |
filldraw fullcircle scaled 60 shifted 25right withoutcolor; |
| 757 |
) |
| 758 |
withshadingmethod "linear" |
| 759 |
withshadingvector (1, 0) |
| 760 |
withshadingcolors (blue, green) ; |
| 761 |
\endmpfig |
| 762 |
\endmplibgroup |
| 763 |
\mpfig[alt=shading test, adjust-BBox=-10bp 6bp -9bp 14bp] |
| 764 |
drawdot origin withpen pencircle scaled 2; |
| 765 |
usemplibgroup "myshading" withtransparency (1, 2/3) ; |
| 766 |
\endmpfig |
| 767 |
\end{document} |