[NTG-context] Speech bubbles

Wolfgang Schuster schuster.wolfgang at googlemail.com
Thu Feb 3 09:39:56 CET 2011


Am 02.02.2011 um 18:12 schrieb Ian Lawrence:

> Evening all:
> 
> Has anyone got a nicer \speechbubble definition up their sleeve?
> 
> Here is not-nice one, so you know the floor:
> 
> \define [1] \speechBubble 
> {\blank
> \framed [width=.6\textwidth ,autowidth=force,align={flushleft}, background=color, backgroundcolor=darkblue,
>   foreground=color, foregroundcolor=white,
>  frame=off,corner=0,backgroundoffset=5pt,]  {#1}
> ~~~ \tfd \startcolor[darkblue]{'} \stopcolor \tfa
>  \blank}
> 
> 
> Called with things like:
> 
> \speechBubble {They could be above or below the frequency we can hear, so called infra-sound or ultra-sound, or the amplitude could be just too small: so not enough power in the radiating pathway for the detector to respond.}
> 
> 
> I guess there are some people with xs metapost skills out there... But is there as simple way to get a nice curved pointer left or right from the bottom of that rounded rectangle frame?

\startuseMPgraphic{speechbubble}
z1 = (0,0) ; z2 = (OverlayWidth,0) ; z3 = (OverlayWidth,OverlayHeight) ; z4 = (0,OverlayHeight) ;
1/2[x1,x2] = x8 + 2cm = x7 + 1cm = x9 - 1cm ; y7 = y9 = 0cm ; y8 = -2cm ;
path p ; p = z1--z7--z8--z9--z2--z3--z4--cycle ;
fill p withcolor blue ;
draw p withpen pencircle scaled 5 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineoverlay[speechbubble][\useMPgraphic{speechbubble}]

\starttext 

\framedtext[frame=off,background=speechbubble]{\input ward }

\blank[4cm]

\framedtext[frame=off,background=speechbubble,width=6cm]{\input ward }

\stoptext

Wolfgang



More information about the ntg-context mailing list