コード例 #1
0
ファイル: canvas.c プロジェクト: nashr/Paint-Rohmen
void canvas_draw_rectangle( int x0, int y0, int x1, int y1, int border_color, int fill_color ) {
	canvas_draw_line( x0, y0, x0, y1, border_color );
	canvas_draw_line( x0, y1, x1, y1, border_color );
	canvas_draw_line( x1, y1, x1, y0, border_color );
	canvas_draw_line( x1, y0, x0, y0, border_color );
	
	if ( fill_color > -1 ) {
		canvas_fill_rectangle( x0, y0, x1, y1, fill_color );
	}

	return;
}
コード例 #2
0
ファイル: display-test.c プロジェクト: EasyRF/contiki
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(display_process, ev, data)
{
  PROCESS_BEGIN();

  INFO("DISPLAY test started");

  display_st7565s.on();
  display_st7565s.set_value(DISPLAY_BACKLIGHT, 1);
  display_st7565s.set_value(DISPLAY_FLIP_X, 1);
  display_st7565s.set_value(DISPLAY_FLIP_Y, 1);

  display_value_t width, height;
  display_st7565s.get_value(DISPLAY_WIDTH, &width);
  display_st7565s.get_value(DISPLAY_HEIGHT, &height);

  /* Open external flash */
  EXTERNAL_FLASH.open();

#if 1
  copy_file_from_romfs_to_cfs("/verdane8_bold.bmp", "verdane8_bold_cfs.bmp");
#endif

  struct canvas_point topleft, bottomright;
  topleft.x = 0; topleft.y = 0;
  bottomright.x = width; bottomright.y = height;

  struct canvas_point topright, bottomleft;
  topright.x = width; topright.y = 0;
  bottomleft.x = 0; bottomleft.y = height;

  canvas_draw_line(&display_st7565s, &topleft, &bottomright, DISPLAY_COLOR_BLACK);
  canvas_draw_line(&display_st7565s, &topright, &bottomleft, DISPLAY_COLOR_BLACK);

  canvas_draw_bmp(&display_st7565s, "/logo_easyrf.bmp", &topleft,
             DISPLAY_COLOR_BLACK, DISPLAY_COLOR_TRANSPARENT);

  struct canvas_rectangle rect;
  rect.left = 0; rect.width = width; rect.top = height / 2 - 2; rect.height = 3;
  canvas_draw_rect(&display_st7565s, &rect, DISPLAY_COLOR_BLACK, DISPLAY_COLOR_BLACK);

  int verdane8_bold = canvas_load_font("verdane8_bold_cfs.bmp");

  struct canvas_textbox textbox;
  canvas_textbox_init(&textbox, width / 2, width / 2, height - 20, canvas_font_height(verdane8_bold) + 4,
                   DISPLAY_COLOR_BLACK, DISPLAY_COLOR_TRANSPARENT, DISPLAY_COLOR_BLACK);

  canvas_textbox_draw_string_reset(&display_st7565s, &textbox, verdane8_bold, "[Hello World!]");

  PROCESS_END();
}
コード例 #3
0
ファイル: canvas.c プロジェクト: nashr/Paint-Rohmen
void canvas_draw_cartesian( int absis_color, int cartesian_color ) {
	int i;

	for ( i = center_y - scale; i > 0 + OFFSET_Y; i -= scale ) {
		canvas_draw_line( 0 + OFFSET_X, i, width + OFFSET_X, i, cartesian_color );
	}
	
	for ( i = center_y + scale; i < height + OFFSET_Y; i += scale ) {
		canvas_draw_line( 0 + OFFSET_X, i, width + OFFSET_X, i, cartesian_color );
	}
	
	for ( i = center_x - scale; i > 0 + OFFSET_X; i -= scale ) {
		canvas_draw_line( i, 0 + OFFSET_Y, i, height + OFFSET_Y, cartesian_color );
	}
	
	for ( i = center_x + scale; i < width + OFFSET_X; i += scale ) {
		canvas_draw_line( i, 0 + OFFSET_Y, i, height + OFFSET_Y, cartesian_color );
	}
	
	canvas_draw_line( 0 + OFFSET_X, center_y, width + OFFSET_X, center_y, absis_color );
	canvas_draw_line( center_x, 0 + OFFSET_Y, center_x, height + OFFSET_Y, absis_color );
	
	return;
}
コード例 #4
0
ファイル: app.c プロジェクト: nashr/Paint-Rohmen
void _app_draw( void ) {
	int i;

	canvas_begin_draw();
	
	// Draw drawings
	drawing_draw();
	
	// Draw cartesian if user wants it
	if ( menu_panels[ 0 ].focus ) {
		canvas_draw_cartesian( CARTESIAN_ABSIS_COLOR, CARTESIAN_COLOR );
	}

	// Draw rotation/shearing center if it's active
	if ( menu_panels[ 2 ].focus ) {
		canvas_draw_rotation_center();
	} else if ( menu_panels[ 3 ].focus ) {
		canvas_draw_shearing_center();
	}

	// Draw menu panels
	for ( i = 0; i < NUM_MENU; i++ ) {
		app_draw_panel( menu_panels[ i ] );
	}
	
	// Draw menu icons
	// 1 - CARTESIAN
	if ( menu_panels[ 0 ].focus ) {
		canvas_draw_line( 20, 16, 44, 16, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 32, 5, 32, 27, MENU_FONT_COLOR_FOCUS );
		canvas_draw_rectangle( 25, 10, 39, 22, MENU_FONT_COLOR_FOCUS, -1 );
	} else {
		canvas_draw_line( 20, 16, 44, 16, MENU_FONT_COLOR );
		canvas_draw_line( 32, 5, 32, 27, MENU_FONT_COLOR );
		canvas_draw_rectangle( 25, 10, 39, 22, MENU_FONT_COLOR, -1 );
	}
	
	// 2 - MOVE
	if ( menu_panels[ 1 ].focus ) {
		canvas_draw_line( 80, 16, 85, 11, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 80, 16, 85, 21, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 85, 16, 107, 16, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 107, 11, 112, 16, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 107, 21, 112, 16, MENU_FONT_COLOR_FOCUS );

		canvas_draw_line( 91, 10, 96, 5, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 96, 5, 101, 10, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 96, 5, 96, 27, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 91, 22, 96, 27, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 96, 27, 101, 22, MENU_FONT_COLOR_FOCUS );
	} else {
		canvas_draw_line( 80, 16, 85, 11, MENU_FONT_COLOR );
		canvas_draw_line( 80, 16, 85, 21, MENU_FONT_COLOR );
		canvas_draw_line( 85, 16, 107, 16, MENU_FONT_COLOR );
		canvas_draw_line( 107, 11, 112, 16, MENU_FONT_COLOR );
		canvas_draw_line( 107, 21, 112, 16, MENU_FONT_COLOR );

		canvas_draw_line( 91, 10, 96, 5, MENU_FONT_COLOR );
		canvas_draw_line( 96, 5, 101, 10, MENU_FONT_COLOR );
		canvas_draw_line( 96, 5, 96, 27, MENU_FONT_COLOR );
		canvas_draw_line( 91, 22, 96, 27, MENU_FONT_COLOR );
		canvas_draw_line( 96, 27, 101, 22, MENU_FONT_COLOR );
	}

	// 3 - ROTATE
	if ( menu_panels[ 2 ].focus ) {
		canvas_draw_ellipse( 160, 16, 10, 10, MENU_FONT_COLOR_FOCUS );
		
		canvas_draw_rectangle( 150, 6, 160, 20, MENU_COLOR_FOCUS, MENU_COLOR_FOCUS );
		
		canvas_draw_line( 160, 6, 165, 1, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 160, 6, 165, 11, MENU_FONT_COLOR_FOCUS );
	} else {
		canvas_draw_ellipse( 160, 16, 10, 10, MENU_FONT_COLOR );

		canvas_draw_rectangle( 150, 6, 160, 20, MENU_COLOR, MENU_COLOR );

		canvas_draw_line( 160, 6, 165, 1, MENU_FONT_COLOR );
		canvas_draw_line( 160, 6, 165, 11, MENU_FONT_COLOR );
	}

	// 4 - SKEW
	if ( menu_panels[ 3 ].focus ) {
		canvas_draw_line( 237, 3, 242, 8, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 220, 8, 242, 8, MENU_FONT_COLOR_FOCUS );

		canvas_draw_line( 220, 12, 207, 27, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 207, 27, 229, 27, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 229, 27, 242, 12, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 242, 12, 220, 12, MENU_FONT_COLOR_FOCUS );
	} else {
		canvas_draw_line( 237, 3, 242, 8, MENU_FONT_COLOR );
		canvas_draw_line( 220, 8, 242, 8, MENU_FONT_COLOR );

		canvas_draw_line( 220, 12, 207, 27, MENU_FONT_COLOR );
		canvas_draw_line( 207, 27, 229, 27, MENU_FONT_COLOR );
		canvas_draw_line( 229, 27, 242, 12, MENU_FONT_COLOR );
		canvas_draw_line( 242, 12, 220, 12, MENU_FONT_COLOR );
	}
	
	// 5 - ZOOM IN
	if ( menu_panels[ 4 ].focus ) {
		canvas_draw_line( 277, 16, 299, 16, MENU_FONT_COLOR_FOCUS );
		canvas_draw_line( 288, 5, 288, 27, MENU_FONT_COLOR_FOCUS );
	} else {
		canvas_draw_line( 277, 16, 299, 16, MENU_FONT_COLOR );
		canvas_draw_line( 288, 5, 288, 27, MENU_FONT_COLOR );
	}

	// 6 - ZOOM OUT
	if ( menu_panels[ 5 ].focus ) {
		canvas_draw_line( 341, 16, 363, 16, MENU_FONT_COLOR_FOCUS );
	} else {
		canvas_draw_line( 341, 16, 363, 16, MENU_FONT_COLOR );
	}

	// 7 - COLOR PALLETE
	for ( i = 0; i < 16; i++ ) {
		if ( i < 8 ) {
			if ( chosen_color == i ) {
				canvas_draw_rectangle( 384 + 32 * i, 1, 384 + 32 * ( i + 1 ), 16, MENU_FONT_COLOR_FOCUS, i );
			} else {
				canvas_draw_rectangle( 384 + 32 * i, 1, 384 + 32 * ( i + 1 ), 16, MENU_FONT_COLOR, i );
			}
		} else {
			if ( chosen_color == i ) {
				canvas_draw_rectangle( 384 + 32 * ( i - 8 ), 16, 384 + 32 * ( i + 1 - 8 ), 31, MENU_FONT_COLOR_FOCUS, i );
			} else {
				canvas_draw_rectangle( 384 + 32 * ( i - 8 ), 16, 384 + 32 * ( i + 1 - 8 ), 31, MENU_FONT_COLOR, i );
			}
		}
		canvas_draw_line( 384, 31, 640, 31, 0 );
	}

	// Draw side panels
	for ( i = 0; i < NUM_SIDE; i++ ) {
		app_draw_panel( side_panels[ i ] );
	}

	// Draw side icons
	// 1 - SELECT
	
	// 2 - LINE
	if ( side_panels[ 1 ].focus ) {
		canvas_draw_line( 10, 150, 54, 106, PANEL_FONT_COLOR_FOCUS );
	} else {
		canvas_draw_line( 10, 150, 54, 106, PANEL_FONT_COLOR );
	}
	
	// 3 - CURVE
	/*if ( side_panels[ 2 ].focus ) {
		int arrayX[4];
		int arrayY[4];
		arrayX[0] = 10;
		arrayX[1] = 24;
		arrayX[2] = 40;
		arrayX[3] = 54;
		arrayY[0] = 192;
		arrayY[1] = 150;
		arrayY[2] = 230;
		arrayY[3] = 192;
		canvas_draw_bezier( arrayX, arrayY, PANEL_FONT_COLOR_FOCUS );
		
	} else {
		int arrayX[4];
		int arrayY[4];
		arrayX[0] = 10;
		arrayX[1] = 24;
		arrayX[2] = 40;
		arrayX[3] = 54;
		arrayY[0] = 192;
		arrayY[1] = 150;
		arrayY[2] = 230;
		arrayY[3] = 192;
		canvas_draw_bezier( arrayX, arrayY, PANEL_FONT_COLOR );
	}*/
	
	// 4 - ELLIPSE
    if ( side_panels[ 3 ].focus ) {
		canvas_draw_ellipse_mouse( 32, 256, 57, 272, PANEL_FONT_COLOR_FOCUS );
		//canvas_draw_ellipse( 32, 256, 25, 16, PANEL_FONT_COLOR_FOCUS );
	} else {
		canvas_draw_ellipse_mouse( 32, 256, 57, 272, PANEL_FONT_COLOR );
		//canvas_draw_ellipse( 32, 256, 25, 16, PANEL_FONT_COLOR );
	}

	// 5 - POLYGON
	if ( side_panels[ 4 ].focus ) {
		canvas_draw_line( 20, 298, 44, 298, PANEL_FONT_COLOR_FOCUS );
		canvas_draw_line( 44, 298, 54, 320, PANEL_FONT_COLOR_FOCUS );
		canvas_draw_line( 54, 320, 44, 342, PANEL_FONT_COLOR_FOCUS );
		canvas_draw_line( 20, 342, 44, 342, PANEL_FONT_COLOR_FOCUS );
		canvas_draw_line( 20, 342, 10, 320, PANEL_FONT_COLOR_FOCUS );
		canvas_draw_line( 10, 320, 20, 298, PANEL_FONT_COLOR_FOCUS );
	} else {
		canvas_draw_line( 44, 298, 54, 320, PANEL_FONT_COLOR );
		canvas_draw_line( 20, 298, 44, 298, PANEL_FONT_COLOR );
		canvas_draw_line( 54, 320, 44, 342, PANEL_FONT_COLOR );
		canvas_draw_line( 20, 342, 44, 342, PANEL_FONT_COLOR );
		canvas_draw_line( 20, 342, 10, 320, PANEL_FONT_COLOR );
		canvas_draw_line( 10, 320, 20, 298, PANEL_FONT_COLOR );
		
	}
	
	// 6 - FILL
	if ( side_panels[ 5 ].focus ) {
		canvas_draw_line( 20, 372, 44, 367, PANEL_FONT_COLOR_FOCUS );
		canvas_draw_line( 20, 382, 44, 377, PANEL_FONT_COLOR_FOCUS );
		canvas_draw_line( 20, 392, 44, 387, PANEL_FONT_COLOR_FOCUS );
		canvas_draw_line( 20, 402, 44, 397, PANEL_FONT_COLOR_FOCUS );
		canvas_draw_line( 20, 372, 20, 402, PANEL_FONT_COLOR_FOCUS );
		canvas_draw_line( 44, 367, 44, 397, PANEL_FONT_COLOR_FOCUS );
		//canvas_fill( 30, 393, BLUE, BLACK );
	} else {
		canvas_draw_line( 20, 372, 44, 367, PANEL_FONT_COLOR );
		canvas_draw_line( 20, 382, 44, 377, PANEL_FONT_COLOR );
		canvas_draw_line( 20, 392, 44, 387, PANEL_FONT_COLOR );
		canvas_draw_line( 20, 402, 44, 397, PANEL_FONT_COLOR );
		canvas_draw_line( 20, 372, 20, 402, PANEL_FONT_COLOR );
		canvas_draw_line( 44, 367, 44, 397, PANEL_FONT_COLOR );
		//canvas_fill( 30, 393, BLUE, BLACK );
	}
	
	
	// 7 - CROP
	
	canvas_end_draw();

	return;
}
コード例 #5
0
ファイル: canvas.c プロジェクト: nashr/Paint-Rohmen
void canvas_draw_shearing_center( void ) {
	canvas_draw_line( sx - 5, sy - 5, sx + 5, sy + 5, 13 );
	canvas_draw_line( sx - 5, sy + 5, sx + 5, sy - 5, 13 );

	return;
}