Re: [dev-context] Additional framed fences

2011-11-20 Thread Hans Hagen

On 19-11-2011 23:11, Aditya Mahajan wrote:


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


ok (but I added a namespace to the mp code)

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
dev-context mailing list
dev-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/dev-context


[dev-context] Additional framed fences

2011-11-19 Thread Aditya Mahajan

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\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}}