%%%%%%%%%%%%%%%%%% ifgeo.gen %%%%%%%%%%%%%%%%%%%%%%%
% (c) Ingo Kloeckl
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.

% History
% 20.12.1999 v1.0  IK 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% geometric symbols
% by I.Kloeckl, ingo.kloeckl@2k-software.de

pen normalpen;
normalpen := pencircle scaled 1linewidth;

shadow_x := 2pt;
shadow_y := 2pt;


% some internal utility functions
def Tri(expr n, s, phi) =
if ((phi=90) or (phi=-90)):
  beginchar((char n),ystretch*(10pt#),xstretch*(10pt#),0); 
else:
  beginchar((char n),xstretch*(10pt#),ystretch*(10pt#),0); 
fi;
  pickup normalpen;
  bot lft z0 = (-0.5pt*s*xstretch, -0.5pt*s*ystretch) rotated (phi);
  bot rt z1 = (0.5pt*s*xstretch, -0.5pt*s*ystretch) rotated (phi);
  top z2 = (0pt, 0.5pt*s*ystretch) rotated (phi);
  draw z0--z1--z2--cycle shifted(.5w,.5h);
endchar;
enddef;

def FillTri(expr n, s, phi) =
if ((phi=90) or (phi=-90)):
  beginchar((char n),ystretch*(10pt#),xstretch*(10pt#),0); 
else:
  beginchar((char n),xstretch*(10pt#),ystretch*(10pt#),0); 
fi;
  pickup normalpen;
  fill (-0.5pt,-0.5pt)--(0.5pt,-0.5pt)--(0pt,0.5pt)--cycle
    xscaled (s*xstretch) yscaled (s*ystretch) rotated (phi)
    shifted(.5w,.5h);
endchar;
enddef;

def Cir(expr n, s) =
beginchar((char n),10pt#,10pt#,0); 
  pickup normalpen;
  numeric t;
  t:=s*1pt;
  draw fullcircle scaled t shifted(5pt,5pt);
endchar;
enddef;

def FillCir(expr n, s) =
beginchar((char n),10pt#,10pt#,0); 
  pickup normalpen;
  numeric t;
  t:=s*1pt;
  fill fullcircle scaled t shifted(5pt,5pt);
endchar;
enddef;

def Sq(expr n, s, shadow) =
  beginchar((char n),xstretch*(10pt#),ystretch*(10pt#),0); 
  pickup normalpen;
  bot lft z0 = (-0.5pt*s*xstretch, -0.5pt*s*ystretch);
  bot rt z1 = (0.5pt*s*xstretch, -0.5pt*s*ystretch);
  top rt z2 = (0.5pt*s*xstretch, 0.5pt*s*ystretch);
  top lft z3 = (-0.5pt*s*xstretch, 0.5pt*s*ystretch);
  if shadow=1:
    path p; p := z0--z1--z2;
    draw p shifted(.5w+shadow_x,.5h-shadow_y);
  elseif shadow=2:
    path p; p := z0--z1--z2--z3--cycle;
    fill p shifted(.5w+shadow_x,.5h-shadow_y);
    unfill p shifted(.5w,.5h);
  elseif shadow=3:
    path p; p := z0--z1--z2--z3--cycle;
    draw p shifted(.5w+shadow_x,.5h-shadow_y);
    unfill p shifted(.5w,.5h);
  fi;
  draw z0--z1--z2--z3--cycle shifted(.5w,.5h);
endchar;
enddef;

def FillSq(expr n, s, shadow) =
  beginchar((char n),xstretch*(10pt#),ystretch*(10pt#),0); 
  pickup normalpen;
  bot lft z0 = (-0.5pt*s*xstretch, -0.5pt*s*ystretch);
  bot rt z1 = (0.5pt*s*xstretch, -0.5pt*s*ystretch);
  top rt z2 = (0.5pt*s*xstretch, 0.5pt*s*ystretch);
  top lft z3 = (-0.5pt*s*xstretch, 0.5pt*s*ystretch);
  if shadow=1:
    path p; p := z0--z1--z2;
    draw p shifted(.5w+shadow_x,.5h-shadow_y);
  elseif shadow=3:
    path p; p := z0--z1--z2--z3--cycle;
    draw p shifted(.5w+shadow_x,.5h-shadow_y);
  fi;
  fill z0--z1--z2--z3--cycle shifted(.5w,.5h);
endchar;
enddef;

def CrossedSq(expr n, s) =
  beginchar((char n),xstretch*(10pt#),ystretch*(10pt#),0); 
  pickup normalpen;
  bot lft z0 = (-0.5pt*s*xstretch, -0.5pt*s*ystretch) shifted(.5w,.5h);
  bot rt z1 = (0.5pt*s*xstretch, -0.5pt*s*ystretch) shifted(.5w,.5h);
  top rt z2 = (0.5pt*s*xstretch, 0.5pt*s*ystretch) shifted(.5w,.5h);
  top lft z3 = (-0.5pt*s*xstretch, 0.5pt*s*ystretch) shifted(.5w,.5h);
  draw z0--z2; draw z1--z3;
endchar;
enddef;

def Diamond(expr n, s, shadow, fillshape) =
  beginchar((char n),xstretch*(10pt#),ystretch*(10pt#),0); 
  pickup normalpen;
  x0 = 0pt; bot y0 = -0.5pt*s*ystretch;
  rt x1 =  0.5pt*s*xstretch; y1 = 0pt;
  x2 =  0pt; top y2 =  0.5pt*s*ystretch;
  lft x3 = -0.5pt*s*xstretch; y3 =  0pt;
  if shadow=1:
    path p; p := z0--z1--z2;
    draw p shifted(.5w+shadow_x,.5h);
  elseif shadow=2:
    path p; p := z0--z1--z2--z3--cycle;
    fill p shifted(.5w+shadow_x,.5h);
    unfill p shifted(.5w,.5h);
  elseif shadow=3:
    path p; p := z0--z1--z2--z3--cycle;
    draw p shifted(.5w+shadow_x,.5h);
    unfill p shifted(.5w,.5h);
  fi;
  draw z0--z1--z2--z3--cycle shifted(.5w,.5h);
  if fillshape=1: % right half filled
    fill z0--z1--z2--cycle shifted(.5w,.5h);
  elseif fillshape=2: % lower half filled
    fill z0--z1--z3--cycle shifted(.5w,.5h);
  fi;
endchar;
enddef;

def FillDiamond(expr n, s, shadow) =
  beginchar((char n),xstretch*(10pt#),ystretch*(10pt#),0); 
  pickup normalpen;
  x0 = 0pt; bot y0 = -0.5pt*s*ystretch;
  rt x1 =  0.5pt*s*xstretch; y1 = 0pt;
  x2 =  0pt; top y2 =  0.5pt*s*ystretch;
  lft x3 = -0.5pt*s*xstretch; y3 =  0pt;
  if shadow=1:
    path p; p := z0--z1--z2;
    draw p shifted(.5w+shadow_x,.5h);
  elseif shadow=3:
    path p; p := z0--z1--z2--z3--cycle;
    draw p shifted(.5w+shadow_x,.5h);
  fi;
  fill z0--z1--z2--z3--cycle shifted(.5w,.5h);
endchar;
enddef;

def DiamondBar(expr n, s, barshape) =
  beginchar((char n),xstretch*(10pt#),ystretch*(10pt#),0); 
  pickup normalpen;
  x0 = 0pt; bot y0 = -0.5pt*s*ystretch;
  rt x1 =  0.5pt*s*xstretch; y1 = 0pt;
  x2 =  0pt; top y2 =  0.5pt*s*ystretch;
  lft x3 = -0.5pt*s*xstretch; y3 =  0pt;
  path p;
  if barshape=1: % horizontal bar
    p := z1--z3;
    draw p shifted(.5w,.5h);
  elseif barshape=2: % vertical bar
    p := z0--z2;
    draw p shifted(.5w,.5h);
  fi;
endchar;
enddef;

"Bigsquare";			Sq(32,10,0);
"Square";			Sq(48,8,0);
"Smallsquare";			Sq(64,6,0);
"FilledBigsquare";		FillSq(80,10,0);
"FilledSquare";			FillSq(96,8,0);
"FilledSmallsquare";		FillSq(112,6,0);

"SquareShadow1";		Sq(0,8,1);
"SquareShadow2";		Sq(1,8,2);
"SquareShadow3";		Sq(2,8,3);
"FilledSquareShadow1";		FillSq(3,8,1);
"FilledSquareShadow3";		FillSq(4,8,3);


"BigtriangleUp";		Tri(33,10,0);
"TriangleUp";			Tri(49,8,0);
"SmalltriangleUp";		Tri(65,6,0);
"FilledBigtriangleUp";		FillTri(81,10,0);
"FilledTriangleUp";		FillTri(97,8,0);
"FilledSmalltriangleUp";	FillTri(113,6,0);

"BigtriangleLeft";		Tri(34,10,90);
"TriangleLeft";			Tri(50,8,90);
"SmalltriangleLeft";		Tri(66,6,90);
"FilledBigtriangleLeft";	FillTri(82,10,90);
"FilledTriangleLeft";		FillTri(98,8,90);
"FilledSmalltriangleLeft";	FillTri(114,6,90);

"BigtriangleDown";          Tri(35,10,180);
"TriangleDown";             Tri(51,8,180);
"SmalltriangleDown";        Tri(67,6,180);
"FilledBigtriangleDown";    FillTri(83,10,180);
"FilledTriangleDown";       FillTri(99,8,180);
"FilledSmalltriangleDown";  FillTri(115,6,180);

"BigtriangleRight";         Tri(36,10,-90);
"TriangleRight";            Tri(52,8,-90);
"SmalltriangleRight";       Tri(68,6,-90);
"FilledBigtriangleRight";   FillTri(84,10,-90);
"FilledTriangleRight";      FillTri(100,8,-90);
"FilledSmalltriangleRight"; FillTri(116,6,-90);

"Bigcircle";                Cir(37,10);
"Circle";                   Cir(53,8);
"Smallcircle";              Cir(69,6);
"FilledBigcircle";          FillCir(85,10);
"Filledcircle";             FillCir(101,8);
"FilledSmallcircle";        FillCir(117,6);


"BigDiamond";                Diamond(38,10,0,0);
"Diamond";                   Diamond(54,8,0,0);
"SmallDiamond";              Diamond(70,6,0,0);
"FilledBigDiamond";          FillDiamond(86,10,0);
"FilledDiamond";             FillDiamond(102,8,0);
"FilledSmallDiamond";        FillDiamond(118,6,0);
"BigRightDiamond";           Diamond(47,10,0,1);
"RightDiamond";              Diamond(63,8,0,1);
"SmallRightDiamond";         Diamond(79,6,0,1);
"BigLowerDiamond";           Diamond(95,10,0,2);
"LowerDiamond";              Diamond(111,8,0,2);
"SmallLowerDiamond";         Diamond(127,6,0,2);

"DiamondShadow1";	     Diamond(5,8,1,0);
"DiamondShadow2";	     Diamond(6,8,2,0);
"DiamondShadow3";	     Diamond(7,8,3,0);
"DiamondSquareShadow1";	     FillDiamond(8,8,1);
"DiamondSquareShadow3";	     FillDiamond(9,8,3);

"BigCross";		     CrossedSq(13,10);
"Cross";		     CrossedSq(14,8);
"SmallCross";		     CrossedSq(15,6);
"BigHorBar";		     DiamondBar(26,10,1);
"HorBar";		     DiamondBar(27,8,1);
"SmallHorBar";		     DiamondBar(28,6,1);
"BigVertBar";		     DiamondBar(29,10,2);
"VertBar";		     DiamondBar(30,8,2);
"SmallVertBar";		     DiamondBar(31,6,2);

end.

%%%%%%%%%%%%%%%%%% end of ifgeo.gen %%%%%%%%%%%%%%%%%%%%%%%