⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpcline.c

📁 使用键盘上的上、下、左、右四个按键
💻 C
字号:
//------------------------------------------------------------------------------
// File:        gpcLine.c
// Date:        2001-6-1 am 11:32:30
// Written by:  CYu
// Decription:  
// Modification record
//------------------------------------------------------------------------------
// Copyright:   EPSON Proprietary Material
//              Copyright (c) 2001, All Rights Reserved
//              SHANGHAI EPSON ELECTRONICS CO., LTD.
//
//              DISTRIBUTION PROHIBITED without written authorization from EPSON
//------------------------------------------------------------------------------
#include <gpc.h>
//--- macro and definition -----------------------------------------------------

//--- static variables ---------------------------------------------------------
//--- external variables -------------------------------------------------------
extern gpcGCValues gpcGC;
//--- shared variables ---------------------------------------------------------
//--- static functions ---------------------------------------------------------
//--- external functions -------------------------------------------------------

//-------------------------------------------------------------------------
//    gpcLines()
//
//  Draw line in the x1, y1, x2, y2 with current color.
//
//  Parameters:
//      x1    - Position X of Start Line.
//      y1    - Position Y of Start Line.
//      x2    - Position X of End Line.
//      y2    - Position Y of End Line.
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
U16 gpcLines( U16 x1, U16 y1, U16 x2, U16 y2 )
{
    U16 i, temp;

    // Horizontal line.
    if (y1 == y2)
    {
        // force line from left to right, keeping endpoint semantics
        if(x1 > x2) {
            temp = x2;
            x2 = x1;
            x1 = temp;
        }

//        bytes = x2 - x1 + 1;  // bytes size  write byte access 
//
        if(gpcGC.GCLineWidth > 1){
//            x1 -= gpcGC.GCLineWidth>>1;
            y1 -= gpcGC.GCLineWidth>>1;
        }

        // check if x1, y1 is less then 0
        // 2000.06.07 by shin :: Update for checking x1, y1 is less then 0
        if(x1 < 1) x1 = 0;
        if(y1 < 1) y1 = 0;

//        pDispAddr = gpcGC.GCDispMem + (y1 * gpcGC.BytesPerScanline) + (x1);

        for( i = 0; i < gpcGC.GCLineWidth; i++) {
//            DrawHLine8(pDispAddr, bytes);
//            pDispAddr += gpcGC.BytesPerScanline;
            seDrawLine( x1, (U16)(y1+i), x2, (U16)(y1+i), gpcGC.GCColorIndex, gpcGC.GCLineStyle );
        }
    // Vertical line 
    } else if (x1 == x2) {
        // make the line go top to bottom of screen, keeping
        // endpoint semantics
        if (y1 > y2) {
            temp = y2;
            y2 = y1;
            y1 = temp;
        }

        if(gpcGC.GCLineWidth > 1){
            x1 -= gpcGC.GCLineWidth>>1;
//            y1 -= gpcGC.GCLineWidth>>1;
        }

        // check if x1, y1 is less then 0
        // 2000.06.07 by shin :: Update for checking x1, y1 is less then 0
        if(x1 < 1) x1 = 0;
        if(y1 < 1) y1 = 0;

        for(i = 0; i < gpcGC.GCLineWidth; i++) {
//            DrawVLine8(x1, y1, y2+gpcGC.GCLineWidth-1) ;
//            x1++;
            seDrawLine( (U16)(x1+i), y1, (U16)(x1+i), y2, gpcGC.GCColorIndex, gpcGC.GCLineStyle );
        }

    // Sloped line 

    } else {
        if( x2 < x1 )
        {
            temp = x1;x1 = x2;x2 = temp;
            temp = y1;y1 = y2;y2 = temp;
        }
        if( gpcGC.GCLineWidth > 1)
            x1 -= gpcGC.GCLineWidth>>1;
        if(x1 < 1) x1 = 0;
        if(y1 < 1) y1 = 0;

        for(i = 0; i < gpcGC.GCLineWidth; i++) {
//            DrawVLine8(x1, y1, y2+gpcGC.GCLineWidth-1) ;
//            x1++;
            seDrawLine( (U16)(x1+i), y1, (U16)(x2+i), y2, gpcGC.GCColorIndex, gpcGC.GCLineStyle );
        }
    }
    return GPC_ERR_OK;

}

//----------------------------- The End of the File ----------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -