📄 graphic.c
字号:
#include "2440addr.h"
#include "2440lib.h"
#include "myTFT.h"
#include "color.h"
#include "graphic.h"
/*
* draw a dot in the LCD
* x,y : coordinate of the pixel to be lightened
* color : the color of the dot
*/
void draw_dot(int x, int y, int color)
{
unsigned int addr;
addr=LCDFRAMEBUFFER+(x+y*SCR_XSIZE)*2;
*(volatile short *)(addr)=color;
}
/* draw a vertical line */
void draw_vline(int x, int y1, int y2, int color)
{
int i;
unsigned int addr;
if(y2<y1) return;
addr=LCDFRAMEBUFFER+(x+y1*SCR_XSIZE)*2;
for(i=y1; i<y2+1; i++) {
*(volatile short *)(addr)=color;
addr += SCR_XSIZE << 1;
}
}
/* draw a horizontal line */
void draw_hline(int x1, int x2, int y, int color)
{
int i;
unsigned int addr;
if(x2<x1) return;
addr=LCDFRAMEBUFFER+(x1+y*SCR_XSIZE)*2;
for(i=x1; i<x2+1; i++) {
*(volatile short *)(addr)=color;
++addr;
}
}
/*
* (start_x,start_y) : coordinate of the top-left-corner of the rectangle
* (end_x,end_y) : coordinate of the bottom-right-corner of the rectangle
*/
void draw_rectangle(int start_x, int start_y, int end_x, int end_y, int color)
{
draw_vline(start_x, start_y, end_y, color);
draw_vline(end_x, start_x, end_y, color);
draw_hline(start_x, end_x, start_y, color);
draw_hline(start_x, end_x, end_y, color);
}
/*
* (start_x,start_y) : coordinate of the top-left-corner of the rectangle
* (end_x,end_y) : coordinate of the bottom-right-corner of the rectangle
* this rectangle is filled with pixels which color is the same as the frame
*/
void draw_fill_rectangle(int start_x, int start_y, int end_x, int end_y, int color)
{
int i;
for(i=start_y; i<end_y+1; i++) {
draw_hline(start_x, end_x, i, color);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -