Primitive Graphics |
Top Previous Next |
Emergence BASIC has graphic functions for lines, rectangles, ellipses, points, images, icons and cursors. Primitive graphic elements are drawn in the current foreground and background colors. LINE and LINETO statements The LINE statement draws a solid line between the start and end points specified. The LINETO statement draws a line between the last pen position and the end point specified. The line will be drawn in the current foreground color unless changed by the optional color parameter. The syntax of the line statements are: LINE window startx, starty, endx, endy {, color} LINETO window endx, endy {,color} For the LINETO statement the last pen position is updated by any other graphic primitive or the MOVE statement DEF w as WINDOW RECT statement The RECT statement is used to draw rectangles in the window. Rectangles can be filled with an optional fill color. The rectangle is drawn in the current foreground color unless a border color is specified. The syntax of the RECT statement is: RECT window, left, top, width, height {, border {, fill}} ELLIPSE statement The ELLIPSE statement is used to draw ellipses in the window. The ellipse will be bound by the rectangle specified in the left,top,width and height parameters. The ellipse drawn in the current foreground color unless a border color is specified. The ellipse may be filled with an optional fill color. The syntax of the ellipse statement is: ELLIPSE window, left, top, width, height {, border {, fill}} CIRCLE statement The CIRCLE statement is used to draw device independent circles. The circle will be drawn at the starting point specified with the radius specified. The circle will be drawn in the current foreground color unless a border color is specified. The circle may be filled with an optional fill color. The syntax of the CIRCLE statement is: CIRCLE window, centerx, centery, radius {, border {, fill}} Example: DEF w as WINDOW PSET statement The PSET statement changes one pixel of the window to the foreground color or the optional specified color. The syntax of PSET is: PSET window, x, y {, color} GETPIXEL function GETPIXEL retrieves the color of a pixel in the window at the coordinates specified. The syntax of GETPIXEL is: color = GETPIXEL( window, x ,y )
Drawing Modes The DRAWMODE statement sets the background mode. The background mode defines whether the system removes existing background colors on the drawing surface before drawing text. The syntax of the DRAWMODE statement is DRAWMODE window, flags Flags can be either @TRANSPARENT or @OPAQUE. If the mode is set to @TRANSPARENT then the background color is not changed when printing text. Raster operations The RASTERMODE statement sets the current drawing mode. The drawing mode specifies how the colors of the pen and the interior of filled objects are combined with the color already on the display surface. The syntax of RASTERMODE is: RASTERMODE window, flags Flags can be any one of the rastermode flags listed in the appendix. Example: DEF w as WINDOW Advanced graphics statements For advanced users Emergence BASIC allows using WIN32 (WINAPI) functions to draw in a window. In order to use any of the WIN32 graphics functions you must first obtain a handle to a device context. While you could use the GetDC/ReleaseDC API functions, it is more convenient and compatible to use the built-in GetHDC and ReleaseHDC functions. The syntax of the GetHDC and ReleaseHDC functions are: handle = GetHDC(window) ReleaseHDC window, handle The handle returned is an unsigned integer value and is a valid HDC. The advantages in using the built in functions is they are integrated with Emergence BASIC's auto drawing windows and will retain the current font, color and drawing mode settings. The @NOAUTODRAW flag To handle WM_PAINT messages directly in your program specify the @NOAUTODRAW flag when creating a window. Your windows handler subroutine will receive @IDPAINT messages whenever the window needs updating. A window created with @NOAUTODRAW uses less memory and will update faster. You must redraw the window every time in response to the @IDPAINT messages. @NOAUTODRAW should also be used if your creating a window where another control covers the entire client area of the window. The editor.eba sample uses this method to embed an edit control into a window. Example code fragment: '... See Also: Images, icons and cursors |