📄 draw.c
字号:
/*draw.c - drawing objects Copyright (C) 2006 Obada Denis (obadadenis@gmail.com)Project home page : http://tictactoegtk.sourceforge.netThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/#ifndef draw_c#define draw_c//Codevoid drawGrid(void)//Draw Grid{gint i,j;//Draw Backgroundgdk_draw_rectangle(darea->window,darea->style->white_gc,TRUE,0,0,300,300);//Draw Bordergdk_draw_rectangle(darea->window,darea->style->black_gc,FALSE,0,0,300,300);//Draw Vertical linesgdk_draw_line(darea->window,darea->style->black_gc,scaleGrid,0,scaleGrid,scaleGrid*3);gdk_draw_line(darea->window,darea->style->black_gc,scaleGrid*2,0,scaleGrid*2,scaleGrid*3);//Draw orizontal linesgdk_draw_line(darea->window,darea->style->black_gc,0,scaleGrid,scaleGrid*3,scaleGrid);gdk_draw_line(darea->window,darea->style->black_gc,0,scaleGrid*2,scaleGrid*3,scaleGrid*2);//Draw chars (X or O if needed)for(i=0;i<3;i++)for(j=0;j<3;j++) { if (grid[i][j]=='X')//Draw X drawX((scaleGrid/2)+(i*(scaleGrid)),(scaleGrid/2)+(j*(scaleGrid))); if (grid[i][j]=='O')//Draw O drawO((scaleGrid/2)+(i*(scaleGrid)),(scaleGrid/2)+(j*(scaleGrid))); }}void drawX(gint i,gint j)//Draw X{int a;for (a=1;a<=10;a++){gdk_draw_line(darea->window,Xcolor,i-scaleX+a,j-scaleX,i+scaleX-a,j+scaleX);gdk_draw_line(darea->window,Xcolor,i-scaleX-a,j+scaleX,i+scaleX+a,j-scaleX);}}void drawO(gint i,gint j)//Draw O{int a;for(a=1;a<=10;a++){gdk_draw_arc(darea->window,Ocolor,FALSE,i-scaleO+a,j-scaleO-a,scaleO*2,scaleO*2,0, 64 * 360);}}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -