From b6531ca78ad489673a378cc3dcd1c1aa04f24f83 Mon Sep 17 00:00:00 2001 From: sebastid Date: Tue, 15 Aug 2006 19:36:21 +0000 Subject: [PATCH] Formatting SVN revision: 24761 --- src/bin/e_spectrum.c | 203 ++++++++++++++++++++++--------------------- 1 file changed, 103 insertions(+), 100 deletions(-) diff --git a/src/bin/e_spectrum.c b/src/bin/e_spectrum.c index 2cf3a300e..782091887 100644 --- a/src/bin/e_spectrum.c +++ b/src/bin/e_spectrum.c @@ -1,3 +1,6 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ #include "e.h" Evas_Smart *_e_spectrum_smart = NULL; @@ -23,7 +26,7 @@ static void _e_spectrum_smart_add(Evas_Object *o) { E_Spectrum *sp; - sp = calloc(1, sizeof(E_Spectrum)); + sp = E_NEW(E_Spectrum, 1); if (!sp) return; @@ -151,51 +154,51 @@ _e_spectrum_smart_init() Evas_Smart *smart; if ( _e_spectrum_smart ) return; _e_spectrum_smart = evas_smart_new("e_spectrum", - _e_spectrum_smart_add, - _e_spectrum_smart_del, - NULL, NULL, NULL, NULL, NULL, - _e_spectrum_smart_move, - _e_spectrum_smart_resize, - _e_spectrum_smart_show, - _e_spectrum_smart_hide, - _e_spectrum_smart_color_set, - _e_spectrum_smart_clip_set, - _e_spectrum_smart_clip_unset, - NULL); + _e_spectrum_smart_add, + _e_spectrum_smart_del, + NULL, NULL, NULL, NULL, NULL, + _e_spectrum_smart_move, + _e_spectrum_smart_resize, + _e_spectrum_smart_show, + _e_spectrum_smart_hide, + _e_spectrum_smart_color_set, + _e_spectrum_smart_clip_set, + _e_spectrum_smart_clip_unset, + NULL); } void _e_spectrum_color_calc(E_Spectrum *sp, float vx, float vy, float vz, int *r, int *g, int *b) { switch (sp->mode) - { + { case E_COLOR_COMPONENT_R: - *r = 255 * vz; - *g = 255 * vy; - *b = 255 * vx; - break; + *r = 255 * vz; + *g = 255 * vy; + *b = 255 * vx; + break; case E_COLOR_COMPONENT_G: - *r = 255 * vx; - *g = 255 * vz; - *b = 255 * vy; - break; + *r = 255 * vx; + *g = 255 * vz; + *b = 255 * vy; + break; case E_COLOR_COMPONENT_B: - *r = 255 * vy; - *g = 255 * vx; - *b = 255 * vz; - break; + *r = 255 * vy; + *g = 255 * vx; + *b = 255 * vz; + break; case E_COLOR_COMPONENT_H: - evas_color_hsv_to_rgb(vz * 360.0, vy, vx, r, g, b); - break; + evas_color_hsv_to_rgb(vz * 360.0, vy, vx, r, g, b); + break; case E_COLOR_COMPONENT_S: - evas_color_hsv_to_rgb(vx * 360.0, vz, vy, r, g, b); - break; + evas_color_hsv_to_rgb(vx * 360.0, vz, vy, r, g, b); + break; case E_COLOR_COMPONENT_V: - evas_color_hsv_to_rgb(vy * 360.0, vx, vz, r, g, b); - break; + evas_color_hsv_to_rgb(vy * 360.0, vx, vz, r, g, b); + break; default: - break; - } + break; + } } void @@ -207,41 +210,41 @@ _e_spectrum_2d_color_at(E_Spectrum *sp, int x, int y, int *r, int *g, int *b) if (!sp || !sp->cv) return; switch (sp->mode) - { - case E_COLOR_COMPONENT_R: - rr = sp->cv->r; - gg = (1 - (y / (double)(sp->ih))) * 255; - bb = (x / (double)(sp->iw)) * 255; - break; - case E_COLOR_COMPONENT_G: - rr = (x / (double)(sp->iw)) * 255; - gg = sp->cv->g; - bb = (1 - (y / (double)(sp->ih))) * 255; - break; - case E_COLOR_COMPONENT_B: - rr = (1 - (y / (double)(sp->ih))) * 255; - gg = (x / (double)(sp->iw)) * 255; - bb = sp->cv->b; - break; - case E_COLOR_COMPONENT_H: - h = sp->cv->h; - s = 1 - (y / (double)(sp->ih)); - v = x / (double)(sp->iw); - evas_color_hsv_to_rgb(h, s, v, &rr, &gg, &bb); - break; - case E_COLOR_COMPONENT_S: - s = sp->cv->s; - v = 1 - (y / (double)(sp->ih)); - h = x / (double)(sp->iw) * 360; - evas_color_hsv_to_rgb(h, s, v, &rr, &gg, &bb); - break; - case E_COLOR_COMPONENT_V: - v = sp->cv->v; - h = (1 - (y / (double)(sp->ih))) * 360; - s = x / (double)(sp->iw); - evas_color_hsv_to_rgb(h, s, v, &rr, &gg, &bb); - break; - } + { + case E_COLOR_COMPONENT_R: + rr = sp->cv->r; + gg = (1 - (y / (double)(sp->ih))) * 255; + bb = (x / (double)(sp->iw)) * 255; + break; + case E_COLOR_COMPONENT_G: + rr = (x / (double)(sp->iw)) * 255; + gg = sp->cv->g; + bb = (1 - (y / (double)(sp->ih))) * 255; + break; + case E_COLOR_COMPONENT_B: + rr = (1 - (y / (double)(sp->ih))) * 255; + gg = (x / (double)(sp->iw)) * 255; + bb = sp->cv->b; + break; + case E_COLOR_COMPONENT_H: + h = sp->cv->h; + s = 1 - (y / (double)(sp->ih)); + v = x / (double)(sp->iw); + evas_color_hsv_to_rgb(h, s, v, &rr, &gg, &bb); + break; + case E_COLOR_COMPONENT_S: + s = sp->cv->s; + v = 1 - (y / (double)(sp->ih)); + h = x / (double)(sp->iw) * 360; + evas_color_hsv_to_rgb(h, s, v, &rr, &gg, &bb); + break; + case E_COLOR_COMPONENT_V: + v = sp->cv->v; + h = (1 - (y / (double)(sp->ih))) * 360; + s = x / (double)(sp->iw); + evas_color_hsv_to_rgb(h, s, v, &rr, &gg, &bb); + break; + } if (r) *r = rr; if (g) *g = gg; @@ -259,44 +262,44 @@ _e_spectrum_redraw(void *d) data = evas_object_image_data_get(sp->o_spectrum, 1); if (!data) - { - sp->draw_timer = NULL; - return 0; - } + { + sp->draw_timer = NULL; + return 0; + } switch(sp->mode) - { - case E_COLOR_COMPONENT_R: - vz = (float)sp->cv->r / 255; - break; - case E_COLOR_COMPONENT_G: - vz = (float)sp->cv->g / 255; - break; - case E_COLOR_COMPONENT_B: - vz = (float)sp->cv->b / 255; - break; - case E_COLOR_COMPONENT_H: - vz = sp->cv->h / 360; - break; - case E_COLOR_COMPONENT_S: - vz = sp->cv->s; - break; - case E_COLOR_COMPONENT_V: - vz = sp->cv->v; - break; - } + { + case E_COLOR_COMPONENT_R: + vz = (float)sp->cv->r / 255; + break; + case E_COLOR_COMPONENT_G: + vz = (float)sp->cv->g / 255; + break; + case E_COLOR_COMPONENT_B: + vz = (float)sp->cv->b / 255; + break; + case E_COLOR_COMPONENT_H: + vz = sp->cv->h / 360; + break; + case E_COLOR_COMPONENT_S: + vz = sp->cv->s; + break; + case E_COLOR_COMPONENT_V: + vz = sp->cv->v; + break; + } for (i = 0; i < sp->ih; i++) - { - vy = (float)i / sp->ih; - for (j = 0; j < sp->iw; j++) { - vx = (float)j / sp->iw; - //_e_spectrum_2d_color_at(sp, j, i, &r, &g, &b); - _e_spectrum_color_calc(sp, vx, vy, vz, &r, &g, &b); - data[(i * sp->iw) + j] = (sp->cv->a << 24) | (r << 16) | (g << 8) | b; + vy = (float)i / sp->ih; + for (j = 0; j < sp->iw; j++) + { + vx = (float)j / sp->iw; + //_e_spectrum_2d_color_at(sp, j, i, &r, &g, &b); + _e_spectrum_color_calc(sp, vx, vy, vz, &r, &g, &b); + data[(i * sp->iw) + j] = (sp->cv->a << 24) | (r << 16) | (g << 8) | b; + } } - } evas_object_image_data_set(sp->o_spectrum, data); evas_object_image_data_update_add(sp->o_spectrum, 0, 0, sp->iw, sp->ih);