home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / S12219.ZIP / VF14.C < prev    next >
C/C++ Source or Header  |  1988-11-29  |  2KB  |  72 lines

  1. /*--------------------------------------
  2.    VF14.C -- Clipped wavy spline curves
  3.   --------------------------------------*/
  4.  
  5. #define INCL_GPI
  6. #include <os2.h>
  7. #include <stdlib.h>
  8. #include "vectfont.h"
  9.  
  10. VOID Display_Wavy (HPS hps, LONG cxClient, LONG cyClient)
  11.      {
  12.      static CHAR szText[] = "Hello!" ;
  13.      static LONG cbText = sizeof szText - 1 ;
  14.      static LONG lColors[] = { CLR_BLUE, CLR_GREEN,  CLR_CYAN, CLR_RED,
  15.                                CLR_PINK, CLR_YELLOW, CLR_WHITE } ;
  16.      INT         i ;
  17.      POINTL      ptl, aptl[8] ;
  18.  
  19.      CreateVectorFont (hps, LCID_MYFONT, "Tms Rmn Italic") ;
  20.      GpiSetCharSet (hps, LCID_MYFONT) ;
  21.      ScaleFontToBox (hps, cbText, szText, cxClient, cyClient) ;
  22.      QueryStartPointInTextBox (hps, cbText, szText, &ptl) ;
  23.  
  24.      ColorClient (hps, cxClient, cyClient, CLR_BLACK) ;
  25.  
  26.      GpiBeginPath (hps, ID_PATH) ;
  27.      GpiCharStringAt (hps, &ptl, cbText, szText) ;     // Text string
  28.      GpiEndPath (hps) ;
  29.  
  30.      GpiSetClipPath (hps, ID_PATH, SCP_AND | SCP_ALTERNATE) ;
  31.  
  32.      for (i = 0 ; i < 14 ; i++)
  33.           {
  34.           aptl[0].x = 0 ;
  35.           aptl[0].y = i * cyClient / 14 ;
  36.  
  37.           aptl[1].x = cxClient / 3 ;
  38.           aptl[1].y = min (cyClient, 2 * i * cyClient / 14) ;
  39.  
  40.           aptl[2].x = 2 * cxClient / 3 ;
  41.           aptl[2].y = max (0L, (2 * i - 14) * cyClient / 14) ;
  42.  
  43.           aptl[3].x = cxClient ;
  44.           aptl[3].y = i * cyClient / 14 ;
  45.  
  46.           aptl[4].x = cxClient ;
  47.           aptl[4].y = (i + 1) * cyClient / 14 ;
  48.  
  49.           aptl[5].x = 2 * cxClient / 3 ;
  50.           aptl[5].y = max (0L, (2 * (i + 1) - 14) * cyClient / 14) ;
  51.  
  52.           aptl[6].x = cxClient / 3 ;
  53.           aptl[6].y = min (cyClient, 2 * (i + 1) * cyClient / 14) ;
  54.  
  55.           aptl[7].x = 0 ;
  56.           aptl[7].y = (i + 1) * cyClient / 14 ;
  57.  
  58.           GpiSetColor (hps, lColors[i % 7]) ;
  59.           GpiBeginArea (hps, BA_BOUNDARY | BA_ALTERNATE) ;
  60.  
  61.           GpiMove (hps, aptl) ;                        // Splines
  62.           GpiPolySpline (hps, 3L, aptl + 1) ;
  63.           GpiLine (hps, aptl + 4) ;
  64.           GpiPolySpline (hps, 3L, aptl + 5) ;
  65.           GpiLine (hps, aptl) ;
  66.  
  67.           GpiEndArea (hps) ;
  68.           }
  69.      GpiSetCharSet (hps, LCID_DEFAULT) ;               // Clean up
  70.      GpiDeleteSetId (hps, LCID_MYFONT) ;
  71.      }
  72.