home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 August / PCWorld_2000-08_cd.bin / Software / TemaCD / xbasic / xbpro.exe / xb / agraphic.x < prev    next >
Text File  |  1999-11-10  |  2KB  |  74 lines

  1. '
  2. ' ####################
  3. ' #####  PROLOG  #####
  4. ' ####################
  5. '
  6. PROGRAM    "agraphic"
  7. VERSION    "0.0000"
  8. '
  9. IMPORT    "xst"
  10. IMPORT    "xgr"
  11. '
  12. ' This program shows how to do graphics with functions
  13. ' in the XBasic GraphicsDesigner function library only.
  14. ' No GuiDesigner functions are called.
  15. '
  16. ' This program creates a window, creates a single grid
  17. ' that fills the entire window, then draws a number of
  18. ' lines, circles, boxes, triangles and text in the grid.
  19. '
  20. ' This program is primarily for programmers who want to
  21. ' add graphics to conventional programs but do not want
  22. ' to write GuiDesigner programs.
  23. '
  24. ' For examples of graphics in GuiDesigner programs,
  25. ' see the "acircle.x" and "ademo.x" sample programs.
  26. '
  27. '
  28. DECLARE FUNCTION  Entry ()
  29. '
  30. '
  31. ' ######################
  32. ' #####  Entry ()  #####
  33. ' ######################
  34. '
  35. '
  36. FUNCTION  Entry ()
  37.  
  38.     XgrGetDisplaySize ("", @#displayWidth, @#displayHeight, @#windowBorderWidth, @#windowTitleHeight)
  39. '
  40.     x = #windowBorderWidth
  41.     y = #windowBorderWidth + #windowTitleHeight
  42.     w = (#displayWidth >> 1) - #windowBorderWidth - #windowBorderWidth
  43.     h = (#displayHeight >> 1) - #windowBorderWidth - #windowBorderWidth - #windowTitleHeight
  44.     XgrCreateWindow (@window, 0, x, y, w, h, 0, "")
  45.     XgrSetWindowTitle (window, @"GraphicsDesigner : simple demonstration")
  46.     XgrCreateGrid (@grid, 0, 0, 0, w, h, window, 0, 0)
  47.     XgrDisplayWindow (window)
  48.     XgrClearGrid (grid, $$Black)
  49.     XgrDrawLine (grid, $$LightYellow, 0, 0, w-1, h-1)
  50.     XgrDrawLine (grid, $$LightGreen, w-1, 0, 0, h-1)
  51.     x1 = (w >>> 2) - 1
  52.     y1 = (h >>> 2) - 1
  53.     x2 = w - (w >>> 2) - 1
  54.     y2 = h - (h >>> 2) - 1
  55.     XgrDrawBox (grid, $$LightBlue, x1, y1, x2, y2)
  56.     r = h >>> 3
  57.     XgrSetDrawpoint (grid, (w >> 1), (h >> 1))
  58.     XgrDrawCircle (grid, $$LightRed, r)
  59.     XgrDrawLine (grid, $$LightOrange, (w >> 1), 0, (w >> 1), h-1)
  60.     XgrDrawLine (grid, $$LightCyan, 0, (h >> 1), w-1, (h >> 1))
  61.     XgrSetDrawpoint (grid, (w >> 1), (h >> 1))
  62.     XgrDrawCircle (grid, $$LightMagenta, r >> 1)
  63.     XgrFillBox (grid, $$Grey, w - (w >> 3), h - (h >> 2), w - (w >> 4), h - (h >> 3) - 16)
  64.     XgrFillTriangle (grid, $$Aqua, 0, $$TriangleUp, w >> 3, h >> 2, (w >> 2) - 8, (h >> 1) - 8)
  65.     XgrSetDrawpoint (grid, (w >> 2), (h >> 3))
  66.     XgrDrawText (grid, $$BrightGreen, @"draw simple graphics")
  67.     XgrCreateFont (@font, @"Comic Sans MS", 480, 400, 0, 0)
  68.     XgrSetDrawpoint (grid, (w >> 1) + 16, (h >> 3))
  69.     XgrSetGridFont (grid, font)
  70.     XgrDrawText (grid, $$BrightBlue, @"draw simple graphics")
  71.     XstSleep (8000)
  72. END FUNCTION
  73. END PROGRAM
  74.