static void redraw(GP_Backend *backend) { GP_Context *context = backend->context; /* Now draw some testing patters */ black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context); red_pixel = GP_RGBToContextPixel(0xff, 0x00, 0x00, context); blue_pixel = GP_RGBToContextPixel(0x00, 0x00, 0xff, context); green_pixel = GP_RGBToContextPixel(0x00, 0xff, 0x00, context); GP_Fill(context, white_pixel); unsigned int i, j; for (i = 0; i < 40; i++) { GP_HLineXYW(context, 0, i, i, black_pixel); GP_HLineXYW(context, 1, i + 40, i, black_pixel); GP_HLineXYW(context, 2, i + 80, i, black_pixel); GP_HLineXYW(context, 3, i + 120, i, black_pixel); GP_HLineXYW(context, 4, i + 160, i, black_pixel); GP_HLineXYW(context, 5, i + 200, i, black_pixel); GP_HLineXYW(context, 6, i + 240, i, black_pixel); GP_HLineXYW(context, 7, i + 280, i, black_pixel); } for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { uint8_t val = 1.00 * sqrt(i*i + j*j)/sqrt(2) + 0.5; GP_Pixel pix = GP_RGBToContextPixel(i, j, val, context); GP_PutPixel(context, i + 60, j + 10, pix); } } GP_Text(context, NULL, 60, 270, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, black_pixel, white_pixel, "Lorem Ipsum dolor sit..."); GP_Text(context, NULL, 60, 290, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, red_pixel, white_pixel, "Lorem Ipsum dolor sit..."); GP_Text(context, NULL, 60, 310, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, green_pixel, white_pixel, "Lorem Ipsum dolor sit..."); GP_Text(context, NULL, 60, 330, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, blue_pixel, white_pixel, "Lorem Ipsum dolor sit..."); /* Update the backend screen */ GP_BackendFlip(backend); }
void redraw_screen(void) { GP_Fill(win->context, black_pixel); /* draw axes intersecting in the middle, where text should be shown */ GP_HLine(win->context, 0, X, Y/2, darkgray_pixel); GP_VLine(win->context, X/2, 0, Y, darkgray_pixel); switch (font_flag) { case 0: style.font = &GP_DefaultProportionalFont; break; case 1: style.font = &GP_DefaultConsoleFont; break; case 2: style.font = GP_FontTinyMono; break; case 3: style.font = GP_FontTiny; break; case 4: style.font = GP_FontC64; break; case 5: style.font = font; break; } GP_Text(win->context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_BELOW, yellow_pixel, black_pixel, "bottom left"); GP_Text(win->context, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, red_pixel, black_pixel, "bottom right"); GP_Text(win->context, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_ABOVE, blue_pixel, black_pixel, "top right"); GP_Text(win->context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_ABOVE, green_pixel, black_pixel, "top left"); GP_HLine(win->context, 0, X, Y/3, darkgray_pixel); GP_Text(win->context, &style, X/2, Y/3, GP_ALIGN_CENTER|GP_VALIGN_BASELINE, white_pixel, black_pixel, "x center y baseline"); }
void redraw_screen(void) { SDL_LockSurface(display); GP_Fill(&context, black_pixel); GP_Text(&context, NULL, W/2, 20, GP_ALIGN_CENTER | GP_VALIGN_BELOW, darkgray_pixel, black_pixel, "GFXprim SDL Demo"); GP_Line(&context, 0, 0, W-1, H-1, darkgray_pixel); GP_Line(&context, 0, H-1, W-1, 0, darkgray_pixel); SDL_UnlockSurface(display); }
void redraw_screen(void) { GP_Fill(win, gray_pixel); GP_TextStyle style = GP_DEFAULT_TEXT_STYLE; switch (font_flag) { case 0: style.font = &GP_DefaultConsoleFont; break; case 1: style.font = &GP_DefaultProportionalFont; break; case 2: style.font = GP_FontTinyMono; break; case 3: style.font = GP_FontTiny; break; case 4: style.font = GP_FontC64; break; case 5: style.font = font; break; } style.pixel_xmul = mul; style.pixel_ymul = mul; style.pixel_xspace = space; style.pixel_yspace = space; style.char_xspace = tracking; /* Text alignment (we are always drawing to the right * and below the starting point). */ int align = GP_ALIGN_RIGHT|GP_VALIGN_BELOW; struct FileLine *line = first_line; unsigned int i; for (i = 0; i < win->h/GP_TextHeight(&style); i++) { if (line == NULL) break; GP_Text(win, &style, 16, 16 + (1.0 * GP_TextHeight(&style))*i, align, black_pixel, gray_pixel, line->text); line = line->next; } }
void redraw_screen(void) { GP_Fill(win->context, black_pixel); GP_TextStyle style = GP_DEFAULT_TEXT_STYLE; switch (font_flag) { case 0: style.font = &GP_DefaultProportionalFont; break; case 1: style.font = &GP_DefaultConsoleFont; break; case 2: style.font = GP_FontTiny; break; case 3: style.font = GP_FontTinyMono; break; case 4: style.font = font; break; } print_font_properties(style.font); /* Text alignment (we are always drawing to the right * and below the starting point). */ int align = GP_ALIGN_RIGHT|GP_VALIGN_BELOW; const size_t TEST_STRING_COUNT = sizeof(test_strings)/sizeof(const char *); size_t i; for (i = 0; i < TEST_STRING_COUNT; i++) { const char *test_string = test_strings[i]; style.pixel_xmul = 1; style.pixel_ymul = 1; style.pixel_xspace = 0; style.pixel_yspace = 0; style.char_xspace = tracking; GP_FillRectXYWH(win->context, 16, SPACING*i + 16, GP_TextWidth(&style, test_string), GP_FontHeight(style.font), dark_gray_pixel); GP_RectXYWH(win->context, 15, SPACING*i + 15, GP_TextMaxWidth(&style, strlen(test_string)) + 1, GP_FontHeight(style.font) + 1, blue_pixel); GP_Text(win->context, &style, 16, SPACING*i + 16, align, white_pixel, dark_gray_pixel, test_string); style.pixel_xmul = 2; style.pixel_ymul = 2; style.pixel_yspace = 1; GP_Text(win->context, &style, 34, SPACING * i + 44, align, white_pixel, black_pixel, test_string); GP_RectXYWH(win->context, 33, SPACING * i + 43, GP_TextWidth(&style, test_string) + 1, GP_TextHeight(&style) + 1, dark_gray_pixel); style.pixel_xmul = 4; style.pixel_ymul = 2; style.pixel_xspace = 1; style.pixel_yspace = 1; if (font_flag == 2 || font_flag == 3) { style.pixel_xmul = 2; style.pixel_ymul = 5; style.pixel_xspace = 2; style.pixel_yspace = 2; } GP_Text(win->context, &style, 64, SPACING*i + 88, align, dark_gray_pixel, black_pixel, test_string); } }