Language Reference
Documentation

Language

Objects
Internet Objects

Graphics Class

Has Constructor: NO, Can Create Instance: No
Can Subclass: NO

The graphic object represents the actual image of a picture or other graphical objects. You can only obtain a reference to a graphics object from a picture object or other objects. (Currently only pictures have graphics objects, in future versions the form and others will have a graphics object.) You can use a graphics object to manipulate the image.

See Also: Picture,NewPicture

Methods

DrawLine
Syntax: DrawLine x1 as integer,y1 as integer,x2 as integer,y2 as integer

Draws a line from (x1,y1) to (x2,y2).

DrawRect | FillRect
Syntax: DrawRect x as integer,y as integer,w as integer,h as integer
Syntax: FillRect x as integer,y as integer,w as integer,h as integer

Draws or draw and fills a rectangle.

DrawOval | FillOval
Syntax: DrawOval x as integer,y as integer,w as integer,h as integer
Syntax: FillOval x as integer,y as integer,w as integer,h as integer

Draws or draw and fills a oval (or circle).

DrawRoundRect | FillRoundRect
Syntax: DrawRoundRect x as integer,y as integer,w as integer,h as integer, r as integer
Syntax: FillRoundRect x as integer,y as integer,w as integer,h as integer, r as integer

Draws or draw and fills a rectangle with rounded corners. The corners are arcs with a radius r.

DrawString
Syntax: DrawString s as string, x as integer, y as integer,[wrapat as integer]

Draws the string s at x and y. The optional parameter wrapat indicates the width in pixels at which the text will be wrapped to a new line.

SetPixel
Syntax: SetPixel c as color,x as integer,y as integer

Sets the pixel at x and y to the color represented by c.

GetPixel
Syntax: GetPixel(x as integer,y as integer)

Returns a color object of the pixel at x and y.

DrawPicture
Syntax: DrawPicture SourcePic as picture,x as integer,y as integer,[TargetWidth as integer],[TargetHeight as integer],[SourceX as integer],[SourceY as integer],[SourceWidth as integer],[SourceHeight as integer]

Draws the picture SourcePic at x and y in the current graphic object. You can set the optional parameters "TargetWidth" and the "TargetHeight" to specify the size. You can use these parameters to scale the image. The "SourceX" and "SourceY" can be used to indicate which portion of the SourcePic will be draw. These parameters must be used together with the "SourceHeight" and "SourceWidth".

Properties

Font
Data Type: String

The name of the font used in DrawString.

FontSize
Data Type: Integer

The size of the font used in DrawString.

FontBold
Data Type: integer

If value is 1 text drawn with DrawString will be bold. Default value is 0.

FontUnderline
Data Type: integer

If value is 1 text drawn with DrawString will be underlined. Default value is 0.

FontItalic
Data Type: integer

If value is 1 text drawn with DrawString will be italic. Default value is 0.

ForeColor
Data Type: color

The color of used when drawing. Default value is black.

PenWidth
Data Type: Integer

The width in pixels of the drawing pen. Default value is 1.

PenHeight
Data Type: Integer

The height in pixels of the drawing pen. Default value is 1.

TextAscent
Data Type: Integer

Returns the text ascent for the font specified by the Font property. Use this property to determ the proper y coordinate when using DrawString. This property is readonly.

TextHeight
Data Type: Integer

Returns the height of the text for the font specified by the Font property. Use this property to determ the proper y coordinate when using DrawString. This property is readonly.

Copies
Data Type: Integer

Number of pages to print. Valid when this graphics object represents a print job. Not implemented. This property is readonly.

FirstPage | LastPage
Data Type: Integer

The range of pages to print. Valid when this graphics object represents a print job. Not implemented. This property is readonly.

.

Sample Code

dim f as file,p as picture,g as graphics

//Gets the current folder
f = getfile("myimage.bmp")

p = f.openaspicture()

g = p.graphics