Difference between revisions of "textext positioning"

From Wiki
Jump to navigation Jump to search
m
Line 1: Line 1:
 
<context mode="mkiv" source="yes">
 
<context mode="mkiv" source="yes">
  
\define[1]\MyFont{\definedfont[#1]\ignorespaces}
+
 
 
 
\starttext
 
\starttext
  
 +
\setupMPinstance
 +
  [metafun]
 +
  [textstyle={\definedfont[name:dejavusans*default at 25pt]\ignorespaces}]
 +
 
 
\startMPpage
 
\startMPpage
  
Line 16: Line 19:
 
pair PA ;  PA := (10cm,16cm) ;
 
pair PA ;  PA := (10cm,16cm) ;
 
    
 
    
draw textext.urt("\ruledhbox{\MyFont{name:dejavusans*default at 25pt}  URT Aujourd'hui}") shifted PA;
+
draw textext.urt("\ruledhbox{URT Aujourd'hui}") shifted PA;
draw textext.ulft("\ruledhbox{\MyFont{name:dejavusans*default at 25pt} ULFT Aujourd'hui}") shifted PA;
+
draw textext.ulft("\ruledhbox{ULFT Aujourd'hui}") shifted PA;
  
draw textext.llft("\ruledhbox{\MyFont{name:dejavusans*default at 25pt} LLFT Aujourd'hui}") shifted PA;
+
draw textext.llft("\ruledhbox{LLFT Aujourd'hui}") shifted PA;
draw textext.lrt("\ruledhbox{\MyFont{name:dejavusans*default at 25pt}  LRT Aujourd'hui}")  shifted PA;
+
draw textext.lrt("\ruledhbox{LRT Aujourd'hui}")  shifted PA;
  
 
draw PA withpen pencircle scaled 1.5mm  withcolor red;
 
draw PA withpen pencircle scaled 1.5mm  withcolor red;
Line 28: Line 31:
 
pair PB ;  PB := PA shifted (0cm,-2cm) ;
 
pair PB ;  PB := PA shifted (0cm,-2cm) ;
 
    
 
    
draw textext.drt("\ruledhbox{\MyFont{name:dejavusans*default at 25pt}  DRT Aujourd'hui}") shifted PB;
+
draw textext.drt("\ruledhbox{DRT Aujourd'hui}") shifted PB;
draw textext.dlft("\ruledhbox{\MyFont{name:dejavusans*default at 25pt} DLFT Aujourd'hui}") shifted PB;
+
draw textext.dlft("\ruledhbox{DLFT Aujourd'hui}") shifted PB;
  
 
draw PB withpen pencircle scaled 1.5mm  withcolor red;
 
draw PB withpen pencircle scaled 1.5mm  withcolor red;
Line 37: Line 40:
 
pair PC ;  PC := PB shifted (0cm,-2cm) ;
 
pair PC ;  PC := PB shifted (0cm,-2cm) ;
 
    
 
    
draw textext.d("\ruledhbox{\MyFont{name:dejavusans*default at 25pt} D Aujourd'hui}") shifted PC;
+
draw textext.d("\ruledhbox{D Aujourd'hui}") shifted PC;
  
  
Line 46: Line 49:
 
pair PD ;  PD := PC shifted (0cm,-2cm) ;
 
pair PD ;  PD := PC shifted (0cm,-2cm) ;
 
    
 
    
draw textext.bot("\ruledhbox{\MyFont{name:dejavusans*default at 25pt} BOT Aujourd'hui}")  shifted PD;
+
draw textext.bot("\ruledhbox{BOT Aujourd'hui}")  shifted PD;
draw textext.top("\ruledhbox{\MyFont{name:dejavusans*default at 25pt} TOP Aujourd'hui}") shifted PD;
+
draw textext.top("\ruledhbox{TOP Aujourd'hui}") shifted PD;
  
 
draw PD withpen pencircle scaled 1.5mm  withcolor red;
 
draw PD withpen pencircle scaled 1.5mm  withcolor red;
Line 55: Line 58:
 
pair PE ;  PE := PD shifted (0cm,-2cm) ;
 
pair PE ;  PE := PD shifted (0cm,-2cm) ;
 
    
 
    
draw textext.lft("\ruledhbox{\MyFont{name:dejavusans*default at 25pt} LFT Aujourd'hui}") shifted PE;
+
draw textext.lft("\ruledhbox{LFT Aujourd'hui}") shifted PE;
draw textext.rt("\ruledhbox{\MyFont{name:dejavusans*default at 25pt} RT Aujourd'hui}") shifted PE;
+
draw textext.rt("\ruledhbox{RT Aujourd'hui}") shifted PE;
  
 
draw PE withpen pencircle scaled 1.5mm  withcolor red;
 
draw PE withpen pencircle scaled 1.5mm  withcolor red;
Line 64: Line 67:
 
pair PF ;  PF := PE shifted (0cm,-2cm) ;
 
pair PF ;  PF := PE shifted (0cm,-2cm) ;
 
    
 
    
draw textext("\ruledhbox{\MyFont{name:dejavusans*default at 25pt} Aujourd'hui}") shifted PF;
+
draw textext("\ruledhbox{Aujourd'hui}") shifted PF;
  
 
draw PF withpen pencircle scaled 1.5mm  withcolor red;
 
draw PF withpen pencircle scaled 1.5mm  withcolor red;
Line 72: Line 75:
 
pair PG ;  PG := PF shifted (0cm,-2cm) ;
 
pair PG ;  PG := PF shifted (0cm,-2cm) ;
 
    
 
    
draw textext.origin("\ruledhbox{\MyFont{name:dejavusans*default at 25pt}ORIGIN Aujourd'hui}") shifted PG;
+
draw textext.origin("\ruledhbox{ORIGIN Aujourd'hui}") shifted PG;
  
 
draw PG withpen pencircle scaled 1.5mm  withcolor red;
 
draw PG withpen pencircle scaled 1.5mm  withcolor red;
Line 80: Line 83:
 
pair PH ;  PH := PG shifted (0cm,-2cm) ;
 
pair PH ;  PH := PG shifted (0cm,-2cm) ;
 
    
 
    
draw textext.raw("\ruledhbox{\MyFont{name:dejavusans*default at 25pt}RAW Aujourd'hui}") shifted PH;
+
draw textext.raw("\ruledhbox{RAW Aujourd'hui}") shifted PH;
  
 
draw PH withpen pencircle scaled 1.5mm  withcolor red;
 
draw PH withpen pencircle scaled 1.5mm  withcolor red;
  
 
%------------------------------------------------------------------------------
 
%------------------------------------------------------------------------------
 +
 +
\stopMPpage
 +
 +
 +
%==============================================================================
 +
%==============================================================================
 +
%==============================================================================
 +
 +
\setupMPinstance
 +
  [metafun]
 +
  [textstyle={\definedfont[name:dejavusans*default at 50pt]\ignorespaces}]
 +
 +
\startMPpage
 +
 +
draw (0cm,0cm)--(20cm,0cm)--(20cm,20cm)--(0cm,20cm)--cycle
 +
  withpen pencircle
 +
  scaled 0.5mm
 +
  withcolor red;
 +
 +
%------------------------------------------------------------------------------
 +
 +
picture PictA ;
 +
 +
pair PA ;  PA := (5cm,12cm) ;
 +
 +
PictA := textext.urt("\ruledhbox{Aujourd'hui}") shifted PA;
 +
draw PictA;
 +
 +
%------------------------------------------------------------------------------
 +
 +
draw (llcorner PictA) withpen pencircle scaled 3mm  withcolor green;
 +
draw (lrcorner PictA) withpen pencircle scaled 3mm  withcolor yellow;
 +
draw (urcorner PictA) withpen pencircle scaled 3mm  withcolor blue;
 +
draw (ulcorner PictA) withpen pencircle scaled 3mm  withcolor cyan;
 +
 +
%------------------------------------------------------------------------------
 +
 +
picture PictB, PictC ;
 +
 +
pair PB ;  PB := PA shifted (0cm,-4cm) ;
 +
 +
PictB := textext.urt("\ruledhbox{Aujourd'hui}") shifted PB;
 +
PictC := textext.drt("\ruledhbox{Aujourd'hui}") shifted PB;
 +
 +
draw PictB;
 +
 +
pair decalage ;
 +
decalage = llcorner PictB - llcorner PictC;
 +
 +
%------------------------------------------------------------------------------
 +
 +
draw (center PictB)        withpen pencircle scaled 3mm  withcolor green;
 +
 +
draw (PB shifted decalage) withpen pencircle scaled 3mm  withcolor yellow;
 +
draw (PB shifted (decalage shifted (bbwidth PictB / 2,0mm)))
 +
                          withpen pencircle scaled 3mm  withcolor blue;
 +
draw (PB shifted (decalage shifted (bbwidth PictB,0mm)))
 +
                          withpen pencircle scaled 3mm  withcolor cyan;
 +
 +
draw PA            withpen pencircle scaled 1.5mm  withcolor red;
 +
  
 
\stopMPpage
 
\stopMPpage
  
 
\stoptext
 
\stoptext
 +
  
 
</context>
 
</context>

Revision as of 10:08, 20 December 2020



\starttext

\setupMPinstance
  [metafun]
  [textstyle={\definedfont[name:dejavusans*default at 25pt]\ignorespaces}]
  
\startMPpage

draw (0cm,0cm)--(20cm,0cm)--(20cm,20cm)--(0cm,20cm)--cycle
  withpen pencircle
  scaled 0.5mm
  withcolor red;

%------------------------------------------------------------------------------

pair PA ;  PA := (10cm,16cm) ;
  
draw textext.urt("\ruledhbox{URT Aujourd'hui}") shifted PA;
draw textext.ulft("\ruledhbox{ULFT Aujourd'hui}") shifted PA;

draw textext.llft("\ruledhbox{LLFT Aujourd'hui}") shifted PA;
draw textext.lrt("\ruledhbox{LRT Aujourd'hui}")  shifted PA;

draw PA withpen pencircle scaled 1.5mm  withcolor red;

%------------------------------------------------------------------------------

pair PB ;  PB := PA shifted (0cm,-2cm) ;
  
draw textext.drt("\ruledhbox{DRT Aujourd'hui}") shifted PB;
draw textext.dlft("\ruledhbox{DLFT Aujourd'hui}") shifted PB;

draw PB withpen pencircle scaled 1.5mm  withcolor red;

%------------------------------------------------------------------------------

pair PC ;  PC := PB shifted (0cm,-2cm) ;
  
draw textext.d("\ruledhbox{D Aujourd'hui}") shifted PC;


draw PC withpen pencircle scaled 1.5mm  withcolor red;

%------------------------------------------------------------------------------

pair PD ;  PD := PC shifted (0cm,-2cm) ;
  
draw textext.bot("\ruledhbox{BOT Aujourd'hui}")  shifted PD;
draw textext.top("\ruledhbox{TOP Aujourd'hui}") shifted PD;

draw PD withpen pencircle scaled 1.5mm  withcolor red;

%------------------------------------------------------------------------------

pair PE ;  PE := PD shifted (0cm,-2cm) ;
  
draw textext.lft("\ruledhbox{LFT Aujourd'hui}") shifted PE;
draw textext.rt("\ruledhbox{RT Aujourd'hui}") shifted PE;

draw PE withpen pencircle scaled 1.5mm  withcolor red;

%------------------------------------------------------------------------------

pair PF ;  PF := PE shifted (0cm,-2cm) ;
  
draw textext("\ruledhbox{Aujourd'hui}") shifted PF;

draw PF withpen pencircle scaled 1.5mm  withcolor red;

%------------------------------------------------------------------------------

pair PG ;  PG := PF shifted (0cm,-2cm) ;
  
draw textext.origin("\ruledhbox{ORIGIN Aujourd'hui}") shifted PG;

draw PG withpen pencircle scaled 1.5mm  withcolor red;

%------------------------------------------------------------------------------

pair PH ;  PH := PG shifted (0cm,-2cm) ;
  
draw textext.raw("\ruledhbox{RAW Aujourd'hui}") shifted PH;

draw PH withpen pencircle scaled 1.5mm  withcolor red;

%------------------------------------------------------------------------------

\stopMPpage


%==============================================================================
%==============================================================================
%==============================================================================

\setupMPinstance
  [metafun]
  [textstyle={\definedfont[name:dejavusans*default at 50pt]\ignorespaces}]

\startMPpage

draw (0cm,0cm)--(20cm,0cm)--(20cm,20cm)--(0cm,20cm)--cycle
  withpen pencircle
  scaled 0.5mm
  withcolor red;

%------------------------------------------------------------------------------

picture PictA ;

pair PA ;  PA := (5cm,12cm) ;

PictA := textext.urt("\ruledhbox{Aujourd'hui}") shifted PA;
draw PictA;

%------------------------------------------------------------------------------

draw (llcorner PictA) withpen pencircle scaled 3mm  withcolor green;
draw (lrcorner PictA) withpen pencircle scaled 3mm  withcolor yellow;
draw (urcorner PictA) withpen pencircle scaled 3mm  withcolor blue;
draw (ulcorner PictA) withpen pencircle scaled 3mm  withcolor cyan;

%------------------------------------------------------------------------------

picture PictB, PictC ;

pair PB ;  PB := PA shifted (0cm,-4cm) ;

PictB := textext.urt("\ruledhbox{Aujourd'hui}") shifted PB;
PictC := textext.drt("\ruledhbox{Aujourd'hui}") shifted PB;

draw PictB;

pair decalage ; 
decalage = llcorner PictB - llcorner PictC;

%------------------------------------------------------------------------------

draw (center PictB)        withpen pencircle scaled 3mm  withcolor green;

draw (PB shifted decalage) withpen pencircle scaled 3mm  withcolor yellow;
draw (PB shifted (decalage shifted (bbwidth PictB / 2,0mm))) 
                           withpen pencircle scaled 3mm  withcolor blue;
draw (PB shifted (decalage shifted (bbwidth PictB,0mm))) 
                           withpen pencircle scaled 3mm  withcolor cyan;

draw PA             withpen pencircle scaled 1.5mm  withcolor red;


\stopMPpage

\stoptext