Changes

Jump to navigation Jump to search
983 bytes added ,  20:16, 20 September 2017
new
So you’d like to have one of these nice drop shadows behind some object? Here’s a piece of code to play with:

<texcode>
\startuniqueMPgraphic{mpshadow}
% these values are good for small text boxes
ox := 0 ; % offset x
oy := 0 ; % offset y
bx := 10 ; % bleed x
by := 0 ; % bleed y
rx := 5 ; % corner radius x
ry := 5 ; % corner radius y

for dx = 0 upto 10: % use more iterations for bigger boxes
dy := dx ;
xa := dx + ox - bx/2;
xb := \overlaywidth - dx + ox + bx/2;
ya := dy + oy - by/2;
yb := \overlayheight - dy + oy + by/2;

% rounded rectangle
fill (xa, ya + ry)---
(xa, yb - ry)..
(xa + rx, yb)---
(xb - rx, yb)..
(xb, yb - ry)---
(xb, ya + ry)..
(xb - rx, ya)---
(xa + rx, ya)..cycle
withcolor transparent(1, .04, black) ;
endfor;
setbounds currentpicture to OverlayBox ;
\stopuniqueMPgraphic

\defineoverlay[shadow][\useMPgraphic{mpshadow}]

\inframed[frame=off,background=shadow,foregroundcolor=white]{\bfa This text box has a shadow.}
</texcode>

Navigation menu