[dev-context] Additional framed fences

Aditya Mahajan adityam at umich.edu
Sat Nov 19 23:11:40 CET 2011


Hans,

Can you change the definition of setinstalledframeddimensions in 
pack-fen.mkiv to:

\def\setinstalledframedimensions
   {\edef\overlaywidth {\the\frameddimenwd\space}%
    \edef\overlayheight{\the\dimexpr\frameddimenht+\frameddimendp\relax\space}%
    \edef\overlaydepth {\the\frameddimendp\space}%
    \edef\overlaycolor {\framedparameter\c!backgroundcolor}%
    \edef\overlaylinecolor{\framedparameter\c!framecolor}%
    \edef\overlaylinewidth{\the\ruledlinewidth}}


and include the attached file as part of meta-imp-fen.mkiv?

This is based on an example by Marcin on TeX.se: 
http://tex.stackexchange.com/questions/34482/contest-show-off-your-skillz-in-tex-friends-tex-sx-birthday/35211#35211

Thanks,
Aditya
-------------- next part --------------
\unprotect

% Hooked fences: lefthook, righthook, tophook, and bottomhook.
% The parameter \type{radius} determine the radius of the hook.
% The parameter \type{hook} determines the length of the hook.

\startMPextensions
    vardef BasicHook (expr size, radius, hook) =
        ((0,0) --- (size - radius, 0){right} .. {up}(size, radius) --- (size, hook))
    enddef;
\stopMPextensions

\startuseMPgraphic{bottom_right_hook}
  save radius, hook ;
  radius := \the\dimexpr\framedparameter\c!frameradius\relax;
  hook   := \the\dimexpr\framedparameter{hook}\relax;
  
   draw BasicHook(OverlayWidth, radius, hook)
        withpen pencircle scaled OverlayLineWidth
        withcolor OverlayLineColor;

   setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\startuseMPgraphic{bottom_left_hook}
  save radius, hook ;
  radius := \the\dimexpr\framedparameter\c!frameradius\relax;
  hook   := \the\dimexpr\framedparameter{hook}\relax;
  
   draw BasicHook(OverlayWidth, radius, hook) 
        reflectedabout ((0.5OverlayWidth, 0), (0.5OverlayWidth, OverlayHeight))
        withpen pencircle scaled OverlayLineWidth
        withcolor OverlayLineColor;

   setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\startuseMPgraphic{top_right_hook}
  save radius, hook ;
  radius := \the\dimexpr\framedparameter\c!frameradius\relax;
  hook   := \the\dimexpr\framedparameter{hook}\relax;
  
   draw BasicHook(OverlayWidth, radius, hook) 
        reflectedabout ((0,0),(OverlayWidth,0))
        shifted (0,OverlayHeight)
        withpen pencircle scaled OverlayLineWidth
        withcolor OverlayLineColor;

   setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\startuseMPgraphic{left_top_hook}
  save radius, hook ;
  radius := \the\dimexpr\framedparameter\c!frameradius\relax;
  hook   := \the\dimexpr\framedparameter{hook}\relax;
  
   draw BasicHook(OverlayWidth, radius, hook) 
        reflectedabout ((0.5OverlayWidth, 0), (0.5OverlayWidth, OverlayHeight))
        reflectedabout ((0,0),(OverlayWidth,0))
        shifted (0,OverlayHeight)
        withpen pencircle scaled OverlayLineWidth
        withcolor OverlayLineColor;

   setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\startuseMPgraphic{left_bottom_hook}
  save radius, hook ;
  radius := \the\dimexpr\framedparameter\c!frameradius\relax;
  hook   := \the\dimexpr\framedparameter{hook}\relax;
  
   draw BasicHook(OverlayHeight, radius, hook) 
        rotated -90
        shifted (0,OverlayHeight)
        withpen pencircle scaled OverlayLineWidth
        withcolor OverlayLineColor;

   setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\startuseMPgraphic{left_top_hook}
  save radius, hook ;
  radius := \the\dimexpr\framedparameter\c!frameradius\relax;
  hook   := \the\dimexpr\framedparameter{hook}\relax;
  
   draw BasicHook(OverlayHeight, radius, hook) 
        reflectedabout ((0,0),(OverlayWidth,0))
        rotated 90
        withpen pencircle scaled OverlayLineWidth
        withcolor OverlayLineColor;

   setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\startuseMPgraphic{right_top_hook}
  save radius, hook ;
  radius := \the\dimexpr\framedparameter\c!frameradius\relax;
  hook   := \the\dimexpr\framedparameter{hook}\relax;
  
   draw BasicHook(OverlayHeight, radius, hook) 
        rotated 90
        shifted (OverlayWidth,0)
        withpen pencircle scaled OverlayLineWidth
        withcolor OverlayLineColor;

   setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\startuseMPgraphic{right_bottom_hook}
  save radius, hook ;
  radius := \the\dimexpr\framedparameter\c!frameradius\relax;
  hook   := \the\dimexpr\framedparameter{hook}\relax;
  
   draw BasicHook(OverlayHeight, radius, hook) 
        reflectedabout ((0,0),(OverlayWidth,0))
        rotated -90
        shifted (OverlayWidth,OverlayHeight)
        withpen pencircle scaled OverlayLineWidth
        withcolor OverlayLineColor;

   setbounds currentpicture to OverlayBox;
\stopuseMPgraphic


\installtopframerenderer    {righthook}{\useMPgraphic{top_right_hook}}
\installtopframerenderer     {lefthook}{\useMPgraphic{top_left_hook}}

\installbottomframerenderer {righthook}{\useMPgraphic{bottom_right_hook}}
\installbottomframerenderer  {lefthook}{\useMPgraphic{bottom_left_hook}}

\installleftframerenderer  {bottomhook}{\useMPgraphic{left_bottom_hook}}
\installleftframerenderer     {tophook}{\useMPgraphic{left_top_hook}}

\installrightframerenderer {bottomhook}{\useMPgraphic{right_bottom_hook}}
\installrightframerenderer    {tophook}{\useMPgraphic{right_top_hook}}

\setupframed
  [hook=\framedparameter\c!radius]

\protect

\continueifinputfile{meta-imp-hooks.mkiv}

\setupcolors[state=start]
% \setupframed[offset=none]
\starttext
\framed[frame=off,bottomframe=righthook]{Bottom right hook}

\framed[frame=off,bottomframe=lefthook,rulethickness=2bp]{Bottom left hook}

\blank

\framed[frame=off,topframe=righthook,rulethickness=2bp]{Top right hook}

\blank

\framed[frame=off,topframe=lefthook,rulethickness=2bp]{Top left hook}

\framed[frame=off,bottomframe=righthook,framecolor=green,rulethickness=2bp]{Changing colors}

\framed[align=normal,frame=off, hook=1cm, leftframe=bottomhook]{\input zapf \endgraf}

\blank
\framed[align=normal,frame=off, hook=1cm, leftframe=tophook]{\input zapf \endgraf}

\blank
\framed[align=normal,frame=off, hook=1cm, rightframe=tophook]{\input zapf \endgraf}

\blank
\framed[align=normal,frame=off, hook=1cm, rightframe=bottomhook]{\input zapf \endgraf}
\stoptext



More information about the dev-context mailing list