Back to index

Graphics commands:

Double bufferisation (flicking free) support:

Sub StartBufferDraw
Sub EndBufferDraw(x1,y1,x2,y2)

Enables support for flicking free draw

Where x1,y1,x2,y2 determines a rect that should be pushed to screen after draw is complete

Example:

    StartBufferDraw ' From that moment all drawing functions will draw in buffer not on screen
    For i=1 to 10
      DrawLine Rnd(640),Rnd(200),Rnd(640),Rnd(200) ' draws a randomized line on screen
    Next
    EndBufferDraw 0,0,640,20 ' Ends double bufferisation mode and copies specifed rect of buffer to screen 
                             ' in our example it draws 10 lines on screen in one step (not one by one)

    ' All drawing functions outside StartBufferDraw/EndBufferDraw immideately draws to screen

Picture drawing functions:

Function LoadPicture(filename) As Integer

Loads a picture from specified filename and returns a handle to it.

Where filename a filename containing an image in any format (jpg,bmp,gif,png,etc)
Returns handle to loaded picture if picture was properly loaded, if picture is in unknown format or does not exsist function returns -1. Returned handle is used in all picture drawing commands.

Example:

    pic1 = LoadPicture "c:\Test.jpg"       ' Load picture
    pic2 = LoadPicture "c:\TestMask.jpg"   ' Load picture mask (picture as well)
    DrawPictureMasked 100,100, pic1, pic2  ' Draw masked image

Sub UnloadPicture(picture)

Unloads already loaded picture spcified by handle from memory. Unloading pictures is optional as all loaded pictures automatically unloads when application exists althrough it can be very useful when loading lots of pictures, draws them and when no longer need them to unload them to do not waste memory

Where picture is handle to picture

Sub DrawPicture(picture,x,y)
Sub DrawPictureMasked(picture,picture_mask,x,y)

Draws a picture or masked picture at a specified point.

Where picture,picture_mask are handles to picture/picture mask
x,y - The point where the top left pixel of the picture is to be drawn

Sub DrawPicturePart(picture,x,y,x1,y1,x2,y2)

Draws part of picture at specified point.

Where picture is handle to picture
x,y - The point where the top left pixel of the picture is to be drawn
x1,y1,x2,y2 - The rect that determines what picture part should be drawn

Sub DrawPictureAlpha(picture,x,y,opacity)
Sub DrawPictureAlphaMasked(picture,picture_mask,x,y,opacity)

Draws a partially transparent picture or masked picture at a specified point.

Where picture,picture_mask are handles to picture/picture mask
x,y - The point where the top left pixel of the picture is to be drawn
opacity - Opacity level. A value between 0 and 100. 0 means image will be fully transparent, 100 means image won't be tranparent at all, e.g. 50 - semitransparent.

Text drawing functions:

Sub UseFont(Typeface,Height,Bold,Italic)

Sets the font is used for text drawing.

Where Typeface - The typeface of the font (name of the font), e.g. "SwissA"
Height - the height of the typeface (in twips).
Bold - 1 or 0, if 1 the text will be drawn in Bold
Italic - 1 or 0, if 1 the text will be drawn in Italic

Example:

    UseFont "SwissA", 200, 1,0 ' Sets the font to draw text -  SwissA typeface, size 200, bold and not italic
    DrawText 100,100,"Hello world" ' Draw text command uses font params set by UseFont

Sub DrawText(text,x,y)
Sub DrawTextVertical(text,x,y,direction)

Draws text without a surrounding box.
Where text - The text string to draw
x,y - A point specifying the position of the left end of the text.
direction - Direction for DrawTextVertical. 1 for up, 0 for down.

The text baseline is aligned with the y co-ordinate of the specified point, and the left end of the text is aligned with the left end of the text.

Text drawing is done with the pen (SetPenColor), and is subject to the pen colour. The size and style of the text depends on the font used (UseFont).

Sub DrawTextInRect(text,x1,y1,x2,y2,align)
Sub DrawTextVerticalInRect(text,x1,y1,x2,y2,align,direction)

Draws text in rect.
Where text - The text string to draw
x1,y1,x2,y2 - The box to draw the text in.
align - The text align: 1 - left, 2 - right, 3 - center, 4 - justified
direction - Direction for DrawTextVertical. 1 for up, 0 for down.

Text drawing is done with the pen (SetPenColor), and is subject to the pen colour. Text drawing is done with the brush style (SetBrushColor and SetBrushTransparent), and is subject to the brush colour or tranparency if any. The size and style of the text depends on the font used (UseFont). The text is clipped to the box. You must ensure that the specified string is not too large.

Function TextCount(text, width) As Integer

Gets how much of the specified descriptor can be displayed with currently selected font (UseFont) without exceeding the specified width.

Where text - The text string to check
Where expression is a value in radians.
width - The available width for character display.
Returns The number of characters which will be able to be displayed without exceeding the specified width. The count starts from the beginning of the descriptor.

Function TextWidthInPixels(text) As Integer

Gets the width in pixels of the specified descriptor when displayed with currently selected font (UseFont).

Where text - The text string to check
Returns the width of the specified text string when displayed in this font, in pixels.

Other drawing functions:

Sub SetPenColor(colour)

Sets the pen colour. The pen is used to draw lines, the outlines of filled shapes, and text.

Where colour An RGB colour for the pen. See also Rgb function that can contruct a colour value

Sub SetBrushColor(colour)

Sets the brush colour. The brush is used for filling shapes and the background of text boxes.
Use SetBrushTransparent(1) to draw the outline of a fillable shape on its own, without filling.

Where colour An RGB colour for the brush colour. See also Rgb function that can contruct a colour value

Sub SetBrushTransparent(value)

Sets the brush style to be transparent or solid colour.

Where value is 1 or 0. If 1 then brush style is set to transparent, 0 - to solid colour

The brush is used for filling shapes and the background of text boxes.
If style is set to solid colour then all shapes and text boxes are filled with colour set by SetBrushColour.

Sub ClearRect(x1,y1,x2,y2)

Clears a rectangular area of a window. The cleared area is filled with the current brush colour (SetBrushColor).

Where x1,y1,x2,y2 is the rectangle to clear.

Sub DrawRect(x1,y1,x2,y2)

Draws and fills a rectangle. The rectangle's border is drawn with the pen, and it is filled using the brush.

Where x1,y1,x2,y2 is the rectangle to be drawn

Sub DrawRoundRect(x1,y1,x2,y2, dx,dy)

Draws and fills a rectangle with rounded corners. The rectangle's border is drawn with the pen, and it is filled using the brush.

Where x1,y1,x2,y2 is the rectangle to be drawn
dx,dy - the dimensions of each corner.

Sub DrawLine(x1,y1,x2,y2)

Draws a straight line between two points. Line is drawn with the pen.

Where x1,y1 - the point at the start of the line.
x2,y2 - the point at the end of the line.

Sub DrawCircle(x,y,r)

Draws and fills a circle. The circle's border is drawn with the pen, and it is filled using the brush.

Where x,y - the point at the center of circle.
r - radius.

Sub DrawEllipse(x1,y1,x2,y2)

Draws and fills an ellipse. The ellipse's border is drawn with the pen, and it is filled using the brush.

Where x1,y1,x2,y2 - A rectangle in which to draw the ellipse.

Sub DrawArc(x1,y1,x2,y2, sx,sy, ex,ey)

Draws an arc. An arc is a portion of an ellipse. Line drawing is subject to pen colour.

Where x1,y1,x2,y2 - A rectangle in which to draw the ellipse (of which the arc is a segment)
sx,sy - A point to define the start of the arc
ex,ey - A point to define the end of the arc

The point (sx,sy) is used to define one end of a line from the geometric centre of the ellipse. The point of intersection between this line and the ellipse defines the start point of the arc. The point (ex,ey) is used to define one end of a second line from the geometric centre of the ellipse. The point of intersection between this line and the ellipse defines the end point of the arc. The pixels at both the start point and the end point are drawn.

The arc itself is the segment of the ellipse in an anti-clockwise direction from the start point to the end point.

Sub DrawPie(x1,y1,x2,y2, sx,sy, ex,ey)

Draws and fills a pie-shaped slice of an ellipse. Outlines are subject to the current pen colour. The fill is subject to brush style and colour.

Where x1,y1,x2,y2 - A rectangle in which to draw the ellipse bounding the pie slice
sx,sy - A point to define the start of the pie slice
ex,ey - A point to define the end of the pie slice

The point (sx,sy) is used to define one end of a line to the centre of the ellipse. The point of intersection between this line and the ellipse defines the start point of the arc bounding the pie slice. The point (ex,ey) is used to define one end of a second line to the centre of the ellipse. The point of intersection between this line and the ellipse defines the end point of the arc bounding the pie slice. The pixels at the end point are not drawn.

Sub DrawPixel(x,y,colour)

Draws a single point.

Where x,y - The point to be drawn.
colour - colour of pixel.

Function GetPixel(x,y) As Integer

Returns a colour of specified point on screen.

Where x,y - The point to be checked.
Returns: a colour of specified point on screen.

Sub CopyRect(tx,ty, x1,y1,x2,y2)

Temporary doesnt't work!

Copies a rectangle from any part of the screen into other place on screen.

Where tx,ty - The offset from the original position to the point where the rectangle is copied.
x1,y1,x2,y2 - The rectangular area to be copied. This is in window co-ordinates, e.g. the top left corner of the window is position (0,0) with respect to the rectangle.



Copyright (c) 2000-2005 by SymbianWare OHG. All rights reserved.
SymbianWare and SymbianWare logo are trademarks of SymbianWare OHG.