SDL作图
来源:互联网 发布:淘宝甩手掌柜工具箱 编辑:程序博客网 时间:2024/05/02 02:46
SDL
题1:要求用SDL编程进行绘图,如下图所示,该图形由坐标系、一个矩形和两个椭圆构成,其屏幕的背景色为白色。 SDL_Surface*s; int r; intret=SDL_Init(SDL_INIT_VIDEO); if(ret<0){printf("init error!\r\n");exit(-1);}; s=SDL_SetVideoMode(640,480,16,SDL_SWSURFACE); if(s==NULL){printf("setvideomodeerror!\r\n");exit(-1);}; atexit(SDL_Quit);
SDL_FillRect(s,NULL,SDL_MapRGB(s->format,255,255,255));//背景色 Draw_HLine(s,200,240,440,SDL_MapRGB(s->format,0,0,0)); Draw_VLine(s,320,180,300,SDL_MapRGB(s->format,255,0,0)); Draw_Ellipse(s,240,180,76,56,SDL_MapRGB(s->format,0,0,255)); Draw_FillEllipse(s,400,300,76,56,SDL_MapRGB(s->format,0,0,255)); Draw_FillRect(s,200,250,100,80,SDL_MapRGB(s->format,255,255,0)); SDL_UpdateRect(s,0,0,0,0); SDL_Delay(5000); return0; //gcc drawline.c -o drawline -I/usr/include/SDL -lSDL-lSDL_draw SDL_Surface*i; SDL_Rectdest; i=SDL_LoadBMP(pn); if(i==NULL){printf("load BMP error!\r\n");exit(-1);}; dest.x=x; dest.y=y; dest.w=i->w; dest.h=i->h; SDL_BlitSurface(i,NULL,s,&dest); SDL_UpdateRects(s,1,&dest); SDL_Surface*s; intr; intret=SDL_Init(SDL_INIT_VIDEO); if(ret<0){printf("init error!\r\n");exit(-1);}; s=SDL_SetVideoMode(640,480,16,SDL_SWSURFACE); if(s==NULL){printf("setvideomodeerror!\r\n");exit(-1);}; atexit(SDL_Quit); intx,y,i,j; SDL_FillRect(s,NULL,SDL_MapRGB(s->format,0,255,0)); SDL_UpdateRect(s,0,0,0,0);
for(i=0;i<5;i++) for(j=0;j<5;j++) { x=i*48; y=j*32; if(i==j) ShowBMP("black.bmp",s,x,y); elseShowBMP("white.bmp",s,x,y); } SDL_Delay(5000); return0;
#include
#include
#include
#include
#include
int main()
{
}
题2:要求完成阶梯状图形,效果如下图所示:
#include
#include
#include
#include
#include
void ShowBMP(char*pn,SDL_Surface *s,int x,int y)
{
}
int main()
{
//ShowBMP("white.bmp",s,0,0);
}
0 0
- SDL作图
- 作图
- SDL
- SDL
- SDL
- SDL
- SDL
- sdl
- SDL
- SDL
- SDL
- SDL
- sdl
- SDL
- 基本作图
- 汇编语言作图
- MATLAB作图
- Gnuplot 作图
- shell中数组的定义、初始化、引用、赋值
- 为AspxGridView绑定数据
- PCA 学习
- 黑马程序员————学习笔记(第四天)
- 关于链表的几个术语的解释
- SDL作图
- 代码注释
- Android简单的绘制 矩形 圆形 弧形 和直线
- 移动支付NFC-SWP方案在SIM卡中的实现方法
- jasper(ireport)报表pdf乱码问题
- 设计模式与面向对象学习--decorator模式
- ASP.NET MVC4 系列教程之第二篇 (MVC4基础)
- TOJ 3896 Above the Median -- 分治 树状数组
- 二维码点子名片格式