Difference between revisions of "textext positioning"
Line 1: | Line 1: | ||
− | |||
− | |||
\starttext | \starttext | ||
Line 9: | Line 7: | ||
\startMPpage | \startMPpage | ||
+ | |||
+ | string MonTexte ; | ||
+ | MonTexte := "Aujourd'hui"; | ||
draw (0cm,0cm)--(20cm,0cm)--(20cm,20cm)--(0cm,20cm)--cycle | draw (0cm,0cm)--(20cm,0cm)--(20cm,20cm)--(0cm,20cm)--cycle | ||
Line 19: | Line 20: | ||
pair PA ; PA := (10cm,16cm) ; | pair PA ; PA := (10cm,16cm) ; | ||
− | draw textext.urt(" | + | draw textext.urt ("URT-" & MonTexte) shifted PA; |
− | draw textext.ulft(" | + | draw textext.ulft("ULFT-" & MonTexte) shifted PA; |
− | + | draw textext.llft("LLFT-" & MonTexte) shifted PA; | |
− | draw textext.llft(" | + | draw textext.lrt ("LRT-" & MonTexte) shifted PA; |
− | draw textext.lrt(" | ||
draw PA withpen pencircle scaled 1.5mm withcolor red; | draw PA withpen pencircle scaled 1.5mm withcolor red; | ||
Line 31: | Line 31: | ||
pair PB ; PB := PA shifted (0cm,-2cm) ; | pair PB ; PB := PA shifted (0cm,-2cm) ; | ||
− | draw textext.drt(" | + | draw textext.drt ("DRT-" & MonTexte) shifted PB; |
− | draw textext.dlft(" | + | draw textext.dlft("DLFT-" & MonTexte) shifted PB; |
draw PB withpen pencircle scaled 1.5mm withcolor red; | draw PB withpen pencircle scaled 1.5mm withcolor red; | ||
Line 40: | Line 40: | ||
pair PC ; PC := PB shifted (0cm,-2cm) ; | pair PC ; PC := PB shifted (0cm,-2cm) ; | ||
− | draw textext.d(" | + | draw textext.d("D-" & MonTexte) shifted PC; |
Line 49: | Line 49: | ||
pair PD ; PD := PC shifted (0cm,-2cm) ; | pair PD ; PD := PC shifted (0cm,-2cm) ; | ||
− | draw textext.bot(" | + | draw textext.bot("BOT-" & MonTexte) shifted PD; |
− | draw textext.top(" | + | draw textext.top("TOP-" & MonTexte) shifted PD; |
draw PD withpen pencircle scaled 1.5mm withcolor red; | draw PD withpen pencircle scaled 1.5mm withcolor red; | ||
Line 58: | Line 58: | ||
pair PE ; PE := PD shifted (0cm,-2cm) ; | pair PE ; PE := PD shifted (0cm,-2cm) ; | ||
− | draw textext.lft(" | + | draw textext.lft("LFT-" & MonTexte) shifted PE; |
− | draw textext.rt(" | + | draw textext.rt("RT-" & MonTexte) shifted PE; |
draw PE withpen pencircle scaled 1.5mm withcolor red; | draw PE withpen pencircle scaled 1.5mm withcolor red; | ||
Line 67: | Line 67: | ||
pair PF ; PF := PE shifted (0cm,-2cm) ; | pair PF ; PF := PE shifted (0cm,-2cm) ; | ||
− | draw textext( | + | draw textext(MonTexte) shifted PF; |
draw PF withpen pencircle scaled 1.5mm withcolor red; | draw PF withpen pencircle scaled 1.5mm withcolor red; | ||
Line 75: | Line 75: | ||
pair PG ; PG := PF shifted (0cm,-2cm) ; | pair PG ; PG := PF shifted (0cm,-2cm) ; | ||
− | draw textext.origin(" | + | draw textext.origin("ORIGIN-" & MonTexte) shifted PG; |
draw PG withpen pencircle scaled 1.5mm withcolor red; | draw PG withpen pencircle scaled 1.5mm withcolor red; | ||
Line 83: | Line 83: | ||
pair PH ; PH := PG shifted (0cm,-2cm) ; | pair PH ; PH := PG shifted (0cm,-2cm) ; | ||
− | draw textext.raw(" | + | draw textext.raw("RAW-" & MonTexte) shifted PH; |
draw PH withpen pencircle scaled 1.5mm withcolor red; | draw PH withpen pencircle scaled 1.5mm withcolor red; | ||
Line 91: | Line 91: | ||
\stopMPpage | \stopMPpage | ||
− | \ | + | |
+ | %============================================================================== | ||
+ | %============================================================================== | ||
+ | %============================================================================== | ||
+ | |||
+ | \setupMPinstance | ||
+ | [metafun] | ||
+ | [textstyle={\definedfont[name:dejavusans*default at 50pt]\ignorespaces}] | ||
+ | |||
+ | \startMPpage | ||
+ | |||
+ | string MonTexte ; | ||
+ | MonTexte := "\ruledhbox{Aujourd'hui}"; | ||
+ | |||
+ | 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(MonTexte) 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) ; | ||
+ | |||
+ | def givedecalage(text temptext) = ( (llcorner textext.urt(temptext)) - | ||
+ | (llcorner textext.drt(temptext)) ) enddef; | ||
+ | |||
+ | |||
+ | PictB := textext.urt(MonTexte) shifted PB; | ||
+ | |||
+ | pair decalage ; | ||
+ | decalage := givedecalage(MonTexte) ; | ||
+ | |||
+ | %------------------------------------------------------------------------------ | ||
+ | |||
+ | draw PictB; | ||
+ | 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 |
Revision as of 10:49, 20 December 2020
\starttext
\setupMPinstance
[metafun] [textstyle={\definedfont[name:dejavusans*default at 25pt]\ignorespaces}]
\startMPpage
string MonTexte ; MonTexte := "Aujourd'hui";
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 ("URT-" & MonTexte) shifted PA; draw textext.ulft("ULFT-" & MonTexte) shifted PA; draw textext.llft("LLFT-" & MonTexte) shifted PA; draw textext.lrt ("LRT-" & MonTexte) shifted PA;
draw PA withpen pencircle scaled 1.5mm withcolor red;
%------------------------------------------------------------------------------
pair PB ; PB := PA shifted (0cm,-2cm) ;
draw textext.drt ("DRT-" & MonTexte) shifted PB; draw textext.dlft("DLFT-" & MonTexte) shifted PB;
draw PB withpen pencircle scaled 1.5mm withcolor red;
%------------------------------------------------------------------------------
pair PC ; PC := PB shifted (0cm,-2cm) ;
draw textext.d("D-" & MonTexte) shifted PC;
draw PC withpen pencircle scaled 1.5mm withcolor red;
%------------------------------------------------------------------------------
pair PD ; PD := PC shifted (0cm,-2cm) ;
draw textext.bot("BOT-" & MonTexte) shifted PD; draw textext.top("TOP-" & MonTexte) shifted PD;
draw PD withpen pencircle scaled 1.5mm withcolor red;
%------------------------------------------------------------------------------
pair PE ; PE := PD shifted (0cm,-2cm) ;
draw textext.lft("LFT-" & MonTexte) shifted PE; draw textext.rt("RT-" & MonTexte) shifted PE;
draw PE withpen pencircle scaled 1.5mm withcolor red;
%------------------------------------------------------------------------------
pair PF ; PF := PE shifted (0cm,-2cm) ;
draw textext(MonTexte) shifted PF;
draw PF withpen pencircle scaled 1.5mm withcolor red;
%------------------------------------------------------------------------------
pair PG ; PG := PF shifted (0cm,-2cm) ;
draw textext.origin("ORIGIN-" & MonTexte) shifted PG;
draw PG withpen pencircle scaled 1.5mm withcolor red;
%------------------------------------------------------------------------------
pair PH ; PH := PG shifted (0cm,-2cm) ;
draw textext.raw("RAW-" & MonTexte) shifted PH;
draw PH withpen pencircle scaled 1.5mm withcolor red;
%------------------------------------------------------------------------------
\stopMPpage
%==============================================================================
%==============================================================================
%==============================================================================
\setupMPinstance
[metafun] [textstyle={\definedfont[name:dejavusans*default at 50pt]\ignorespaces}]
\startMPpage
string MonTexte ; MonTexte := "\ruledhbox{Aujourd'hui}";
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(MonTexte) 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) ;
def givedecalage(text temptext) = ( (llcorner textext.urt(temptext)) -
(llcorner textext.drt(temptext)) ) enddef;
PictB := textext.urt(MonTexte) shifted PB;
pair decalage ; decalage := givedecalage(MonTexte) ;
%------------------------------------------------------------------------------
draw PictB; 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