home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / EXAMPLES / PLSTYLES.P < prev    next >
Text File  |  2000-02-11  |  2KB  |  146 lines

  1. program lstyles;
  2.  
  3. #include "Vogle.h"
  4.  
  5. var
  6.     idum: integer;
  7.     device: string_t;
  8.  
  9. procedure drawbox(s: real);
  10. begin
  11.     PushMatrix;
  12.  
  13.     Rotate(30.0, 'x');
  14.     Rotate(60.0, 'y');
  15.     Translate(-0.7, -1.2, 0.0);
  16.     Scale(s, s, s);
  17.  
  18.     Move(0.0, 0.0, 0.0);
  19.  
  20.     Draw(1.0, 0.0, 0.0);
  21.     Draw(1.0, 1.0, 0.0);
  22.     Draw(0.0, 1.0, 0.0);
  23.     Draw(0.0, 0.0, 0.0);
  24.  
  25.     Draw(0.0, 0.0, -1.0);
  26.     Draw(1.0, 0.0, -1.0);
  27.     Draw(1.0, 1.0, -1.0);
  28.     Draw(0.0, 1.0, -1.0);
  29.     Draw(0.0, 0.0, -1.0);
  30.  
  31.     Move(0.0, 1.0, -1.0);
  32.     Draw(0.0, 1.0, 0.0);
  33.  
  34.     Move(1.0, 1.0, 0.0);
  35.     Draw(1.0, 1.0, -1.0);
  36.  
  37.     Move(1.0, 0.0, 0.0);
  38.     Draw(1.0, 0.0, -1.0);
  39.  
  40.     PopMatrix;
  41. end;
  42.  
  43.  
  44. procedure drawsine(s: real);
  45.  
  46. const
  47.     RAD = 0.5;
  48.     AMP = 0.03;
  49. var
  50.     a, x, y, z: real;
  51.  
  52. begin
  53.  
  54.     PushMatrix;
  55.  
  56.     Translate(RAD + 0.2, -0.5, 0.0);
  57.     Scale(s, s, s);
  58.  
  59.     Move(RAD, 0.0, 0.0);
  60.     a := 0;
  61.     while (a <= 2 * 3.1415926) do begin
  62.         x := RAD * cos(a);
  63.         z := RAD * sin(a);
  64.         y := AMP * sin(a * 6.0);
  65.  
  66.         Draw(x, y, z);
  67.  
  68.         a := a + 0.02
  69.     end;
  70.  
  71.     PopMatrix
  72. end;
  73.  
  74. procedure drawscene;
  75. begin
  76.     Color(BLACK);
  77.     Clear;
  78.  
  79.     Color(GREEN);
  80.     SetDash(0.03);
  81.  
  82.     XcenterText;
  83.     Move2(-0.45, 0.9);
  84.     DrawStr('Linestyle: "10"');
  85.     Move2(-0.45, 0.7);
  86.     DrawStr('Linestyle: "110"');
  87.     Move2(-0.45, 0.5);
  88.     DrawStr('Linestyle: "111010"');
  89.     Move2(-0.45, 0.3);
  90.     DrawStr('Linestyle: "0001"');
  91.  
  92.     LineStyle('10');
  93.     Move2(-0.9, 0.9);
  94.     Draw2( 0.0, 0.9);
  95.     Circle(0.6, 0.6, 0.4);
  96.  
  97.     drawbox(0.9);
  98.     drawsine(0.9);
  99.  
  100.     Color(RED);
  101.     LineStyle('110');
  102.     Move2(-0.9, 0.7);
  103.     Draw2( 0.0, 0.7);
  104.     Circle(0.6, 0.6, 0.3);
  105.     drawbox(0.7);
  106.     drawsine(0.7);
  107.  
  108.     Color(CYAN);
  109.     LineStyle('111010');
  110.     Move2(-0.9, 0.5);
  111.     Draw2( 0.0, 0.5);
  112.     Circle(0.6, 0.6, 0.2);
  113.     drawbox(0.5);
  114.     drawsine(0.5);
  115.  
  116.     Color(YELLOW);
  117.     LineStyle('0001');
  118.     Move2(-0.9, 0.3);
  119.     Draw2( 0.0, 0.3);
  120.     Circle(0.6, 0.6, 0.1);
  121.     drawbox(0.3);
  122.     drawsine(0.3);
  123.  
  124.     idum := GetKey;    
  125.  
  126. end;
  127.  
  128.  
  129. begin
  130.     write('Enter output device: ');
  131.     readln(device);
  132.  
  133.     Vinit(device);
  134.     VsetFlush(false);
  135.     Up(0.0, 1.0, 0.0);
  136.     Perspective(90.0, 1.0, 0.3, 3.0);
  137.     Translate(0.0, 0.0, -1.3);
  138.  
  139.     drawscene;
  140.     Rotate(-30.0, 'y');
  141.     Rotate(-30.0, 'x');
  142.     drawscene;
  143.  
  144.     Vexit
  145. end.
  146.