% do with this file whatever you want
% Patrick Gundlach, Jan 21 2002
% Version 0.4

\setupoutput[pdftex]
\setupcolors[state=start]
\setuppapersize[A4,landscape][A4,landscape]
\startuseMPgraphic{euro1}
path unitcircle; unitcircle:=fullcircle scaled 2;
%unitcircle has radius of 1


boolean show_dots, show_lines,show_labels ; 

% show_lines := true;
% show_dots := true;
% show_labels := true;


show_lines := false;
show_dots := false;
show_labels := false;


% the official construction is ambiguous: how thick are the horizontal
% bars? How much do they stick out to the left? Is this thing a circle
% or what? Are the angles on the left side of the bars the same as the
% one on the right side? I assume, that the top bar is 10 units wide
% and that the round thing is a circle and both bars and the circle
% have a 'thickness' of 1 unit. But, who can tell? Any answer is
% welcome. Send them to patrick@gundla.ch. Thank you.


% ok, this is my (!) way to construct this symbol. 
% 1. determine the points that are given in the official construction
% 2. draw the circle
% 3. draw the two bars (sticking out to the left)
% 5. clip the right side off

path inner, outer; % the big circle: inner and outer part
path hbar;         % horizontal bar
path a[];          % aux paths for intersections
path clippath;     % path for clipping 
pair topbarleft, bottombarleft; 
pair o[];          % official points :-)
pair c[];          % clip points
picture cp;        %currentpicture for clipping
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% calculate points

% this is just a multiplication factor. start with 1 cm
u :=1cm;
radius:=5.5u;
topbarlength := 10u;
thickness:=1u;

% these are the ``official'' points
o1 = (0 ,-radius-.5thickness);    
o2 = dir  40 * (radius-.5thickness);
o3 = dir -40 * (radius-.5thickness);

% the very strange angle at the ends of the two vertical bars and the
% upper right edge of the C 
alpha := angle (o2-o1);

a1 := o1 -- o2;      % the right slant
a2 := origin -- o3;  % the lower 40deg. angle


% first: draw the circle

draw unitcircle scaled radius
      withpen pencircle scaled thickness;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% the bars
hbar := unitsquare xscaled topbarlength yscaled thickness
               slanted (1/tand (alpha));

% top bar lrcorner:
c3 := ((-infinity,0.5u) -- (infinity , 0.5u)) intersectionpoint a1; 

topbarleft    := (xpart c3 - topbarlength , 0.5u);
bottombarleft := (xpart c3 - topbarlength ,-1.5u);

fill hbar shifted topbarleft;
fill hbar shifted bottombarleft;

% clip the right part
cp := currentpicture;

c2 := a1  intersectionpoint a2;
c4 := o2 + dir alpha *2u;
c6 := (xpart  o3, ypart lrcorner cp);

outer := unitcircle scaled (radius+.5thickness);
c1 := (o1--c4) intersectionpoint outer;


clippath := llcorner cp -- c6 -- o3 -- c2 -- c1 -- 
          (xpart c1,ypart urcorner cp) -- ulcorner cp -- cycle ;

clip currentpicture to clippath;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% debugging

if show_lines:
  % the circle is painted as a fullcirlce scaled 11u with a thickness
  % of 1u;
  inner := unitcircle scaled (radius-.5thickness);
  pickup pencircle scaled 1pt;

  drawoptions (withcolor .7white);
  draw inner;
  draw outer; % defined above 

  draw a1 dashed evenly;
  draw origin -- o2 dashed evenly;
  draw a2  dashed evenly;
  draw hbar shifted topbarleft;
  draw hbar shifted bottombarleft;
  draw clippath;
fi

if show_dots:
 pickup pencircle scaled 2pt;
 drawoptions (withcolor .5black);
 draw origin;
 draw c1;
 draw c3;
 draw c2;
 draw c4;
 draw c6;
 draw o1;
 draw o2;
 draw topbarleft;
 draw bottombarleft;
fi

if show_labels:
 drawoptions (withcolor .5black);
  label.bot("origin",origin);
  label.lrt("bottombarleft",bottombarleft);
  label.lrt("topbarleft",topbarleft);
  label.ulft ("c1",c1);
  label.rt ("c2",c2);
  label.rt ("c3",c3);
  label.rt ("c4",c4);
  label.bot("c6",c6);
  label.bot("o1",o1);
  label.bot("o2",o2);
  label.rt ("o3",o3);
 fi
 
if show_lines:
   draw bbox currentpicture dashed evenly withcolor .7white ; 
fi

\stopuseMPgraphic

\startuniqueMPgraphic{euro}{height}
   \includeMPgraphic{euro1} ;
   currentpicture := currentpicture ysized \MPvar{height} ;
\stopuniqueMPgraphic




\definesymbol[euro][\uniqueMPgraphic{euro}{height=1.5ex}]

\starttext
%\setupbackgrounds[page][background=color,backgroundcolor=blue]
\framed{%
\useMPgraphic{euro1}%
}

This is an international  \symbol[euro]\ text. And these are my 0.02
\tfd \symbol[euro]. 
\stoptext
\endinput


% official site
% http://europa.eu.int/euro/html/entry.html
 
% construction with 2u sticking out on the left side
% http://www.euro.ecb.int/en/section/euro/euro.html
% there are actually some others that copied this construction

% a project from a school. The red line that is drawn on the right
% side makes the one on the left. 
% http://www.fh-lueneburg.de/u1/gym03/expo/jonatur/schulent/eigenarb/euro/eurokons.htm


% Changelog: 
% Version 0.4 (Jan 21 2002)
%    * removed most commands that were unnecessary (50% of source code)
% Version 0.3 (Jan 14 2002)
%    * removed unfill... because in mp this is a hack. (Thanks again
%      to Hans Hagen)
%    * removed a (halfway unnecessary) line for c3
%    * a bit code cleanup
% Version 0.2 (Sept. 11 2001):
%    * fixed bbox, added symbol definition. Thanks to Hans Hagen.


%%% Local Variables: 
%%% mode: plain-tex
%%% TeX-master: t
%%% End: 
