Graphic Primitive Functions
- Details
- Category: Help
- Published on Monday, 31 December 2012 07:35
- Written by Super User
- Hits: 5874
Drawing A line in GLCD
A line is a geometrical figure defined by two points. A line can be drawn on GLCD by specifying a start point and an end point. The function in ProGFX which draws a line is explained below.
void GFXLine(UINT8 x1,UINT8 y1,UINT8 x2,UINT8 y2,UINT8 color);
Arguments
- x1 = start x co-ordinate.
- y1 = start y co-ordinate.
- x2 = end x co-ordinate.
- y2 = end y co-ordinate.
- colour = either GFX_COLOR_BLACK or GFX_COLOR_WHITE
Return Value
- NONE
Example
Draw a line between (16,16) to (100,41) in Black colour
#include <gfx.h>
void main()
{
//Initialize ProGFX Engine
GFXInit();
//Draw a line between (16,16) to (100,41) in Black colour
GFXLine(16,16,100,41,GFX_COLOR_BLACK);
//Update the display
GFXUpdate();
}
![]() |
Line in GLCD |
If the line you want to draw is perfectly horizontal or vertical then you may use the following two functions.
- void GFXHLine(UINT8 x1,UINT8 y1,UINT8 len,UINT8 color);
- void GFXVLine(UINT8 x1,UINT8 y1,UINT8 len,UINT8 color);
These function takes starting point and the length of line. They are much faster than generic GFXLine() function.
Drawing a Rectangle In GLCD
Rectangle can be drawn on the screen by specifying two points and colour.
- Top-left point
- Bottom-right point
The function which draws a rectangle is documented below.
void GFXRect(UINT8 x1,UINT8 y1,UINT8 x2, UINT8 y2,UINT8 color);
Argument:
- x1 = top-left x co-ordinate.
- y1 = top-left y co-ordinate.
- x2 = bottom-right x co-ordinate.
- y2 = bottom-right y co-ordinate.
colour = either GFX_COLOR_BLACK or GFX_COLOR_WHITE
Return Value
- NONE
Example
Draw a rectangle between (16,16) and (100,41) in Black colour
#include <gfx.h>
void main()
{
//Initialize ProGFX Engine
GFXInit();
//Draw a rectangle between (16,16) to (100,41) in Black colour
GFXRect(16,16,100,41,GFX_COLOR_BLACK);
//Update the display
GFXUpdate();
}
![]() |
Rectangle in GLCD |
Drawing a Filled Rectangle in GLCD
In place of above function use the following function. It will draw a filled rectangle.
void GFXFillRect(UINT8 x1,UINT8 y1,UINT8 x2, UINT8 y2,UINT8 color);
Example
Draw a filled rectangle between (16,16) and (100,41) in Black colour
#include <gfx.h>
void main()
{
//Initialize ProGFX Engine
GFXInit();
//Draw a filled rectangle between
//(16,16) to (100,41) in Black colour
GFXFillRect(16,16,100,41,GFX_COLOR_BLACK);
//Update the display
GFXUpdate();
}
![]() |
Filled Rectangle in GLCD |
Drawing a Circle in GLCD
Circle can be drawn on GLCD by specifying the center and the radius. The following function draws a circle in ProGFX.
void GFXCircle(UINT8 cx,UINT8 cy,UINT8 rad,UINT8 color);
Argument:
- cx = x co-ordinate of center.
- cy = y co-ordinate of center.
- rad = radius.
- colour = either GFX_COLOR_BLACK or GFX_COLOR_WHITE
Return Value
- NONE
Example
Draw a circle with center at 64,32 and having a radius of 20 pixels in Black colour.
#include <gfx.h>
void main()
{
//Initialize ProGFX Engine
GFXInit();
//Draw a circle with center at 64,32
//and radius of 20 pixels.
GFXCircle(64,32,20,GFX_COLOR_BLACK);
//Update the display
GFXUpdate();
}
![]() |
Circle in GLCD |
System Functions of ProGFX
void GFXInit();
This function Initialize the ProGFX Graphics Engine. Must be called before using any other graphic functions.
Argument:
NONE
Return Value
NONE
void GFXUpdate();
This function transfers the internal graphic buffer to the LCD Module. After your drawing is complete you must call this to make it visible on screen.
Argument:
NONE
Return Value
NONE
void GFXClear();
This function Clears the screen.
Argument:
NONE
Return Value
NONE