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 >
Wrap
Text File
|
1999-11-10
|
2KB
|
74 lines
'
' ####################
' ##### PROLOG #####
' ####################
'
PROGRAM "agraphic"
VERSION "0.0000"
'
IMPORT "xst"
IMPORT "xgr"
'
' This program shows how to do graphics with functions
' in the XBasic GraphicsDesigner function library only.
' No GuiDesigner functions are called.
'
' This program creates a window, creates a single grid
' that fills the entire window, then draws a number of
' lines, circles, boxes, triangles and text in the grid.
'
' This program is primarily for programmers who want to
' add graphics to conventional programs but do not want
' to write GuiDesigner programs.
'
' For examples of graphics in GuiDesigner programs,
' see the "acircle.x" and "ademo.x" sample programs.
'
'
DECLARE FUNCTION Entry ()
'
'
' ######################
' ##### Entry () #####
' ######################
'
'
FUNCTION Entry ()
XgrGetDisplaySize ("", @#displayWidth, @#displayHeight, @#windowBorderWidth, @#windowTitleHeight)
'
x = #windowBorderWidth
y = #windowBorderWidth + #windowTitleHeight
w = (#displayWidth >> 1) - #windowBorderWidth - #windowBorderWidth
h = (#displayHeight >> 1) - #windowBorderWidth - #windowBorderWidth - #windowTitleHeight
XgrCreateWindow (@window, 0, x, y, w, h, 0, "")
XgrSetWindowTitle (window, @"GraphicsDesigner : simple demonstration")
XgrCreateGrid (@grid, 0, 0, 0, w, h, window, 0, 0)
XgrDisplayWindow (window)
XgrClearGrid (grid, $$Black)
XgrDrawLine (grid, $$LightYellow, 0, 0, w-1, h-1)
XgrDrawLine (grid, $$LightGreen, w-1, 0, 0, h-1)
x1 = (w >>> 2) - 1
y1 = (h >>> 2) - 1
x2 = w - (w >>> 2) - 1
y2 = h - (h >>> 2) - 1
XgrDrawBox (grid, $$LightBlue, x1, y1, x2, y2)
r = h >>> 3
XgrSetDrawpoint (grid, (w >> 1), (h >> 1))
XgrDrawCircle (grid, $$LightRed, r)
XgrDrawLine (grid, $$LightOrange, (w >> 1), 0, (w >> 1), h-1)
XgrDrawLine (grid, $$LightCyan, 0, (h >> 1), w-1, (h >> 1))
XgrSetDrawpoint (grid, (w >> 1), (h >> 1))
XgrDrawCircle (grid, $$LightMagenta, r >> 1)
XgrFillBox (grid, $$Grey, w - (w >> 3), h - (h >> 2), w - (w >> 4), h - (h >> 3) - 16)
XgrFillTriangle (grid, $$Aqua, 0, $$TriangleUp, w >> 3, h >> 2, (w >> 2) - 8, (h >> 1) - 8)
XgrSetDrawpoint (grid, (w >> 2), (h >> 3))
XgrDrawText (grid, $$BrightGreen, @"draw simple graphics")
XgrCreateFont (@font, @"Comic Sans MS", 480, 400, 0, 0)
XgrSetDrawpoint (grid, (w >> 1) + 16, (h >> 3))
XgrSetGridFont (grid, font)
XgrDrawText (grid, $$BrightBlue, @"draw simple graphics")
XstSleep (8000)
END FUNCTION
END PROGRAM