home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_tools / v_lib205 / demoproc.c < prev    next >
C/C++ Source or Header  |  1994-02-28  |  37KB  |  1,379 lines

  1. #include <windows.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include "visualib.h"
  5. #include "vlibdemo.h"
  6. #include "demoproc.h"
  7.  
  8. HINSTANCE    hdllinst = 0;
  9.  
  10. int WINAPI LibMain (HINSTANCE hinst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
  11. {
  12.     if (cbHeapSize != 0)
  13.         UnlockData (0);
  14.     hdllinst = hinst;
  15.     return (1);
  16. }
  17.  
  18. VOID WINAPI MinRoutine (int nParameter, LPSTR lpszParam2)
  19. {
  20.     
  21. }
  22.  
  23. int    WINAPI WEP (int nParameter)
  24. {
  25.     if (nParameter == WEP_SYSTEM_EXIT) {
  26.         return (1);
  27.     }
  28.     else if (nParameter == WEP_FREE_DLL) {
  29.         return (1);
  30.     }
  31.     else {
  32.         return (1);
  33.     }
  34. }
  35.  
  36. VOIDED    LineDemo2D (HDC hdc)
  37. {
  38.     SetViewerName (VL_CURRENT, "2D Lines");
  39.     PenColor (hdc, VL_RED);
  40.     MoveTo2D (hdc, 0, 0);
  41.     LineTo2D (hdc, 1, 1);
  42.     RLineTo2D (hdc, -2, 0);
  43.     RLineTo2D (hdc, 0, -2);
  44.     RLineTo2D (hdc, 2, 0);
  45.     RLineTo2D (hdc, 0, 2);
  46.     RMoveTo2D (hdc, 1, 1);
  47.     LineTo2D (hdc, -2, 2);
  48.     PenColor (hdc, VL_BLUE);
  49.     MoveTo2H (hdc, 1, 1, 0.5f);
  50.     LineTo2H (hdc, 0, 1, 0);
  51.     LineTo2H (hdc, 0, 0, 1);
  52.     MoveTo2H (hdc, -1, 1, 0.5f);
  53.     LineTo2H (hdc, -1, 0, 0);
  54.     LineTo2H (hdc, 0, 0, 1);
  55.     MoveTo2H (hdc, -1, -1, 0.5f);
  56.     LineTo2H (hdc, 0, -1, 0);
  57.     LineTo2H (hdc, 0, 0, 1);
  58.     MoveTo2H (hdc, 1, -1, 0.5f);
  59.     LineTo2H (hdc, 1, 0, 0);
  60.     LineTo2H (hdc, 0, 0, 1);
  61.     PenColor (hdc, VL_GREEN);
  62.     Line2D (hdc, -15, 5, 15, 5);
  63.     Line2D (hdc, -15, -5, 15, -5);
  64.     Line2D (hdc, -5, -15, -5, 15);
  65.     Line2D (hdc, 5, -15, 5, 15);
  66.     Line2D (hdc, -15, 0, 0, 15);
  67.     Line2D (hdc, 15, 0, 0, 15);
  68.     Line2D (hdc, 0, -15, 15, 0);
  69.     Line2D (hdc, 0, -15, -15, 0);
  70.     PenColor (hdc, VL_YELLOW);
  71.     Line2H (hdc, -5, 5, 0.75f, 5, 5, 0.75f);
  72.     Line2H (hdc, -5, -5, 0.75f, 5, -5, 0.75f);
  73.     Line2H (hdc, -5, -5, 0.75f, -5, 5, 0.75f);
  74.     Line2H (hdc, 5, -5, 0.75f, 5, 5, 0.75f);
  75.     PenColor (hdc, VL_BROWN);
  76.     RLine2D (hdc, 2, 3, -5, -5);
  77. }
  78.  
  79. VOIDED    PolylineDemo2D (HDC hdc)
  80. {
  81.     COORD    poly[] = {-1, -1, -1, 1, 1, 1, 1, -1};
  82.  
  83.     SetViewerName (VL_CURRENT, "2D PolyLines");
  84.     PenColor (hdc, VL_RED);
  85.     Polyline2D (hdc, VL_2D, poly, 4);
  86.     PushTransformation2D (NULL);
  87.     TranslateTo2D (3, 3);
  88.     ClosedPolyline2D (hdc, VL_2D, poly, 4);
  89.     TranslateTo2D (10, 0);
  90.     ClosedPolyline2D (hdc, VL_2D, poly, 4);
  91.     TranslateTo2D (10, -6);
  92.     ClosedPolyline2D (hdc, VL_2D, poly, 4);
  93.     TranslateTo2D (-10, -6);
  94.     ClosedPolyline2D (hdc, VL_2D, poly, 4);
  95.     TranslateTo2D (-10, 6);
  96.     ClosedPolyline2D (hdc, VL_2D, poly, 4);
  97.     PopTransformation2D (NULL);
  98.     LineTo2D (hdc, 0, 0);
  99. }
  100.  
  101. VOIDED    PointerDemo2D (HDC hdc)
  102. {
  103.     REAL    x, y, a;
  104.     short    i;
  105.  
  106.     SetViewerName (VL_CURRENT, "2D Pointers");
  107.     PenColor (hdc, VL_YELLOW);
  108.     for (i = 0, a = 0; i < 12; i++, a += 0.5f) {
  109.         x = (REAL) cos (a) * 9;
  110.         y = (REAL) sin (a) * 5;
  111.         Pointer2D (hdc, 0, 0, x, y, 1, 0.5f, VL_CLOSEDARROW);
  112.     }
  113. }
  114.  
  115. VOIDED    MarkDemo2D (HDC hdc)
  116. {
  117.     short    i, j;
  118.     REAL    x, y;
  119.  
  120.     SetViewerName (VL_CURRENT, "2D Marks");
  121.     PenColor (hdc, VL_BLUE);
  122.     for (j = 0, y = -6; j < 7; j++, y += 2)
  123.         for (i = 0, x = -9; i < 10; i++, x += 2)
  124.             Mark2D (hdc, x, y, i+2, i+2, VL_CIRCLEMARK << j);
  125. }
  126.  
  127. VOIDED    LabelDemo2D (HDC hdc)
  128. {
  129.     SetViewerName (VL_CURRENT, "2D Labels");
  130.     TextColor (hdc, VL_RED, VL_WHITE, TRANSPARENT);
  131.     PenColor (hdc, VL_GREEN);
  132.     SetTextAlign (hdc, TA_CENTER | TA_BASELINE);
  133.     Label2D (hdc, 0, 0, "Center & BaseLine");
  134.     Mark2D (hdc, 0, 0, 15, 5, VL_CROSSMARK);
  135.     SetTextAlign (hdc, TA_CENTER | TA_TOP);
  136.     Label2D (hdc, 0, 3, "Center & Top");
  137.     Mark2D (hdc, 0, 3, 15, 3, VL_CROSSMARK);
  138.     SetTextAlign (hdc, TA_CENTER | TA_BOTTOM);
  139.     Label2D (hdc, 0, -3, "Center & Bottom");
  140.     Mark2D (hdc, 0, -3, 15, 3, VL_CROSSMARK);
  141.  
  142.     SetTextAlign (hdc, TA_LEFT | TA_BASELINE);
  143.     Label2D (hdc, 3.5f, 0, "Left & BaseLine");
  144.     Mark2D (hdc, 3.5f, 0, 15, 5, VL_CROSSMARK);
  145.     SetTextAlign (hdc, TA_LEFT | TA_TOP);
  146.     Label2D (hdc, 3.5f, 3, "Left & Top");
  147.     Mark2D (hdc, 3.5f, 3, 15, 3, VL_CROSSMARK);
  148.     SetTextAlign (hdc, TA_LEFT | TA_BOTTOM);
  149.     Label2D (hdc, 3.5f, -3, "Left & Bottom");
  150.     Mark2D (hdc, 3.5f, -3, 15, 3, VL_CROSSMARK);
  151.  
  152.     SetTextAlign (hdc, TA_RIGHT | TA_BASELINE);
  153.     Label2D (hdc, -3.5f, 0, "Right & BaseLine");
  154.     Mark2D (hdc, -3.5f, 0, 15, 5, VL_CROSSMARK);
  155.     SetTextAlign (hdc, TA_RIGHT | TA_TOP);
  156.     Label2D (hdc, -3.5f, 3, "Right & Top");
  157.     Mark2D (hdc, -3.5f, 3, 15, 3, VL_CROSSMARK);
  158.     SetTextAlign (hdc, TA_RIGHT | TA_BOTTOM);
  159.     Label2D (hdc, -3.5f, -3, "Right & Bottom");
  160.     Mark2D (hdc, -3.5f, -3, 15, 3, VL_CROSSMARK);
  161. }
  162.  
  163. VOIDED    NetDemo2D (HDC hdc)
  164. {
  165.     COORD    net[140];
  166.     short    i, j, index = 0;
  167.     REAL    x, y;
  168.  
  169.     PenColor (hdc, VL_BLUE);
  170.     ;
  171.     for (i = 0, y = -6.5f; i < 7; i++, y += 2) {
  172.         for (j = 0, x = -9.5f; j < 10; j++, x += 2) {
  173.             net[index++] = x + ((REAL) rand () / RAND_MAX);
  174.             net[index++] = y + ((REAL) rand () / RAND_MAX);
  175.         }
  176.     }
  177.     Net2D (hdc, VL_2D, (LPCOORD) net, 7, 10);
  178.     SetViewerName (VL_CURRENT, "2D Net");
  179. }
  180.  
  181. VOIDED    Prime2D (HDC hdc, int func)
  182. {
  183.     switch (func) {
  184.         case IDM_2DPRIME_LINE:
  185.             LineDemo2D (hdc);
  186.             break;
  187.         case IDM_2DPRIME_POLYLINE:
  188.             PolylineDemo2D (hdc);
  189.             break;
  190.         case IDM_2DPRIME_POINTER:
  191.             PointerDemo2D (hdc);
  192.             break;
  193.         case IDM_2DPRIME_MARK:
  194.             MarkDemo2D (hdc);
  195.             break;
  196.         case IDM_2DPRIME_LABEL:
  197.             LabelDemo2D (hdc);
  198.             break;
  199.         case IDM_2DPRIME_NET:
  200.             NetDemo2D (hdc);
  201.             break;
  202.         case IDM_2DPRIME_SPIRAL:
  203.             PenColor (hdc, VL_YELLOW);
  204.             Spiral2D (hdc, 0, 0, 30, 5, 1, 1);
  205.             SetViewerName (VL_CURRENT, "2D Spiral Curve");
  206.             break;
  207.     }
  208. }
  209.  
  210. VOIDED    LineDemo3D (HDC hdc)
  211. {
  212.     SetViewerName (VL_CURRENT, "3D Lines");
  213.     PenColor (hdc, VL_RED);
  214.     MoveTo3D (hdc, 0, 0, 0);
  215.     LineTo3D (hdc, 10, 10, 0);
  216.     RLineTo3D (hdc, 0, -20, 0);
  217.     RLineTo3D (hdc, -20, 0, 0);
  218.     RLineTo3D (hdc, 0, 20, 0);
  219.     RLineTo3D (hdc, 20, 0, 0);
  220.     PenColor (hdc, VL_BLUE);
  221.     MoveTo3H (hdc, 1, 1, 0, 0.5f);
  222.     LineTo3H (hdc, 0, 1, 0, 0);
  223.     LineTo3H (hdc, 0, 0, 0, 1);
  224.     MoveTo3H (hdc, -1, 1, 0, 0.5f);
  225.     LineTo3H (hdc, -1, 0, 0, 0);
  226.     LineTo3H (hdc, 0, 0, 0, 1);
  227.     MoveTo3H (hdc, -1, -1, 0, 0.5f);
  228.     LineTo3H (hdc, 0, -1, 0, 0);
  229.     LineTo3H (hdc, 0, 0, 0, 1);
  230.     MoveTo3H (hdc, 1, -1, 0, 0.5f);
  231.     LineTo3H (hdc, 1, 0, 0, 0);
  232.     LineTo3H (hdc, 0, 0, 0, 1);
  233.     PenColor (hdc, VL_YELLOW);
  234.     MoveTo3D (hdc, 100, 100, 90);
  235.     LineTo3D (hdc, 10, 0, 0);
  236.     MoveTo3D (hdc, 100, 100, 90);
  237.     LineTo3D (hdc, 0, 10, 0);
  238.     MoveTo3D (hdc, 100, 100, 90);
  239.     LineTo3D (hdc, 0, 0, 10);
  240. }
  241.  
  242. VOIDED    PolylineDemo3D (HDC hdc)
  243. {
  244.     COORD    poly[] = {-1, -1, -1, 1, 1, 1, 1, -1};
  245.  
  246.     SetViewerName (VL_CURRENT, "3D PolyLines");
  247.     PenColor (hdc, VL_RED);
  248.     Polyline3D (hdc, VL_2D, poly, 4);
  249.     PushTransformation3D (NULL);
  250.     Scale3D (5, 5, 5);
  251.     TranslateTo3D (3, 3, 0);
  252.     PenColor (hdc, VL_GREEN);
  253.     ClosedPolyline3D (hdc, VL_2D, poly, 4);
  254.     TranslateTo3D (10, 0, 0);
  255.     PenColor (hdc, VL_BLUE);
  256.     ClosedPolyline3D (hdc, VL_2D, poly, 4);
  257.     TranslateTo3D (10, -6, 0);
  258.     PenColor (hdc, VL_YELLOW);
  259.     ClosedPolyline3D (hdc, VL_2D, poly, 4);
  260.     TranslateTo3D (-10, -6, 0);
  261.     PenColor (hdc, VL_BROWN);
  262.     ClosedPolyline3D (hdc, VL_2D, poly, 4);
  263.     TranslateTo3D (-10, 6, 0);
  264.     PenColor (hdc, VL_WHITE);
  265.     ClosedPolyline3D (hdc, VL_2D, poly, 4);
  266.     PopTransformation3D (NULL);
  267.     LineTo3D (hdc, 0, 0, 0);
  268. }
  269.  
  270. VOIDED    PointerDemo3D (HDC hdc)
  271. {
  272.     SetViewerName (VL_CURRENT, "3D Pointers");
  273.     PenColor (hdc, VL_RED);
  274.     Pointer3D (hdc, 0, 0, 0, 20, 0, 0, 5, 3, VL_OPENARROW);
  275.     PenColor (hdc, VL_GREEN);
  276.     Pointer3D (hdc, 0, 0, 0, 0, 20, 0, 5, 3, VL_CLOSEDARROW);
  277.     PenColor (hdc, VL_BLUE);
  278.     Pointer3D (hdc, 0, 0, 0, 0, 0, 20, 5, 3, VL_CROSSMARK);
  279.     PenColor (hdc, VL_YELLOW);
  280.     Pointer3D (hdc, 0, 0, 0, -20, 0, 0, 5, 3, VL_HEXAGONMARK);
  281.     PenColor (hdc, VL_BROWN);
  282.     Pointer3D (hdc, 0, 0, 0, 0, -20, 0, 5, 3, VL_TRIANGLEMARK);
  283.     PenColor (hdc, VL_WHITE);
  284.     Pointer3D (hdc, 0, 0, 0, 0, 0, -20, 5, 3, VL_BOXMARK);
  285. }
  286.  
  287. VOIDED    MarkDemo3D (HDC hdc)
  288. {
  289.     SetViewerName (VL_CURRENT, "3D Marks");
  290.     PenColor (hdc, VL_RED);
  291.     Mark3D (hdc, 0, 0, 0, 5, 5, VL_CROSSMARK);
  292.     PenColor (hdc, VL_GREEN);
  293.     Mark3D (hdc, 20, 0, 0, 5, 5, VL_HEXAGONMARK);
  294.     PenColor (hdc, VL_BLUE);
  295.     Mark3D (hdc, 0, 20, 0, 5, 5, VL_DIAMONDMARK);
  296.     PenColor (hdc, VL_WHITE);
  297.     Mark3D (hdc, 0, 0, 20, 5, 5, VL_TRIANGLEMARK);
  298. }
  299.  
  300. VOIDED    LabelDemo3D (HDC hdc)
  301. {
  302.     int    method;
  303.  
  304.     SetViewerName (VL_CURRENT, "3D Labels");
  305.     Scale3D (2, 2, 2);
  306.     method = ShadingOption (VL_CURRENT, VL_SHADINGMETHOD, VL_WIREFRAME);
  307.     PenColor (hdc, VL_GREEN);
  308.     Cube (hdc, 20, 20, 20);
  309.     ShadingOption (VL_CURRENT, VL_SHADINGMETHOD, method);
  310.     TextColor (hdc, VL_RED, VL_BLACK, TRANSPARENT);
  311.     SetTextAlign (hdc, TA_BOTTOM | TA_CENTER);
  312.     Label3D (hdc, -10, -10, 10, "Back Top");
  313.     SetTextAlign (hdc, TA_BASELINE | TA_CENTER);
  314.     Label3D (hdc, 10, 10, 10, "Front Top");
  315.     SetTextAlign (hdc, TA_TOP | TA_CENTER);
  316.     Label3D (hdc, 10, 10, -10, "Front Bottom");
  317.     SetTextAlign (hdc, TA_BASELINE | TA_RIGHT);
  318.     Label3D (hdc, 10, -10, 10, "Left Top");
  319.     Label3D (hdc, 10, -10, -10, "Left Bottom");
  320.     SetTextAlign (hdc, TA_BASELINE | TA_LEFT);
  321.     Label3D (hdc, -10, 10, 10, "Right Top");
  322.     Label3D (hdc, -10, 10, -10, "Right Bottom");
  323. }
  324.  
  325. VOIDED    NetDemo3D (HDC hdc)
  326. {
  327.     COORD    net[210];
  328.     short    i, j, index = 0;
  329.     REAL    x, y;
  330.  
  331.     PushTransformation3D (NULL);
  332.     Scale3D (5, 5, 5);
  333.     PenColor (hdc, VL_BLUE);
  334.     for (i = 0, y = -6.5f; i < 7; i++, y += 2) {
  335.         for (j = 0, x = -9.5f; j < 10; j++, x += 2) {
  336.             net[index++] = x + ((REAL) rand () / RAND_MAX);
  337.             net[index++] = y + ((REAL) rand () / RAND_MAX);
  338.             net[index++] = (REAL) rand () / RAND_MAX;
  339.         }
  340.     }
  341.     Net3D (hdc, VL_3D, (LPCOORD) net, 7, 10);
  342.     PopTransformation3D (NULL);
  343.     SetViewerName (VL_CURRENT, "3D Net");
  344. }
  345.  
  346. VOIDED    Prime3D (HDC hdc, int func)
  347. {
  348.     MarkPosition3D (hdc, 0, 0, 0, 10, VL_ORIGIN);
  349.     switch (func) {
  350.         case IDM_3DPRIME_LINE:
  351.             LineDemo3D (hdc);
  352.             break;
  353.         case IDM_3DPRIME_POLYLINE:
  354.             PolylineDemo3D (hdc);
  355.             break;
  356.         case IDM_3DPRIME_POINTER:
  357.             PointerDemo3D (hdc);
  358.             break;
  359.         case IDM_3DPRIME_MARK:
  360.             MarkDemo3D (hdc);
  361.             break;
  362.         case IDM_3DPRIME_LABEL:
  363.             LabelDemo3D (hdc);
  364.             break;
  365.         case IDM_3DPRIME_NET:
  366.             NetDemo3D (hdc);
  367.             break;
  368.         case IDM_3DPRIME_SPIRAL:
  369.             MarkPosition3D (hdc, 0, 0, 0, 20, VL_ORIGIN);
  370.             PenColor (hdc, VL_GREEN);
  371.             Spiral3D (hdc, 0, 10, 0, 0.5f, 40);
  372.             PenColor (hdc, VL_YELLOW);
  373.             Rotate3D (90, 'y');
  374.             Spiral3D (hdc, 0, 10, 0, 0.5f, 40);
  375.             PenColor (hdc, VL_RED);
  376.             Rotate3D (-90, 'x');
  377.             Spiral3D (hdc, 0, 10, 0, 0.5f, 40);
  378.             SetViewerName (VL_CURRENT, "3D Spiral");
  379.             break;
  380.         case IDM_3DPRIME_SPRING:
  381.             MarkPosition3D (hdc, 0, 0, 0, 20, VL_ORIGIN);
  382.             PenColor (hdc, VL_BLUE);
  383.             Spring3D (hdc, 30, 10, 10, 40);
  384.             PenColor (hdc, VL_YELLOW);
  385.             Rotate3D (90, 'y');
  386.             Spring3D (hdc, 30, 10, 10, 40);
  387.             PenColor (hdc, VL_GREEN);
  388.             Rotate3D (-90, 'x');
  389.             Spring3D (hdc, 30, 10, 10, 40);
  390.             SetViewerName (VL_CURRENT, "3D Springs");
  391.             break;
  392.     }
  393. }
  394.  
  395. VOIDED    DrawNgon (HDC hdc, int type)
  396. {
  397.     REAL    x, y, t, w, h;
  398.     short    i, j, n;
  399.  
  400.     t = 0;
  401.     w = h = 1.75f;
  402.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  403.         for (j = 0, x = -7.5f; j < 4; j++, x += 5) {
  404.             n = i * 4 + j;
  405.             PenColor (hdc, VL_RED + n);
  406.             BrushColor (hdc, VL_RED + j * 3 + i);
  407.             n += 3;
  408.             if (type == VL_THREED)
  409.                 Ngon3D (hdc, x, y, t, w, h, n);
  410.             else
  411.                 Ngon2D (hdc, x, y, t, w, h, n);
  412.         }
  413.     }
  414. }
  415.  
  416. VOIDED    DrawStar (HDC hdc, int type)
  417. {
  418.     REAL    x, y, t, w, h;
  419.     short    i, j, n;
  420.  
  421.     t = 0; w = h = 1.75f;
  422.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  423.         for (j = 0, x = -7.5f; j < 4; j++, x += 5) {
  424.             n = i * 4 + j;
  425.             PenColor (hdc, VL_RED + n);
  426.             BrushColor (hdc, VL_RED + j * 3 + i);
  427.             n += 3;
  428.             if (type == VL_THREED)
  429.                 Star3D (hdc, x, y, t, w, h, n);
  430.             else
  431.                 Star2D (hdc, x, y, t, w, h, n);
  432.         }
  433.     }
  434. }
  435.  
  436. VOIDED    DrawFlower (HDC hdc, int type)
  437. {
  438.     REAL    x, y, t, w, h, r;
  439.     short    i, j, n;
  440.  
  441.     t = 0; w = h = 1.75f; r = 0.75f;
  442.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  443.         ;
  444.         for (j = 0, x = -7.5f; j < 4; j++, x += 5) {
  445.             n = i * 4 + j;
  446.             PenColor (hdc, VL_RED + n);
  447.             BrushColor (hdc, VL_RED + j * 3 + i);
  448.             n += 3;
  449.             if (type == VL_THREED)
  450.                 Flower3D (hdc, x, y, t, w, h, n, r);
  451.             else
  452.                 Flower2D (hdc, x, y, t, w, h, n, r);
  453.         }
  454.     }
  455. }
  456.  
  457. VOIDED    DrawPie (HDC hdc, int type)
  458. {
  459.     REAL    x, y, t, w, h, a, b;
  460.     short    i, j, n;
  461.  
  462.     t = 0;
  463.     a = 0; w = h = 1.75f;
  464.     for (i = 0, y = -6; i < 4; i++, y += 4) {
  465.         for (j = 0, x = -7.5f, b = 30; j < 4; j++, x += 5, b += 30) {
  466.             n = i * 4 + j;
  467.             PenColor (hdc, VL_RED + n);
  468.             BrushColor (hdc, VL_RED + j * 3 + i);
  469.             if (type == VL_THREED)
  470.                 Pie3D (hdc, x, y, t, w, h, a, b);
  471.             else
  472.                 Pie2D (hdc, x, y, t, w, h, a, b);
  473.         }
  474.         t += 90;
  475.     }
  476. }
  477.  
  478. VOIDED    DrawDisk (HDC hdc, int type)
  479. {
  480.     REAL    x, y, t, w, h;
  481.     short    i, j, n;
  482.  
  483.     t = 0;
  484.     w = 2; h = 0.2f;
  485.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  486.         for (j = 0, x = -7.5f; j < 4; j++, x += 5) {
  487.             n = i * 4 + j;
  488.             PenColor (hdc, VL_RED + n);
  489.             BrushColor (hdc, VL_RED + j * 3 + i);
  490.             if (type == VL_THREED)
  491.                 Disk3D (hdc, x, y, t, w, h);
  492.             else
  493.                 Disk2D (hdc, x, y, t, w, h);
  494.             t += 15;
  495.             w -= 0.15f;
  496.             h += 0.15f;
  497.         }
  498.     }
  499. }
  500.  
  501. VOIDED    DrawRose (HDC hdc, int type)
  502. {
  503.     REAL    x, y, t, r;
  504.     short    i, j, m, n;
  505.  
  506.     t = 0;
  507.     r = 2;
  508.     for (i = 0, y = -4; i < 3; i++, y += 4) {
  509.         n = i + 1;
  510.         for (j = 0, x = -7.5f; j < 4; j++, x += 5) {
  511.             switch (n) {
  512.                 case 1:
  513.                     m = j + 2;
  514.                     break;
  515.                 case 2:
  516.                     m = j * 2 + 1;
  517.                     break;
  518.                 case 3:
  519.                     m = j + 1 + j / 2;
  520.                     break;
  521.             }
  522.             PenColor (hdc, VL_RED + i * 4 + j);
  523.             BrushColor (hdc, VL_RED + j * 3 + i);
  524.             if (type == VL_THREED)
  525.                 Rose3D (hdc, x, y, t, r, m, n);
  526.             else
  527.                 Rose2D (hdc, x, y, t, r, m, n);
  528.             t += 15;
  529.         }
  530.     }
  531. }
  532.  
  533. VOIDED    DrawBox (HDC hdc, int type)
  534. {
  535.     REAL    x, y, t, w, h;
  536.     short    i, j, n;
  537.  
  538.     t = 0;
  539.     w = 3; h = 0.6f;
  540.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  541.         for (j = 0, x = -7.5f; j < 4; j++, x += 5, w -= 0.2f, h += 0.2f) {
  542.             n = i * 4 + j;
  543.             PenColor (hdc, VL_RED + n);
  544.             BrushColor (hdc, VL_RED + j * 3 + i);
  545.             if (type == VL_THREED)
  546.                 Box3D (hdc, x, y, t, w, h);
  547.             else
  548.                 Box2D (hdc, x, y, t, w, h);
  549.             t += 15;
  550.         }
  551.     }
  552. }
  553.  
  554. VOIDED    DrawChord (HDC hdc, int type)
  555. {
  556.     REAL    x, y, t, w, h, a, b;
  557.     short    i, j, n;
  558.  
  559.     t = 0;
  560.     a = 0; b = 30; w = h = 1.75f;
  561.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  562.         for (j = 0, x = -7.5f; j < 4; j++, x += 5, b += 30, t += 15) {
  563.             n = i * 4 + j;
  564.             PenColor (hdc, VL_RED + n);
  565.             BrushColor (hdc, VL_RED + j * 3 + i);
  566.             if (type == VL_THREED)
  567.                 Chord3D (hdc, x, y, a, w, h, a, b);
  568.             else
  569.                 Chord2D (hdc, x, y, a, w, h, a, b);
  570.         }
  571.     }
  572. }
  573.  
  574. VOIDED    DrawRing (HDC hdc, int type)
  575. {
  576.     REAL    x, y, t, w, h, a, b;
  577.     short    i, j, n;
  578.  
  579.     ; t = 0;
  580.     a = 0; b = 30; w = h = 1;
  581.     for (i = 0, y = -5; i < 3; i++, y += 5) {
  582.         for (j = 0, x = -7.5f; j < 4; j++, x += 5, b += 30, t += 15) {
  583.             n = i * 4 + j;
  584.             PenColor (hdc, VL_RED + n);
  585.             BrushColor (hdc, VL_RED + j * 3 + i);
  586.             if (type == VL_THREED)
  587.                 Ring3D (hdc, x, y, a, w, h, a, b, 0.5f);
  588.             else
  589.                 Ring2D (hdc, x, y, a, w, h, a, b, 0.5f);
  590.         }
  591.     }
  592. }
  593.  
  594. VOIDED    DrawBezierCurve (HDC hdc, int type)
  595. {
  596.     COORD    point[40];
  597.  
  598.     point[0] = -8; point[1] = 3.5f;
  599.     point[2] = -5; point[3] = 6;
  600.     point[4] = -5; point[5] = 1;
  601.     point[6] = -2; point[7] = 3.5f;
  602.     PenColor (hdc, VL_WHITE);
  603.     if (type == VL_TWOD)
  604.         BezierCurve2D (hdc, VL_2D, point);
  605.     else
  606.         BezierCurve3D (hdc, VL_2D, point);
  607.     PenColor (hdc, VL_GREEN);
  608.     if (type == VL_TWOD)
  609.         Polyline2D (hdc, VL_2D, point, 4);
  610.     else
  611.         Polyline3D (hdc, VL_2D, point, 4);
  612.     PenColor (hdc, VL_WHITE);
  613.     if (type == VL_TWOD)
  614.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_HEXAGONMARK);
  615.     else
  616.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_HEXAGONMARK);
  617.  
  618.     point[0] = 2; point[1] = 3.5f;
  619.     point[2] = 5; point[3] = 6;
  620.     point[4] = 8; point[5] = 3.5f;
  621.     point[6] = 5; point[7] = 1;
  622.     PenColor (hdc, VL_WHITE);
  623.     if (type == VL_TWOD)
  624.         BezierCurve2D (hdc, VL_2D, point);
  625.     else
  626.         BezierCurve3D (hdc, VL_2D, point);
  627.     PenColor (hdc, VL_GREEN);
  628.     if (type == VL_TWOD)
  629.         Polyline2D (hdc, VL_2D, point, 4);
  630.     else
  631.         Polyline3D (hdc, VL_2D, point, 4);
  632.     PenColor (hdc, VL_WHITE);
  633.     if (type == VL_TWOD)
  634.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_CROSSMARK);
  635.     else
  636.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_CROSSMARK);
  637.  
  638.     point[0] = -8; point[1] = -3;
  639.     point[2] = -2; point[3] = -6;
  640.     point[4] = -2; point[5] = -1;
  641.     point[6] = -8; point[7] = -5;
  642.     PenColor (hdc, VL_WHITE);
  643.     if (type == VL_TWOD)
  644.         BezierCurve2D (hdc, VL_2D, point);
  645.     else
  646.         BezierCurve3D (hdc, VL_2D, point);
  647.     PenColor (hdc, VL_GREEN);
  648.     if (type == VL_TWOD)
  649.         Polyline2D (hdc, VL_2D, point, 4);
  650.     else
  651.         Polyline3D (hdc, VL_2D, point, 4);
  652.     PenColor (hdc, VL_WHITE);
  653.     if (type == VL_TWOD)
  654.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_XMARK);
  655.     else
  656.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_XMARK);
  657.  
  658.     point[0] = 2; point[1] = -6;
  659.     point[2] = 5; point[3] = -1;
  660.     point[4] = 8; point[5] = -6;
  661.     point[6] = 2; point[7] = -6;
  662.     PenColor (hdc, VL_WHITE);
  663.     if (type == VL_TWOD)
  664.         BezierCurve2D (hdc, VL_2D, point);
  665.     else
  666.         BezierCurve3D (hdc, VL_2D, point);
  667.     PenColor (hdc, VL_GREEN);
  668.     if (type == VL_TWOD)
  669.         Polyline2D (hdc, VL_2D, point, 4);
  670.     else
  671.         Polyline3D (hdc, VL_2D, point, 4);
  672.     PenColor (hdc, VL_WHITE);
  673.     if (type == VL_TWOD)
  674.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_DIAMONDMARK);
  675.     else
  676.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_DIAMONDMARK);
  677. }
  678.  
  679. VOIDED    DrawBSplineCurve (HDC hdc, int type)
  680. {
  681.     COORD    point[] = {0, 0, 0, 4, 2, 4, 2, 0, 4, 0, 6, 4, 8, 4, 8, 0};
  682.     REAL    knot[20] = {0, 0, 0, 1, 2, 3, 3, 3, 4, 5, 6, 6, 6};
  683.  
  684.     PenColor (hdc, VL_RED);
  685.     TransfVertex (VL_2D, -9, 1, 0, 1, 1, point, 8);
  686.     if (type == VL_TWOD)
  687.         Polyline2D (hdc, VL_2D, point, 8);
  688.     else
  689.         Polyline3D (hdc, VL_2D, point, 8);
  690.     PenColor (hdc, VL_BLUE);
  691.     if (type == VL_TWOD)
  692.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  693.     else
  694.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  695.     
  696.     PenColor (hdc, VL_GREEN);
  697.     if (type == VL_TWOD)
  698.         BSplineCurve2D (hdc, VL_2D, point, 8);
  699.     else
  700.         BSplineCurve3D (hdc, VL_2D, point, 8);
  701.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  702.     PenColor (hdc, VL_RED);
  703.     if (type == VL_TWOD)
  704.         Polyline2D (hdc, VL_2D, point, 8);
  705.     else
  706.         Polyline3D (hdc, VL_2D, point, 8);
  707.     PenColor (hdc, VL_BLUE);
  708.     if (type == VL_TWOD)
  709.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  710.     else
  711.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  712.     PenColor (hdc, VL_GREEN);
  713.     if (type == VL_TWOD)
  714.         SplineInterp2D (hdc, VL_2D, point, 8);
  715.     else
  716.         SplineInterp3D (hdc, VL_2D, point, 8);
  717.     TransfVertex (VL_2D, -10, -6, 0, 1, 1, point, 8);
  718.     PenColor (hdc, VL_RED);
  719.     if (type == VL_TWOD)
  720.         Polyline2D (hdc, VL_2D, point, 8);
  721.     else
  722.         Polyline3D (hdc, VL_2D, point, 8);
  723.  
  724.     PenColor (hdc, VL_BLUE);
  725.     if (type == VL_TWOD)
  726.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  727.     else
  728.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  729.     PenColor (hdc, VL_GREEN);
  730.     if (type == VL_TWOD)
  731.         BSplineCurveClosed2D (hdc, VL_2D, point, 8);
  732.     else
  733.         BSplineCurveClosed3D (hdc, VL_2D, point, 8);
  734.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  735.     PenColor (hdc, VL_RED);
  736.     if (type == VL_TWOD)
  737.         Polyline2D (hdc, VL_2D, point, 8);
  738.     else
  739.         Polyline3D (hdc, VL_2D, point, 8);
  740.     PenColor (hdc, VL_BLUE);
  741.     if (type == VL_TWOD)
  742.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  743.     else
  744.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  745.     PenColor (hdc, VL_GREEN);
  746.     if (type == VL_TWOD)
  747.         NURBSCurveClosed2D (hdc, VL_2D, point, 8, knot);
  748.     else
  749.         NURBSCurveClosed3D (hdc, VL_2D, point, 8, knot);
  750. }
  751.  
  752. VOIDED    DrawCatmullRomCurve (HDC hdc, int type)
  753. {
  754.     COORD    point[] = {0, 0, 0, 1, 1, 1, 1, 0, 2, 0, 3, 1, 4, 1, 4, 0};
  755.  
  756.     TransfVertex (VL_2D, -8, -4, 0, 4, 8, point, 8);
  757.     PenColor (hdc, VL_RED);
  758.     if (type == VL_TWOD)
  759.         Polyline2D (hdc, VL_2D, point, 8);
  760.     else
  761.         Polyline3D (hdc, VL_2D, point, 8);
  762.     PenColor (hdc, VL_BLUE);
  763.     if (type == VL_TWOD)
  764.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  765.     else
  766.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  767.     PenColor (hdc, VL_GREEN);
  768.     if (type == VL_TWOD)
  769.         CatmullRomSpline2D (hdc, VL_2D, point, 8);
  770.     else
  771.         CatmullRomSpline3D (hdc, VL_2D, point, 8);
  772. }
  773.  
  774. void    heart (HDC hdc, int type, BOOL showpnt)
  775. {
  776.     COORD point[] = {0, 0, 0.4f, 0.8f, 2, 1.4f, 2.5f, -1, 1, -2, 0, -3,
  777.                     -1, -2, -2.5f, -1, -2, 1.4f,
  778.                     -0.4f, 0.8f, 0, 0};
  779.     REAL    knot[20] = {0, 0, 0, 1, 2, 3, 3, 3, 4, 5, 6, 6, 6};
  780.  
  781.     if (type == VL_TWOD) {
  782.         PenColor (hdc, VL_RED);
  783.         PushTransformation2D (NULL);
  784.         Scale2D (2, 2);
  785.         NURBSCurve2D (hdc, VL_2D, point, 11, knot);
  786.     }
  787.     else {
  788.         PenColor (hdc, VL_WHITE);
  789.         PushTransformation3D (NULL);
  790.         Scale3D (3, 3, 3);
  791.         NURBSCurve3D (hdc, VL_2D, point, 11, knot);
  792.     }
  793.     if (showpnt) {
  794.         if (type == VL_TWOD) {
  795.             PenColor (hdc, VL_GREEN);
  796.             ClosedPolyline2D (hdc, VL_2D, point, 10); 
  797.             PolyMark2D (hdc, VL_2D, point, 10, 4, 4, VL_BOXMARK);
  798.         }
  799.         else {
  800.             PenColor (hdc, VL_BLUE);
  801.             ClosedPolyline3D (hdc, VL_2D, point, 10); 
  802.             PolyMark3D (hdc, VL_2D, point, 10, 4, 4, VL_BOXMARK);
  803.         }
  804.     }
  805.     if (type == VL_TWOD)
  806.         PopTransformation2D (NULL);
  807.     else
  808.         PopTransformation3D (NULL);
  809. }
  810.  
  811. void    circle (HDC hdc, int type, BOOL showpnt)
  812. {
  813.     POINT2H p[20] = {
  814.         {0, 1, 1}, {0.707f, 0.707f, 0.707f}, {1, 0, 1},
  815.         {0.707f, -0.707f, 0.707f}, {0, -1, 1}, {-0.707f, -0.707f, 0.707f},
  816.         {-1, 0, 1}, {-0.707f, 0.707f, 0.707f}, {0, 1, 1}};
  817.     REAL    knot[20] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4};
  818.  
  819.     if (type == VL_TWOD) {
  820.         PenColor (hdc, VL_RED);
  821.         PushTransformation2D (NULL);
  822.         Scale2D (3, 3);
  823.         QNURBSCurve2D (hdc, VL_2H, (LPCOORD) p, 9, knot);
  824.     }
  825.     else {
  826.         PenColor (hdc, VL_WHITE);
  827.         PushTransformation3D (NULL);
  828.         Scale3D (3, 3, 3);
  829.         QNURBSCurve3D (hdc, VL_2H, (LPCOORD) p, 9, knot);
  830.     }
  831.     if (showpnt) {
  832.         if (type == VL_TWOD) {
  833.             PenColor (hdc, VL_GREEN);
  834.             ClosedPolyline2D (hdc, VL_2H, (LPCOORD) p, 8);
  835.             PolyMark2D (hdc, VL_2H, (LPCOORD) p, 8, 4, 4, VL_BOXMARK);
  836.         }
  837.         else {
  838.             PenColor (hdc, VL_BLUE);
  839.             ClosedPolyline3D (hdc, VL_2H, (LPCOORD) p, 8);
  840.             PolyMark3D (hdc, VL_2H, (LPCOORD) p, 8, 4, 4, VL_BOXMARK);
  841.         }
  842.     }
  843.     if (type == VL_TWOD)
  844.         PopTransformation2D (NULL);
  845.     else
  846.         PopTransformation3D (NULL);
  847. }
  848.  
  849. VOIDED    DrawNURBSCurve (HDC hdc, int type)
  850. {
  851.     circle (hdc, type, TRUE);
  852.     heart (hdc, type, TRUE);
  853. }
  854.  
  855. VOIDED    DrawHermitCurve (HDC hdc, int type)
  856. {
  857.     COORD    point[20];
  858.  
  859.     point[0] = -6; point[1] = -1; point[2] = 6; point[3] = -1;
  860.     point[4] = -10; point[5] = 0; point[6] = 0; point[7] = -40;
  861.     PenColor (hdc, VL_WHITE);
  862.     if (type == VL_TWOD)
  863.         HermitCurve2D (hdc, VL_2D, point);
  864.     else
  865.         HermitCurve3D (hdc, VL_2D, point);
  866.     PenColor (hdc, VL_GREEN);    
  867.     if (type == VL_TWOD) {
  868.         Arrow2D (hdc, point[0], point[1], point[4], point[5],
  869.             4, 1, 0.5f, VL_OPENARROW);
  870.         Arrow2D (hdc, point[2], point[3], point[6], point[7],
  871.             4, 1, 0.5f, VL_OPENARROW);
  872.     }
  873.     else {
  874.         Arrow3D (hdc, point[0], point[1], 0, point[4], point[5], 0,
  875.             4, 1, 0.5f, VL_OPENARROW);
  876.         Arrow3D (hdc, point[2], point[3], 0, point[6], point[7], 0,
  877.             4, 1, 0.5f, VL_OPENARROW);
  878.     }
  879.     PenColor (hdc, VL_WHITE);
  880.     if (type == VL_TWOD) {
  881.         Mark2D (hdc, point[0], point[1], 4, 4, VL_DIAMONDMARK);
  882.         Mark2D (hdc, point[2], point[3], 4, 4, VL_DIAMONDMARK);
  883.     }
  884.     else {
  885.         Mark3D (hdc, point[0], point[1], 0, 4, 4, VL_DIAMONDMARK);
  886.         Mark3D (hdc, point[2], point[3], 0, 4, 4, VL_DIAMONDMARK);
  887.     }
  888. }
  889.  
  890. VOIDED    DrawNURBSCurveKnot (HDC hdc, int type)
  891. {
  892.     COORD    point[] = {0, 0, 0, 4, 2, 4, 2, 0, 4, 0, 6, 4, 8, 4, 8, 0};
  893.     REAL Knot1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  894.     REAL Knot2[] = {0, 0, 0, 1, 1, 1, 4, 5, 5, 5};
  895.     REAL Knot3[] = {0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 6};
  896.     REAL Knot4[] = {0, 0, 0, 1, 3, 5, 7, 9, 10, 15};
  897.  
  898.     TransfVertex (VL_2D, -9, 1, 0, 1, 1, point, 8);
  899.     PenColor (hdc, VL_RED);
  900.     if (type == VL_TWOD)
  901.         Polyline2D (hdc, VL_2D, point, 8);
  902.     else
  903.         Polyline3D (hdc, VL_2D, point, 8);
  904.         
  905.     PenColor (hdc, VL_BLUE);
  906.     if (type == VL_TWOD)
  907.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  908.     else
  909.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  910.     PenColor (hdc, VL_GREEN);
  911.     if (type == VL_TWOD)
  912.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot1);
  913.     else
  914.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot1);
  915.  
  916.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  917.     PenColor (hdc, VL_RED);
  918.     if (type == VL_TWOD)
  919.         Polyline2D (hdc, VL_2D, point, 8);
  920.     else
  921.         Polyline3D (hdc, VL_2D, point, 8);
  922.     PenColor (hdc, VL_BLUE);
  923.     if (type == VL_TWOD)
  924.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  925.     else
  926.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  927.     PenColor (hdc, VL_GREEN);
  928.     if (type == VL_TWOD)
  929.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot2);
  930.     else
  931.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot2);
  932.  
  933.     TransfVertex (VL_2D, -10, -6, 0, 1, 1, point, 8);
  934.     PenColor (hdc, VL_RED);
  935.     if (type == VL_TWOD)
  936.         Polyline2D (hdc, VL_2D, point, 8);
  937.     else
  938.         Polyline3D (hdc, VL_2D, point, 8);
  939.     PenColor (hdc, VL_BLUE);
  940.     if (type == VL_TWOD)
  941.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  942.     else
  943.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  944.     PenColor (hdc, VL_GREEN);
  945.     if (type == VL_TWOD)
  946.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot3);
  947.     else
  948.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot3);
  949.  
  950.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  951.     PenColor (hdc, VL_RED);
  952.     if (type == VL_TWOD)
  953.         Polyline2D (hdc, VL_2D, point, 8);
  954.     else
  955.         Polyline3D (hdc, VL_2D, point, 8);
  956.     PenColor (hdc, VL_BLUE);
  957.     if (type == VL_TWOD)
  958.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  959.     else
  960.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  961.     PenColor (hdc, VL_GREEN);
  962.     if (type == VL_TWOD)
  963.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot4);
  964.     else
  965.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot4);
  966. }
  967.  
  968. VOIDED    DrawQNURBSCurve (HDC hdc, int type)
  969. {
  970.     COORD    point[] = {0, 1, 1, 0.707f, 0.707f, 0.707f, 1, 0, 1,
  971.         0.707f, -0.707f, 0.707f, 0, -1, 1, -0.707f, -0.707f, 0.707f,
  972.         -1, 0, 1, -0.707f, 0.707f, 0.707f, 0, 1, 1};
  973.     REAL knot[] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4};
  974.  
  975.     PenColor (hdc, VL_RED);
  976.     if (type == VL_TWOD) {
  977.         PushTransformation2D (NULL);
  978.         Translate2D (-5, -3);
  979.         Scale2D (3, 3);
  980.         ClosedPolyline2D (hdc, VL_2H, point, 8);
  981.     }
  982.     else {
  983.         PushTransformation3D (NULL);
  984.         Translate3D (-5, -3, 0);
  985.         Scale3D (3, 3, 3);
  986.         ClosedPolyline3D (hdc, VL_2H, point, 8);
  987.     }
  988.     PenColor (hdc, VL_BLUE);
  989.     if (type == VL_TWOD)
  990.         PolyMark2D (hdc, VL_2H, point, 8, 3, 3, VL_DIAMONDMARK);
  991.     else
  992.         PolyMark3D (hdc, VL_2H, point, 8, 3, 3, VL_DIAMONDMARK);
  993.     PenColor (hdc, VL_GREEN);
  994.     if (type == VL_TWOD) {
  995.         QNURBSCurve2D (hdc, VL_2H, point, 9, knot);
  996.         PopTransformation2D (NULL);
  997.     }
  998.     else {
  999.         QNURBSCurve3D (hdc, VL_2H, point, 9, knot);
  1000.         PopTransformation3D (NULL);
  1001.     }
  1002. }
  1003.  
  1004. VOIDED    DrawQuadraticCurve (HDC hdc, int type)
  1005. {
  1006.     COORD    point[] = {0, 0, 0, 4, 2, 4, 2, 0, 4, 0, 6, 4, 8, 4, 8, 0, 0, 0};
  1007.     REAL    knot[20] = {0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7};
  1008.     short    i;
  1009.  
  1010.     PenColor (hdc, VL_RED);
  1011.     TransfVertex (VL_2D, -9, 1, 0, 1, 1, point, 9);
  1012.     if (type == VL_TWOD)
  1013.         ClosedPolyline2D (hdc, VL_2D, point, 8);
  1014.     else
  1015.         ClosedPolyline3D (hdc, VL_2D, point, 8);
  1016.     PenColor (hdc, VL_BLUE);
  1017.     if (type == VL_TWOD)
  1018.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1019.     else
  1020.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1021.     PenColor (hdc, VL_GREEN);
  1022.     if (type == VL_TWOD) {
  1023.         for (i = 0; i < 7; i += 2)
  1024.             QBezierCurve2D (hdc, VL_2D, &point[i*2]);
  1025.     }
  1026.     else {
  1027.         for (i = 0; i < 7; i += 2)
  1028.             QBezierCurve3D (hdc, VL_2D, &point[i*2]);
  1029.     }
  1030.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 9);
  1031.     PenColor (hdc, VL_RED);
  1032.     if (type == VL_TWOD)
  1033.         ClosedPolyline2D (hdc, VL_2D, point, 8);
  1034.     else
  1035.         ClosedPolyline3D (hdc, VL_2D, point, 8);
  1036.     PenColor (hdc, VL_BLUE);
  1037.     if (type == VL_TWOD)
  1038.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1039.     else
  1040.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1041.     PenColor (hdc, VL_GREEN);
  1042.     if (type == VL_TWOD)
  1043.         QBSplineCurve2D (hdc, VL_2D, point, 9);
  1044.     else
  1045.         QBSplineCurve3D (hdc, VL_2D, point, 9);
  1046.  
  1047.     TransfVertex (VL_2D, 0, -6, 0, 1, 1, point, 9);
  1048.     PenColor (hdc, VL_RED);
  1049.     if (type == VL_TWOD)
  1050.         Polyline2D (hdc, VL_2D, point, 8);
  1051.     else
  1052.         Polyline3D (hdc, VL_2D, point, 8);
  1053.     PenColor (hdc, VL_BLUE);
  1054.     if (type == VL_TWOD)
  1055.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1056.     else
  1057.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1058.     PenColor (hdc, VL_GREEN);
  1059.     if (type == VL_TWOD)
  1060.         QNURBSCurve2D (hdc, VL_2D, point, 8, knot);
  1061.     else
  1062.         QNURBSCurve3D (hdc, VL_2D, point, 8, knot);
  1063.     DrawQNURBSCurve (hdc, type);
  1064. }
  1065.  
  1066. VOIDED    SelectPrimitives (HDC hdc, WORD cmd)
  1067. {
  1068.     switch (cmd) {
  1069.         case IDM_2DCURVE_BEZIER:
  1070.             SetViewerName (VL_CURRENT, "Bezier Curves in 2D");
  1071.             DrawBezierCurve (hdc, VL_TWOD);
  1072.             break;
  1073.         case IDM_3DCURVE_BEZIER:
  1074.             SetViewerName (VL_CURRENT, "Bezier Curves in 3D");
  1075.             DrawBezierCurve (hdc, VL_THREED);
  1076.             break;
  1077.         case IDM_2DCURVE_BSPLINE:
  1078.             SetViewerName (VL_CURRENT, "B-Spline Curves in 2D");
  1079.             DrawBSplineCurve (hdc, VL_TWOD);
  1080.             break;
  1081.         case IDM_3DCURVE_BSPLINE:
  1082.             SetViewerName (VL_CURRENT, "B-Spline Curves in 3D");
  1083.             DrawBSplineCurve (hdc, VL_THREED);
  1084.             break;
  1085.         case IDM_2DCURVE_HERMIT:
  1086.             SetViewerName (VL_CURRENT, "2D Hermit Curves");
  1087.             DrawHermitCurve (hdc, VL_TWOD);
  1088.             break;
  1089.         case IDM_3DCURVE_HERMIT:
  1090.             SetViewerName (VL_CURRENT, "3D Hermit Curves");
  1091.             DrawHermitCurve (hdc, VL_THREED);
  1092.             break;
  1093.         case IDM_2DCURVE_NURBSKNOTS:
  1094.             SetViewerName (VL_CURRENT, "2D NUBRS Curves w/ Different Knots");
  1095.             DrawNURBSCurveKnot (hdc, VL_TWOD);
  1096.             break;
  1097.         case IDM_3DCURVE_NURBSKNOTS:
  1098.             SetViewerName (VL_CURRENT, "3D NUBRS Curves w/ Different Knots");
  1099.             DrawNURBSCurveKnot (hdc, VL_THREED);
  1100.             break;
  1101.         case IDM_2DCURVE_CATMULLROM:
  1102.             SetViewerName (VL_CURRENT, "2D Catmull-Rom Curve");
  1103.             DrawCatmullRomCurve (hdc, VL_TWOD);
  1104.             break;
  1105.         case IDM_3DCURVE_CATMULLROM:
  1106.             SetViewerName (VL_CURRENT, "3D Catmull-Rom Curve");
  1107.             DrawCatmullRomCurve (hdc, VL_THREED);
  1108.             break;
  1109.         case IDM_2DCURVE_NURBS:
  1110.             SetViewerName (VL_CURRENT, "2D Cubic and Quadratic NUBRS");
  1111.             DrawNURBSCurve (hdc, VL_TWOD);
  1112.             break;
  1113.         case IDM_3DCURVE_NURBS:
  1114.             SetViewerName (VL_CURRENT, "3D Cubic and Quadratic NUBRS");
  1115.             DrawNURBSCurve (hdc, VL_THREED);
  1116.             break;
  1117.         case IDM_2DCURVE_QBEZIER:
  1118.             SetViewerName (VL_CURRENT, "2D Quadratic Bezier Curve");
  1119.             DrawQuadraticCurve (hdc, VL_TWOD);
  1120.             break;
  1121.         case IDM_3DCURVE_QBEZIER:
  1122.             SetViewerName (VL_CURRENT, "3D Quadratic Bezier Curve");
  1123.             DrawQuadraticCurve (hdc, VL_THREED);
  1124.             break;
  1125.         case IDM_3DSHAPE_ROSE:
  1126.             SetViewerName (VL_CURRENT, "Roses in 3D");
  1127.             DrawRose (hdc, VL_THREED);
  1128.             break;
  1129.         case IDM_3DSHAPE_BOX:
  1130.             SetViewerName (VL_CURRENT, "Rectangles in 3D");
  1131.             DrawBox (hdc, VL_THREED);
  1132.             break;
  1133.         case IDM_3DSHAPE_DISK:
  1134.             SetViewerName (VL_CURRENT, "Disks in 3D");
  1135.             DrawDisk (hdc, VL_THREED);
  1136.             break;
  1137.         case IDM_3DSHAPE_NGON:
  1138.             SetViewerName (VL_CURRENT, "Nside Polygons in 3D");
  1139.             DrawNgon (hdc, VL_THREED);
  1140.             break;
  1141.         case IDM_3DSHAPE_STAR:
  1142.             SetViewerName (VL_CURRENT, "Nside Stars in 3D");
  1143.             DrawStar (hdc, VL_THREED);
  1144.             break;
  1145.         case IDM_3DSHAPE_FLOWER:
  1146.             DrawFlower (hdc, VL_THREED);
  1147.             SetViewerName (VL_CURRENT, "Nside Flowers in 3D");
  1148.             break;
  1149.         case IDM_3DSHAPE_CHORD:
  1150.             SetViewerName (VL_CURRENT, "Chords in 3D");
  1151.             DrawChord (hdc, VL_THREED);
  1152.             break;
  1153.         case IDM_3DSHAPE_PIE:
  1154.             SetViewerName (VL_CURRENT, "Pies in 3D");
  1155.             DrawPie (hdc, VL_THREED);
  1156.             break;
  1157.         case IDM_3DSHAPE_RING:
  1158.             SetViewerName (VL_CURRENT, "Rings in 3D");
  1159.             DrawRing (hdc, VL_THREED);
  1160.             break;
  1161.         case IDM_2DSHAPE_ROSE:
  1162.             SetViewerName (VL_CURRENT, "Roses in 2D");
  1163.             DrawRose (hdc, VL_TWOD);
  1164.             break;
  1165.         case IDM_2DSHAPE_BOX:
  1166.             SetViewerName (VL_CURRENT, "Rectangles in 2D");
  1167.             DrawBox (hdc, VL_TWOD);
  1168.             break;
  1169.         case IDM_2DSHAPE_DISK:
  1170.             SetViewerName (VL_CURRENT, "Disks in 2D");
  1171.             DrawDisk (hdc, VL_TWOD);
  1172.             break;
  1173.         case IDM_2DSHAPE_NGON:
  1174.             SetViewerName (VL_CURRENT, "Nside Polygons in 2D");
  1175.             DrawNgon (hdc, VL_TWOD);
  1176.             break;
  1177.         case IDM_2DSHAPE_STAR:
  1178.             SetViewerName (VL_CURRENT, "Nside Stars in 2D");
  1179.             DrawStar (hdc, VL_TWOD);
  1180.             break;
  1181.         case IDM_2DSHAPE_FLOWER:
  1182.             SetViewerName (VL_CURRENT, "Nside Flowers in 2D");
  1183.             DrawFlower (hdc, VL_TWOD);
  1184.             break;
  1185.         case IDM_2DSHAPE_CHORD:
  1186.             SetViewerName (VL_CURRENT, "Chords in 2D");
  1187.             DrawChord (hdc, VL_TWOD);
  1188.             break;
  1189.         case IDM_2DSHAPE_PIE:
  1190.             SetViewerName (VL_CURRENT, "Pies in 2D");
  1191.             DrawPie (hdc, VL_TWOD);
  1192.             break;
  1193.         case IDM_2DSHAPE_RING:
  1194.             SetViewerName (VL_CURRENT, "Rings in 2D");
  1195.             DrawRing (hdc, VL_TWOD);
  1196.             break;
  1197.     }
  1198. }
  1199.  
  1200. VOIDED    Primitives2D (HDC hdc, int cmd)
  1201. {
  1202.     SelectPrimitives (hdc, cmd);
  1203. }
  1204.  
  1205. VOIDED    Primitives3D (HDC hdc, int cmd)
  1206. {
  1207.     PushTransformation3D (NULL);
  1208.     Scale3D (3, 3, 3);
  1209.     MarkPosition3D (hdc, 0, 0, 0, 10, VL_ORIGIN);
  1210.  
  1211.     PushTransformation3D (NULL);
  1212.     Translate3D (10, 8, 0);
  1213.     SelectPrimitives (hdc, cmd);
  1214.     PopTransformation3D (NULL);
  1215.     PushTransformation3D (NULL);
  1216.     Rotate3D (90, 'x');
  1217.     Translate3D (10, 8, 0);
  1218.     SelectPrimitives (hdc, cmd);
  1219.     PopTransformation3D (NULL);
  1220.     PushTransformation3D (NULL);
  1221.     Rotate3D (-90, 'y');
  1222.     Translate3D (10, 8, 0);
  1223.     SelectPrimitives (hdc, cmd);
  1224.     PopTransformation3D (NULL);
  1225.     PopTransformation3D (NULL);
  1226. }
  1227.  
  1228. BINARY _export    BiArrayBox (HDC hdc, int row, int col)
  1229. {
  1230.     short    mid;
  1231.  
  1232.     switch ((row + col) % 4) {
  1233.         case 0: mid = 1; break;
  1234.         case 1: mid = 2; break;
  1235.         case 2: mid = 3; break;
  1236.         case 3: mid = 4; break;
  1237.     }
  1238.     SelectMaterial (mid);
  1239.     return (Cube (hdc, 2, 3, 4));
  1240. }
  1241.  
  1242. BINARY _export    TriArrayBox (HDC hdc, int row, int col, int lev)
  1243. {
  1244.     SelectMaterial ((row + col + lev) % 4 + 1);
  1245.     return (Cube (hdc, 2, 3, 2));
  1246. }
  1247.  
  1248. VOIDED _export    ObjectArray3D (HDC hdc, int func)
  1249. {
  1250.     ClearDepthBuffer (0xffff);
  1251.     switch (func) {
  1252.         case IDM_3DARRAY_RECTANGLE:
  1253.             RectangularArray3D (hdc, 4, 6, 8, 8, BiArrayBox);
  1254.             SetViewerName (VL_CURRENT, "4x6 Rectangular Object Array");
  1255.             break;
  1256.         case IDM_3DARRAY_POLAR:
  1257.             PolarArray3D (hdc, 4, 6, 10, 30, 5, BiArrayBox);
  1258.             SetViewerName (VL_CURRENT, "4x6 Polar Object Array");
  1259.             break;
  1260.         case IDM_3DARRAY_CUBIC:
  1261.             CubicArray (hdc, 4, 6, 5, 8, 8, 4, TriArrayBox);
  1262.             SetViewerName (VL_CURRENT, "4x6x5 Cubic Object Array");
  1263.             break;
  1264.         case IDM_3DARRAY_CYLINDRIC:
  1265.             CylindricArray (hdc, 4, 6, 5, 10, 30, 5, 5, TriArrayBox);
  1266.             SetViewerName (VL_CURRENT, "4x6x5 Cylindric Object Array");
  1267.             break;
  1268.         case IDM_3DARRAY_SPHERIC:
  1269.             SphericArray (hdc, 4, 6, 5, 10, 30, 30, 10, 30, TriArrayBox);
  1270.             SetViewerName (VL_CURRENT, "4x6x5 Spheric Object Array");
  1271.             break;
  1272.     }
  1273. }
  1274.  
  1275. BINARY _export    RectangularArray2DProc (HDC hdc, int row, int col)
  1276. {
  1277.     short    index;
  1278.  
  1279.     index = row * 6 + col + 1;
  1280.     BrushColor (hdc, index);
  1281.     Ngon2D (hdc, 0, 0, 0, 1, 1, index + 2);
  1282.     return (TRUE);
  1283. }
  1284.  
  1285. BINARY _export    PolarArray2DProc (HDC hdc, int row, int col)
  1286. {
  1287.     BrushColor (hdc, row * 3 + col + 1);
  1288.     switch (col % 3) {
  1289.         case 0:
  1290.             Ngon2D (hdc, 0, 0, 0, 1, 1, row + 3);
  1291.             break;
  1292.         case 1:
  1293.             Star2D (hdc, 0, 0, 0, 1, 1, row + 3);
  1294.             break;
  1295.         case 2:
  1296.             Flower2D (hdc, 0, 0, 0, 1, 1, row + 3, 2);
  1297.             break;
  1298.     }
  1299.     return (TRUE);
  1300. }
  1301.  
  1302. VOIDED    ObjectArray2D(HDC hdc, int func)
  1303. {
  1304.     switch (func) {
  1305.         case IDM_2DARRAY_RECTANGLE:
  1306.             SetViewerName (VL_CURRENT, "4x6 Rectangular Object Array");
  1307.             Translate2D (-8, -5);
  1308.             RectangularArray2D (hdc, 4, 6, 3, 3, RectangularArray2DProc);
  1309.             break;
  1310.         case IDM_2DARRAY_POLAR:
  1311.             PolarArray2D (hdc, 12, 3, 2, 30, 2, PolarArray2DProc);
  1312.             SetViewerName (VL_CURRENT, "4x6 Polar Object Array");
  1313.             break;
  1314.     }
  1315. }
  1316.  
  1317. BINARY    USFlag (HDC hdc)
  1318. {
  1319.     short   i, j;
  1320.     REAL    x1, y1, x2, y2;
  1321.     REAL    r, width, height;
  1322.  
  1323.     width = 1;
  1324.     height = (REAL) 13 / 24;
  1325.     x1 = 0;
  1326.     x2 = width;
  1327.     y1 = 0;
  1328.     y2 = height / 13;
  1329.     BrushColor (hdc, VL_RED);
  1330.     PenColor (hdc, VL_RED);
  1331.     for (i = 0; i < 7; i ++) {
  1332.         Rectangle2D (hdc, x1, y1, x2, y2);
  1333.         y1 += height * 2 / 13;
  1334.         y2 += height * 2 / 13;
  1335.     }
  1336.  
  1337.     BrushColor (hdc, VL_WHITE);
  1338.     PenColor (hdc, VL_WHITE);
  1339.     y1 = height / 13;
  1340.     y2 = height * 2 / 13 - 0.001f;
  1341.     for (i = 0; i < 6; i ++) {
  1342.         Rectangle2D (hdc, x1, y1, x2, y2);
  1343.         y1 += height * 2 / 13;
  1344.         y2 += height * 2 / 13;
  1345.     }
  1346.  
  1347.     BrushColor (hdc, VL_BLUE);
  1348.     PenColor (hdc, VL_BLUE);
  1349.     x2 = 10 * width / 24;
  1350.     y1 = 6 * height / 13;
  1351.     y2 = height;
  1352.     Rectangle2D (hdc, x1, y1, x2, y2);
  1353.  
  1354.     BrushColor (hdc, VL_WHITE);
  1355.     PenColor (hdc, VL_WHITE);
  1356.     x2 /= 6;
  1357.     x1 = x2 / 2;
  1358.     y2 = height * 7 / 13 / 5;
  1359.     r = 0.01f;
  1360.     for (i = 0; i < 6 ; i ++) {
  1361.         y1 = height - y2 / 2;
  1362.         for (j = 0; j < 5; j ++) {
  1363.             Star2D (hdc, x1, y1, 0, r, r, 5);
  1364.             y1 -= y2;
  1365.         }
  1366.         x1 = x1 + x2;
  1367.     }
  1368.     x1 = x2;
  1369.     for (i = 0; i < 5; i ++) {
  1370.         y1 = height - y2;
  1371.         for (j = 0; j < 4; j ++) {
  1372.             Star2D (hdc, x1, y1, 0, r, r, 5);
  1373.             y1 -= y2;
  1374.         }
  1375.         x1 = x1 + x2;
  1376.     }
  1377.     return (TRUE);
  1378. }
  1379.