C Language Development Kit/Functions/DrawLine

From OptiWiki

Jump to: navigation, search
Description This function draws a line on the LCD-display.
Syntax
void drawline(int x1, int y1, int x2, int y2, int mode);
Arguments
int x1, int y1
The pixel coordinates of the start point of the line.
int x2, int y2
The pixel coordinates of the end point of the line.
int mode
Three values are defined for mode:
0 Draws the line by clearing pixels.
1 Draws the line by setting pixels.
2 Draws the line by inverting pixels.
Returns None
Remarks This function uses screen coordinates to position the line. The following table shows the possible screen coordinates.
OPH100x PHL1300 PHL1700 PHL2700 OPL97xx DCL153x
Upper left corner 0,0 0,0 0,0 0,0 0,0 0,0
Bottom right corner 111,127 95,63 95,47 127,63 111,63 111,63
Example
#include "lib.h"
#include <stdio.h>
 
void main( void )
{
    int x, y;
 
    while( 1 )
    {
        printf("\f");
 
        for( x=0; x < 96; x++)
            drawline( x, 0, 50, 24, 1);
 
        for( y=0; y < 48; y++)
            drawline( 96, y, 50, 24, 1);
 
        for( x=96; x >= 0; x--)
            drawline( x, 47, 50, 24, 1);
 
        for( y=47; y >= 0; y--)
            drawline( 0, y, 50, 24, 1);
 
        gotoxy( 3, 2);
        printf("Press key");
        while(!kbhit())
            idle();
        resetkey();
    }
}


Views
Personal tools