From df12f144a2cb09cec29a95df26bdfc5ccad58aff Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Tue, 27 Jul 2021 19:52:30 +0200 Subject: 2021-07-27 19:27:00 --- metapost/context/base/mpiv/mp-xbox.mpiv | 33 ++++++++++++++++++++++++++++++++- metapost/context/base/mpxl/mp-lmtx.mpxl | 8 ++++---- 2 files changed, 36 insertions(+), 5 deletions(-) (limited to 'metapost') diff --git a/metapost/context/base/mpiv/mp-xbox.mpiv b/metapost/context/base/mpiv/mp-xbox.mpiv index be5630a5e..ff3bbc27a 100644 --- a/metapost/context/base/mpiv/mp-xbox.mpiv +++ b/metapost/context/base/mpiv/mp-xbox.mpiv @@ -5,7 +5,12 @@ % copyright : Public domain % patched : Hans Hagen % -% The code is the same but I've added s boxes_ namespace for soem so that we don't +% author : Karl Berry +% version : $Id: rboxes.mp,v 1.2 2004/09/19 21:47:11 karl Exp $ +% copyright : Public domain +% patched : Hans Hagen +% +% The code is the same but I've added a boxes_ namespace for some so that we don't % clash with metafun. if known metafun_loaded_xbox : endinput ; fi ; @@ -296,3 +301,29 @@ if makingfigure : boxes_init_all; fi ; +% Rectangular boxes with rounded corners + +newinternal rbox_radius ; rbox_radius := 8bp ; + +vardef rboxit@#(text tt) = + boxes_begin("boxes_the_rounded","boxes_size",@#,tt) ; + boxes_generic_declare (pair) _n.sw, _n.s, _n.se, _n.e, _n.ne, _n.n, _n.nw, _n.w ; + 0 = xpart(@#nw - @#sw) = ypart(@#se - @#sw) ; + 0 = xpart(@#ne - @#se) = ypart(@#ne - @#nw) ; + @#w = .5[@#nw,@#sw] ; + @#s = .5[@#sw,@#se] ; + @#e = .5[@#ne,@#se] ; + @#n = .5[@#ne,@#nw] ; + @#ne - @#c = @#c - @#sw = (@#dx,@#dy) + .5*(urcorner boxes_pic@# - llcorner boxes_pic@#) ; + boxes_end(boxes_clear,@#) ; +enddef; + +def boxes_the_rounded(suffix $) = + save _r ; _r = min(rbox_radius, .5*ypart($.n-$.s), .5*xpart($.e-$.w)); + $.sw + (_r,0) {right} .. {right} $.se - (_r,0) .. + $.se + (0,_r) {up} .. {up} $.ne - (0,_r) .. + $.ne - (_r,0) {left} .. {left} $.nw + (_r,0) .. + $.nw - (0,_r) {down} .. {down} $.sw + (0,_r) .. + cycle +enddef; + diff --git a/metapost/context/base/mpxl/mp-lmtx.mpxl b/metapost/context/base/mpxl/mp-lmtx.mpxl index 9984ab805..c7461a5d1 100644 --- a/metapost/context/base/mpxl/mp-lmtx.mpxl +++ b/metapost/context/base/mpxl/mp-lmtx.mpxl @@ -2344,13 +2344,13 @@ permanent % nice hack -newscriptindex mfid_scrutenized ; mfid_scrutenized := scriptindex "scrutenized" ; +newscriptindex mfid_scrutinized ; mfid_scrutinized := scriptindex "scrutinized" ; -primarydef p scrutenized n = - runscript mfid_scrutenized p n +primarydef p scrutinized n = + runscript mfid_scrutinized p n enddef ; -permanent scrutenized ; +permanent scrutinized ; % for now here -- cgit v1.2.3