[NTG-context] Speech bubbles

Ian Lawrence physics.wanderer at gmail.com
Thu Feb 3 16:09:32 CET 2011


Thanks Wolfgang..

In case there are any others who are in need.. Here is one with curvy speech bubbles, left and right, and wrapped up so they don't overhang any text.
__

\startuseMPgraphic{speechL}
z1 = (0.25cm,0) ; z2=(1 cm,0) ; z3 = (0,-1cm) ; z4 = (2cm,0);z5 = (OverlayWidth-0.25cm,0) ; z6 = (OverlayWidth,0.25cm) ; z7 = (OverlayWidth,OverlayHeight-0.25cm) ; z8 = (OverlayWidth-0.25cm,OverlayHeight) ; z9 = (0.25 cm,OverlayHeight);z10=(0,OverlayHeight-0.25cm) ; z11=(0,0.25cm)  ;
path p ; p = z1--z2{down}..{dir 270}z3{dir 30}..{dir 70}z4--z5{right}..{up}z6--z7{up}..{left}z8--z9{left}..{down}z10--z11{down}..{right}z1--cycle ;
fill p withcolor blue ;
draw p withpen pencircle scaled 1 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{speechR}
z1 = (0.25cm,0) ; z2=(5 cm,0) ; z3 = (7cm,-1cm) ; z4 = (6cm,0);z5 = (OverlayWidth-0.25cm,0) ; z6 = (OverlayWidth,0.25cm) ; z7 = (OverlayWidth,OverlayHeight-0.25cm) ; z8 = (OverlayWidth-0.25cm,OverlayHeight) ; z9 = (0.25 cm,OverlayHeight);z10=(0,OverlayHeight-0.25cm) ; z11=(0,0.25cm)  ;
path p ; p = z1{left}..{up}z11--z10{up}..{right}z9--z8{right}..{down}z7--z6{down}..{left}z5--z4{down}..{dir 270}z3{dir 150}..{dir 110}z2--cycle ;
fill p withcolor blue ;
draw p withpen pencircle scaled 1 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic


\defineoverlay[speechL][\useMPgraphic{speechL}]

\define [1] \speechbubbleL
{\blank
\framedtext[frame=off,background=speechL, width=7cm]{#1}
\blank[1 cm]}]

\defineoverlay[speechR][\useMPgraphic{speechR}]

\define [1] \speechbubbleR
{\blank
\framedtext[frame=off,background=speechR, width=7cm]{#1}
\blank[1 cm]}]



\starttext
Some text

\speechbubbleL {'Who needs highlighter pens, anyway?'}

If all three are satisfied then then sound radiates from the source to the detector. The source-medium-detector model was central to the model of sound. The vibrations, because of their nature, travel as variations in physical density, so rely on a medium made of particles connecting the source to the detector. Other vibrations, very similar in nature, could still travel out from the source, but not be detected. 

\speechbubbleR  {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.}

More and more dog latin for beginners.. And so on...... And so on
\stoptext
__
Sorry the metapost is not parameterised...I should have variables in to set up the offsets and curvature of the corners. But I have not go that far yet...my floor is only a little higher, thanks to Wolfgang.

On 3 Feb 2011, at 08:39, Wolfgang Schuster wrote:

> 
> 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
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________



More information about the ntg-context mailing list