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

📄 box.c

📁 可能有用,是关于c++的是因为要下个软件所以随便传了一个,抱歉了.刚学c++还不会弄什么,以后一定一定传好的东西.
💻 C
字号:
#include "box.h"

static void draw_box(pixel *ptr,int pitch,void *object,int x,int y)
{
	struct box *obj=(struct box*)object;
	int w=obj->width;
	int h=obj->height;
	int i,j;
	pixel *buffer=ptr;
	pixel color=obj->color;
	if (y<0) {
		h+=y;
		y=0;
	}
	else {
		buffer=(pixel*)((char*)buffer+y*pitch);
	}
	if (x<0) {
		w+=x;
		x=0;
	}
	else {
		buffer+=x;
	}
	if (w+x>CANVAS_BLOCK_WIDTH) {
		w=CANVAS_BLOCK_WIDTH-x;
	}
	if (h+y>CANVAS_BLOCK_HEIGHT) {
		h=CANVAS_BLOCK_HEIGHT-y;
	}
	for (i=0;i<h;i++) {
		for (j=0;j<w;j++) {
			buffer[j]=color;
		}
		buffer=(pixel*)((char*)buffer+pitch);
	}
}

void box_draw(struct canvas *c,struct box *b,int x,int y)
{
	canvas_draw(c,draw_box,b,x,y);
}

⌨️ 快捷键说明

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