% output=pdftex engine=pdftex language=uk
%
% copyright=pragma-ade readme=readme.pdf licence=cc-by-nc-sa

\startcomponent mfun-018

\environment mfun-000

\chapter {Reference}

\startintro

In this chapter, we will demonstrate most of the drawing
related primitives and macros as present in plain \METAPOST\
and \METAFUN\ extensions.

If a path is shown and|/|or a transformation is applied, we
show the original in red and the transformed path or point
in yellow. The small dark gray crosshair is the origin and
the black rectangle the bounding box. In some drawings, in
light gray we show the points that makeup the path.

{\em Thist list is still incomplete and needs to be checked
against the formal syntax diagrams. There are also a couple
of \METAFUN\ macros added that need to find their way to
here.}

\stopintro

\section {Paths}

\ShowSampleA {mc} {pair}              {(1,.5)}
\ShowSampleA {mm} {pair .. pair}      {(0,0)..(.75,0)..(1,.25)..(1,1)}
\ShowSampleA {mm} {pair ... pair}     {(0,0)..(.75,0)...(1,.25)..(1,1)}
\ShowSampleA {mm} {pair -{}- pair}    {(0,0)--(.75,0)--(1,.25)--(1,1)}
\ShowSampleA {mm} {pair -{}-{}- pair} {(0,0)..(.75,0)---(1,.25)..(1,1)}

\ShowSampleA {mm} {pair softjoin pair}      {(0,0)..(.75,0) softjoin (1,.25)..(1,1)}
\ShowSampleA {mp} {controls pair}           {(0,0)..controls (.75,0)..(1,1)}
\ShowSampleA {mp} {controls pair and pair}  {(0,0)..controls (.75,0) and (1,.25)..(1,1)}
\ShowSampleA {mp} {tension numeric}         {(0,0)..(.75,0)..tension 2.5..(1,.25)..(1,1)}
\ShowSampleA {mp} {tension num.. and num..} {(0,0)..(.75,0)..tension 2.5 and 1.5..(1,.25)..(1,1)}
\ShowSampleA {mp} {tension atleast numeric} {(0,0)..(.75,0)..tension atleast 1..(1,.25)..(1,1)}

\ShowSampleA {mp} {cycle}        {(0,0)--(1,0)--(1,1)--cycle}
\ShowSampleA {mp} {curl numeric} {(0,0){curl 1}..(.75,0)..(1,.25)..(1,1)}
\ShowSampleA {mp} {dir numeric}  {(0,0){dir 30}..(1,1)}
\ShowSampleA {mm} {left}         {(0,0){left}..(1,1)}
\ShowSampleA {mm} {right}        {(0,0){right}..(1,1)}
\ShowSampleA {mm} {up}           {(0,0){up}..(1,1)}
\ShowSampleA {mm} {down}         {(0,0){down}..(1,1)}

\ShowSampleA {mp} {path \& path} {(0,0)..(.75,.25) & (.75,.25)..(1,1)}

\ShowSampleA {mv} {unitvector}  {origin--unitvector(1,1)}
\ShowSampleA {mp} {dir}         {origin--dir(45)}
\ShowSampleA {mp} {angle}       {origin--dir(angle(1,1))}

\ShowSampleA {mv} {fullcircle}  {fullcircle}
\ShowSampleA {fv} {unitcircle}  {unitcircle}
\ShowSampleA {fv} {fullsquare}  {fullsquare}
\ShowSampleA {mv} {unitsquare}  {unitsquare}
\ShowSampleA {fv} {fulldiamond} {fulldiamond}
\ShowSampleA {fv} {unitdiamond} {unitdiamond}

\ShowSampleA {mv} {halfcircle}    {halfcircle}
\ShowSampleA {mv} {quartercircle} {quartercircle}

\ShowSampleA {fv} {llcircle} {llcircle}
\ShowSampleA {fv} {lrcircle} {lrcircle}
\ShowSampleA {fv} {urcircle} {urcircle}
\ShowSampleA {fv} {ulcircle} {ulcircle}
\ShowSampleA {fv} {tcircle}  {tcircle}
\ShowSampleA {fv} {bcircle}  {bcircle}
\ShowSampleA {fv} {lcircle}  {lcircle}
\ShowSampleA {fv} {rcircle}  {rcircle}

\ShowSampleA {fv} {lltriangle} {lltriangle}
\ShowSampleA {fv} {lrtriangle} {lrtriangle}
\ShowSampleA {fv} {urtriangle} {urtriangle}
\ShowSampleA {fv} {ultriangle} {ultriangle}

\ShowSampleA {mm} {flex(pair,pair,pair)}
                  {flex ((0,0),(1,1),(1,0))}
\ShowSampleA {mm} {superellipse(pair,p..,p..,p..,num..)}
                  {superellipse((1,.5),(.5,1),(0,.5),(.5,0),.75)}

\ShowSampleA {fm} {path smoothed numeric/pair}   {unitsquare scaled 1.5 smoothed .2}
\ShowSampleA {fm} {path cornered numeric/pair}   {lltriangle scaled 1.5 cornered .2}
\ShowSampleA {fm} {path superellipsed numeric}   {unitsquare scaled 1.5 superellipsed .75}
\ShowSampleA {fm} {path randomized numeric/pair} {unitsquare scaled 1.5 randomized (.2,.2)}
\ShowSampleA {fm} {path squeezed numeric/pair}   {unitsquare scaled 1.5 squeezed (.2,.1)}

\ShowSampleB {fm} {punked path}
    {unitcircle scaled 1.5}
  {punked unitcircle scaled 1.5}

\ShowSampleB {fm} {curved path}
         {((0,0)--(.2,1)--(1,.2)--cycle)}
  {curved ((0,0)--(.2,1)--(1,.2)--cycle)}

\ShowSampleB {fm} {unspiked path}
           {((0,0)--(1,0)--(1,1)--(2,1)--(1,1)--(0,1)) shifted (-3,0)}
  {unspiked ((0,0)--(1,0)--(1,1)--(2,1)--(1,1)--(0,1))}

\ShowSampleB {fm} {simplified path}
             {((0,0)--(1,0)--(2,0)--(2,1)--(0,1)--cycle) shifted (-3,0)}
  {simplified ((0,0)--(1,0)--(2,0)--(2,1)--(0,1)--cycle)}

\ShowSampleB {fm} {path blownup numeric/pair}
             {fullcircle scaled 1.5}
  {(fullcircle scaled 1.5) blownup .1}

\ShowSampleB {fm} {path stretched numeric/pair}
             {fullcircle scaled 1.5}
  {(fullcircle scaled 1.5) stretched (1.1,0.8)}

\section {Transformations}

\ShowSampleB {mp} {path scaled numeric}        {fullcircle} {fullcircle scaled .50}
\ShowSampleB {mp} {path xscaled numeric}       {fullcircle} {fullcircle xscaled .25}
\ShowSampleB {mp} {path yscaled numeric}       {fullcircle} {fullcircle yscaled .25}
\ShowSampleB {mp} {path zscaled pair}          {fullcircle} {fullcircle zscaled (2,.25)}
\ShowSampleB {mp} {path xyscaled numeric/pair} {fullcircle} {fullcircle xyscaled (.5,.7)}
\ShowSampleB {mp} {path xyscaled pair}         {fullcircle} {fullcircle xyscaled (2,.25)}
\ShowSampleB {mp} {path shifted pair}          {fullcircle} {fullcircle shifted (2,.25)}

\ShowSampleB {fm} {path leftenlarged   numeric} {fullsquare} {fullsquare leftenlarged .25}
\ShowSampleB {fm} {path topenlarged    numeric} {fullsquare} {fullsquare topenlarged .25}
\ShowSampleB {fm} {path rightenlarged  numeric} {fullsquare} {fullsquare rightenlarged .25}
\ShowSampleB {fm} {path bottomenlarged numeric} {fullsquare} {fullsquare bottomenlarged .25}

\ShowSampleB {fm} {path enlarged numeric}   {fullcircle} {fullcircle enlarged .25}
\ShowSampleB {fm} {path enlarged pair}      {fullcircle} {fullcircle enlarged (1,.25)}
\ShowSampleB {fm} {path llenlarged numeric} {fullcircle} {fullcircle llenlarged .25}
\ShowSampleB {fm} {path lrenlarged numeric} {fullcircle} {fullcircle lrenlarged .25}
\ShowSampleB {fm} {path urenlarged numeric} {fullcircle} {fullcircle urenlarged .25}
\ShowSampleB {fm} {path ulenlarged numeric} {fullcircle} {fullcircle ulenlarged .25}
\ShowSampleB {fm} {path llenlarged pair}    {fullcircle} {fullcircle llenlarged (1,.25)}
\ShowSampleB {fm} {path lrenlarged pair}    {fullcircle} {fullcircle lrenlarged (1,.25)}
\ShowSampleB {fm} {path urenlarged pair}    {fullcircle} {fullcircle urenlarged (1,.25)}
\ShowSampleB {fm} {path ulenlarged pair}    {fullcircle} {fullcircle ulenlarged (1,.25)}
\ShowSampleB {fm} {path llmoved numeric}    {fullcircle} {fullcircle llmoved .25}
\ShowSampleB {fm} {path lrmoved numeric}    {fullcircle} {fullcircle lrmoved .25}
\ShowSampleB {fm} {path urmoved numeric}    {fullcircle} {fullcircle urmoved .25}
\ShowSampleB {fm} {path ulmoved numeric}    {fullcircle} {fullcircle ulmoved .25}
\ShowSampleB {fm} {path llmoved pair}       {fullcircle} {fullcircle llmoved (1,.25)}
\ShowSampleB {fm} {path lrmoved pair}       {fullcircle} {fullcircle lrmoved (1,.25)}
\ShowSampleB {fm} {path urmoved pair}       {fullcircle} {fullcircle urmoved (1,.25)}
\ShowSampleB {fm} {path ulmoved pair}       {fullcircle} {fullcircle ulmoved (1,.25)}
\ShowSampleB {mp} {path slanted numeric}    {fullcircle} {fullcircle slanted .5}
\ShowSampleB {mp} {path rotated numeric}    {fullsquare} {fullsquare rotated 45}

\ShowSampleB {mm} {path rotatedaround(pair,numeric)}  {fullsquare} {fullsquare rotatedaround((.25,.5),45)}
\ShowSampleB {mm} {path reflectedabout(pair,pair)}    {fullcircle} {fullcircle reflectedabout((.25,-1),(.25,+1))}
\ShowSampleB {mp} {reverse path}                      {fullcircle} {reverse fullcircle shifted(.5,0)}
\ShowSampleB {mm} {counterclockwise path}             {fullcircle} {counterclockwise fullcircle shifted(.5,0)}
\ShowSampleB {mm} {tensepath path}                    {fullcircle} {tensepath fullcircle}

\ShowSampleB {mp} {subpath (numeric,numeric) of path} {fullcircle} {subpath (1,5) of fullcircle}
\ShowSampleB {mm} {path cutbefore pair} {fullcircle} {fullcircle cutbefore point 3 of fullcircle}
\ShowSampleB {mm} {path cutafter  pair} {fullcircle} {fullcircle cutafter point 3 of fullcircle}
\ShowSampleB {mm} {path cutends .1} {fullcircle} {fullcircle cutends .5}

\ShowSampleC {mp} {llcorner path} {fullcircle} {llcorner fullcircle}
\ShowSampleC {mp} {lrcorner path} {fullcircle} {lrcorner fullcircle}
\ShowSampleC {mp} {urcorner path} {fullcircle} {urcorner fullcircle}
\ShowSampleC {mp} {ulcorner path} {fullcircle} {ulcorner fullcircle}
\ShowSampleC {mm} {center   path} {fullcircle} {center   fullcircle}

\ShowSampleD {fm} {boundingbox      path} {fullcircle} {boundingbox fullcircle}
\ShowSampleD {fm} {innerboundingbox path} {fullcircle} {innerboundingbox fullcircle}
\ShowSampleD {fm} {outerboundingbox path} {fullcircle} {outerboundingbox fullcircle}

\ShowSampleDD {fm} {bottomboundary path} {fullcircle} {bottomboundary fullcircle}
\ShowSampleDD {fm} {leftboundary   path} {fullcircle} {leftboundary fullcircle}
\ShowSampleDD {fm} {topboundary    path} {fullcircle} {topboundary fullcircle}
\ShowSampleDD {fm} {rightboundary  path} {fullcircle} {rightboundary fullcircle}

\ShowSampleE {fm} {path/picture xsized numeric}  {xsized 3cm} {currentpicture xsized 5cm}
\ShowSampleE {fm} {path/picture ysized numeric}  {ysized 2cm} {currentpicture ysized 2cm}
\ShowSampleE {fm} {path/picture xysized numeric} {xysized (3cm,2cm)} {currentpicture xysized (3cm,2cm)}

\section {Points}

%ShowSampleF {mp} {center path}                 {fullcircle}     {center fullcircle}
\ShowSampleF {mm} {top pair}                    {fullcircle} {top center fullcircle}
\ShowSampleF {mm} {bot pair}                    {fullcircle} {bot center fullcircle}
\ShowSampleF {mm} {lft pair}                    {fullcircle} {lft center fullcircle}
\ShowSampleF {mm} {rt pair}                     {fullcircle} {rt  center fullcircle}
\ShowSampleF {mp} {point       numeric of path} {fullcircle} {point 2 of fullcircle}
\ShowSampleF {fm} {point       numeric on path} {fullcircle} {point .5 on fullcircle}
\ShowSampleF {fm} {point    numeric along path} {fullcircle} {point 1cm along fullcircle}
\ShowSampleF {mp} {precontrol  numeric of path} {fullcircle} {precontrol 2 of fullcircle}
\ShowSampleF {mp} {postcontrol numeric of path} {fullcircle} {postcontrol 2 of fullcircle}
\ShowSampleF {mp} {directionpoint pair of path} {fullcircle} {directionpoint (2,3) of fullcircle}

\ShowSampleG {mc} {numeric[pair,pair]} {(1,1)} {.5[(0,0),(1,1)]}

\ShowSampleH {mm} {path intersectionpoint path} {fullcircle} {fulldiamond}
                  {fullcircle intersectionpoint fulldiamond}

\section {Attributes}

\ShowSampleI {mp} {withcolor color} {withcolor (.625,0,0)}
\ShowSampleI {fm} {withcolor cmyk}  {withcolor cmyk(0,.625,.625,0)}
\ShowSampleI {fm} {withcolor transparent(num,num,color)} {withcolor transparent(1,.625,red)}

\ShowSampleZ {fm} {withshade numeric} {Shades need to be declared before they can be (re)used.}

\ShowSampleII {mp} {dashed withdots} {dashed withdots}
\ShowSampleII {mp} {dashed evenly}   {dashed evenly}

\ShowSampleJ {mm} {pencircle transform} {pencircle}
\ShowSampleJ {mm} {pensquare transform} {pensquare}
\ShowSampleJ {mm} {penrazor transform}  {penrazor}

\ShowSampleK {mm} {penspeck transform}  {penspeck}

\ShowSampleL {mm} {draw}      {fullcircle}
\ShowSampleL {mm} {fill}      {fullcircle}
\ShowSampleL {mm} {filldraw}  {fullcircle}
\ShowSampleL {mm} {drawfill}  {fullcircle}
\ShowSampleL {mm} {drawdot}   {origin}
\ShowSampleL {mm} {drawarrow} {fullcircle}

\ShowSampleM {mm} {undraw}     {fullcircle}
\ShowSampleM {mm} {unfill}     {fullcircle}
\ShowSampleM {mm} {unfilldraw} {fullcircle}
\ShowSampleM {mm} {undrawfill} {fullcircle}
\ShowSampleM {mm} {undrawdot}  {origin}

\ShowSampleQ {mm} {cutdraw} {origin--(1,1)}

\ShowSampleN {mv} {butt}    {linecap := butt}    {(0,.5)--(.5,0)--(1,1)}
\ShowSampleN {mv} {rounded} {linecap := rounded} {(0,.5)--(.5,0)--(1,1)}
\ShowSampleN {mv} {squared} {linecap := squared} {(0,.5)--(.5,0)--(1,1)}

\ShowSampleN {mv} {mitered} {linejoin := mitered} {(0,.5)--(.5,0)--(1,1)}
\ShowSampleN {mv} {rounded} {linejoin := rounded} {(0,.5)--(.5,0)--(1,1)}
\ShowSampleN {mv} {beveled} {linejoin := beveled} {(0,.5)--(.5,0)--(1,1)}

\ShowSampleR {fm} {inverted picture}         {inverted currentpicture}
\ShowSampleR {fm} {picture uncolored color}  {currentpicture uncolored green}
\ShowSampleR {fm} {picture softened numeric} {currentpicture softened .8}
\ShowSampleR {fm} {picture softened color}   {currentpicture softened (.7,.8,.9)}
\ShowSampleR {fm} {grayed picture}           {grayed currentpicture}

\section {Text}

\ShowSampleO {mm} {label}           {label("MetaFun",origin)}
\ShowSampleO {mm} {label.top}   {label.top("MetaFun",origin)}
\ShowSampleO {mm} {label.bot}   {label.bot("MetaFun",origin)}
\ShowSampleO {mm} {label.lft}   {label.lft("MetaFun",origin)}
\ShowSampleO {mm} {label.rt}     {label.rt("MetaFun",origin)}
\ShowSampleO {mm} {label.llft} {label.llft("MetaFun",origin)}
\ShowSampleO {mm} {label.lrt}   {label.lrt("MetaFun",origin)}
\ShowSampleO {mm} {label.urt}   {label.urt("MetaFun",origin)}
\ShowSampleO {mm} {label.ulft} {label.ulft("MetaFun",origin)}

\ShowSampleP {mp}
  {btex text etex}
  {draw btex MetaTeX etex}

\ShowSampleQQ {fm}
  {textext(string)}
  {draw textext("MetaFun")}

\ShowSampleQQ {fm}
  {graphictext string ...}
  {graphictext "MetaFun"}

\section {Graphics}

\ShowSampleS {fm}
  {loadfigure string number numeric ...}
  {loadfigure "mycow.mp" number 1 scaled .25}

\ShowSampleS {fm}
  {externalfigure string ...}
  {externalfigure "mycow.pdf" scaled 3cm}

\stopcomponent
