示例#1
0
文件: anim.c 项目: doremi/sdl
void draw_sine()
{
	double i = 0.0;
	const double factor = 30.0;
	const double size = 16.3;
	for (; i < size; i += 1/factor) {
		draw_xy(i * factor, (int)(sin(i) * factor), 255, 0, 0);
	}	
}
示例#2
0
文件: main.c 项目: 20400992/ARM-Codes
int mymain(void)
{	
	char * p = (char *)BMP_ADDR;
	char red, blue, green;
	int color;
	int i, j;
	
	vga_init();

	lcd_init();
	
	lcd_clear_screen(0x000000);	// black	
	
	draw_xy(0, 0, 0xff0000);
	draw_xy(0, 200, 0x00ff00);
	draw_xy(300, 0, 0x0000ff);

	for (i = -320; i < 320; i++)
		for (j = -240; j < 240; j++)
		{
			double x, y;
			int color = 0xff0000;
			
			x = (double)i / (double)150;
			y = (double)j / (double)150;
			
			color = get_fratal(x, y);
			
			draw_xy(i, j, color);
			//printf("i = %d, j = %d, color = %d \n", i, j, color);
		}
		
	while(1);
	

	lcd_draw_hline(100, 100, 640-100, 0xff0000);	// red
	lcd_draw_hline(200, 100, 640-100, 0x00ff00);	// green
	lcd_draw_hline(300, 100, 640-100, 0x0000ff);	// blue
	lcd_draw_hline(400, 100, 640-100, 0xffffff);	// white

	lcd_draw_vline(640/2, 50, 480-50, 0xffffff);	// white
	
	#define POS	50
	#define HALF	20
	lcd_draw_cross(POS, POS, HALF);
	lcd_draw_cross(POS, 640-POS, HALF);
	
	lcd_draw_cross(480-POS, POS, HALF);
	lcd_draw_cross(480-POS, 640-POS, HALF);
	
	//while (1);
	
	// show BMP file
		// read bmp file
	// bmp file header is 54 bytes
	p += 54;
	
	for (i = 0; i < 272; i++)
		for (j = 0; j < 480; j++)
		{
			blue = *p++;
			green = *p++;
			red = *p++;
		
			color = red << 16 | green << 8 | blue << 0;
			
			lcd_draw_pixel(272-i, j, color);
		}
	
	while (1);
	
	return 0;
}