Changeset 2821 for libcaca/trunk/examples/gamma.c
- Timestamp:
- Sep 27, 2008, 3:12:46 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/examples/gamma.c
r2299 r2821 1 1 /* 2 * gamma libc uculgamma test program2 * gamma libcaca gamma test program 3 3 * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> 4 4 * All Rights Reserved … … 20 20 #endif 21 21 22 #include "cucul.h"23 22 #include "caca.h" 24 23 … … 28 27 { 29 28 caca_event_t ev; 30 c ucul_canvas_t *cv, *cw, *mask;29 caca_canvas_t *cv, *cw, *mask; 31 30 caca_display_t *dp; 32 c ucul_dither_t *left, *right;31 caca_dither_t *left, *right; 33 32 float gam; 34 33 int x; 35 34 36 cv = c ucul_create_canvas(0, 0);35 cv = caca_create_canvas(0, 0); 37 36 if(cv == NULL) 38 37 { … … 47 46 } 48 47 49 cw = c ucul_create_canvas(cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));50 mask = c ucul_create_canvas(cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));48 cw = caca_create_canvas(caca_get_canvas_width(cv), caca_get_canvas_height(cv)); 49 mask = caca_create_canvas(caca_get_canvas_width(cv), caca_get_canvas_height(cv)); 51 50 52 51 for(x = 0; x < 256; x++) … … 58 57 } 59 58 60 left = c ucul_create_dither(32, 256, 4, 4 * 256,59 left = caca_create_dither(32, 256, 4, 4 * 256, 61 60 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0); 62 right = c ucul_create_dither(32, 256, 4, 4 * 256,61 right = caca_create_dither(32, 256, 4, 4 * 256, 63 62 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0); 64 gam = c ucul_get_dither_gamma(right);63 gam = caca_get_dither_gamma(right); 65 64 caca_set_display_time(dp, 20000); 66 65 … … 82 81 83 82 /* Resize the spare canvas, just in case the main one changed */ 84 c ucul_set_canvas_size(cw, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));85 c ucul_set_canvas_size(mask, cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));83 caca_set_canvas_size(cw, caca_get_canvas_width(cv), caca_get_canvas_height(cv)); 84 caca_set_canvas_size(mask, caca_get_canvas_width(cv), caca_get_canvas_height(cv)); 86 85 87 86 /* Draw the regular dither on the main canvas */ 88 c ucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv),89 c ucul_get_canvas_height(cv), left, buffer);87 caca_dither_bitmap(cv, 0, 0, caca_get_canvas_width(cv), 88 caca_get_canvas_height(cv), left, buffer); 90 89 91 90 /* Draw the gamma-modified dither on the spare canvas */ 92 c ucul_set_dither_gamma(right, gam);93 c ucul_dither_bitmap(cw, 0, 0, cucul_get_canvas_width(cw),94 c ucul_get_canvas_height(cw), right, buffer);91 caca_set_dither_gamma(right, gam); 92 caca_dither_bitmap(cw, 0, 0, caca_get_canvas_width(cw), 93 caca_get_canvas_height(cw), right, buffer); 95 94 96 95 /* Draw something on the mask */ 97 c ucul_set_color_ansi(mask, CUCUL_LIGHTGRAY, CUCUL_BLACK);98 c ucul_clear_canvas(mask);99 c ucul_set_color_ansi(mask, CUCUL_WHITE, CUCUL_WHITE);100 c ucul_fill_ellipse(mask, (1.0 + sin(0.05 * (float)x))101 * 0.5 * c ucul_get_canvas_width(mask),96 caca_set_color_ansi(mask, CACA_LIGHTGRAY, CACA_BLACK); 97 caca_clear_canvas(mask); 98 caca_set_color_ansi(mask, CACA_WHITE, CACA_WHITE); 99 caca_fill_ellipse(mask, (1.0 + sin(0.05 * (float)x)) 100 * 0.5 * caca_get_canvas_width(mask), 102 101 (1.0 + cos(0.05 * (float)x)) 103 * 0.5 * c ucul_get_canvas_height(mask),104 c ucul_get_canvas_width(mask) / 2,105 c ucul_get_canvas_height(mask) / 2, '#');102 * 0.5 * caca_get_canvas_height(mask), 103 caca_get_canvas_width(mask) / 2, 104 caca_get_canvas_height(mask) / 2, '#'); 106 105 107 106 /* Blit the spare canvas onto the first one */ 108 c ucul_blit(cv, 0, 0, cw, mask);107 caca_blit(cv, 0, 0, cw, mask); 109 108 110 c ucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);111 c ucul_printf(cv, 2, 1,109 caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE); 110 caca_printf(cv, 2, 1, 112 111 "gamma=%g - use arrows to change, Esc to quit", gam); 113 112 … … 115 114 } 116 115 117 c ucul_free_dither(left);118 c ucul_free_dither(right);116 caca_free_dither(left); 117 caca_free_dither(right); 119 118 120 119 caca_free_display(dp); 121 c ucul_free_canvas(mask);122 c ucul_free_canvas(cw);123 c ucul_free_canvas(cv);120 caca_free_canvas(mask); 121 caca_free_canvas(cw); 122 caca_free_canvas(cv); 124 123 125 124 return 0;
Note: See TracChangeset
for help on using the changeset viewer.