void draw_vectors(t_hoa_meter *x, t_object *view, t_rect *rect) { double x1, y1, size; t_matrix transform; t_elayer *g = ebox_start_layer((t_ebox *)x, hoa_sym_vector_layer, rect->width, rect->height); if (g) { egraphics_matrix_init(&transform, 1, 0, 0, -1, rect->width / 2., rect->width / 2.); egraphics_set_matrix(g, &transform); size = 1. / 64. * rect->width; if(x->f_vector_type == hoa_sym_both || x->f_vector_type == hoa_sym_energy) { egraphics_set_color_rgba(g, &x->f_color_energy_vector); if(x->f_clockwise == hoa_sym_anticlock) { x1 = x->f_vector_coords[2] * x->f_radius_center * 0.85; y1 = x->f_vector_coords[3] * x->f_radius_center * 0.85; } else { double rad = radius(x->f_vector_coords[2], x->f_vector_coords[3]) * x->f_radius_center * 0.85; double ang = -azimuth(x->f_vector_coords[2], x->f_vector_coords[3]); x1 = abscissa(rad, ang); y1 = ordinate(rad, ang); } egraphics_arc(g, x1, y1, size, 0., HOA_2PI); egraphics_fill(g); } if(x->f_vector_type == hoa_sym_both || x->f_vector_type == hoa_sym_velocity) { egraphics_set_color_rgba(g, &x->f_color_velocity_vector); if(x->f_clockwise == hoa_sym_anticlock) { x1 = x->f_vector_coords[0] * x->f_radius_center * 0.85; y1 = x->f_vector_coords[1] * x->f_radius_center * 0.85; } else { double rad = radius(x->f_vector_coords[0], x->f_vector_coords[1]) * x->f_radius_center * 0.85; double ang = -azimuth(x->f_vector_coords[0], x->f_vector_coords[1]); x1 = abscissa(rad, ang); y1 = ordinate(rad, ang); } egraphics_arc(g, x1, y1, size, 0., HOA_2PI); egraphics_fill(g); } ebox_end_layer((t_ebox*)x, hoa_sym_vector_layer); } ebox_paint_layer((t_ebox *)x, hoa_sym_vector_layer, 0., 0.); }
void draw_background(t_hoa_scope *x, t_object *view, t_rect *rect) { t_matrix transform; t_rgba black = rgba_addContrast(x->f_color_bg, -contrast_black); t_rgba white = rgba_addContrast(x->f_color_bg, contrast_white); t_elayer *g = ebox_start_layer((t_ebox *)x, hoa_sym_background_layer, rect->width, rect->height); if (g) { egraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); egraphics_set_matrix(g, &transform); double angle, x1, x2, y1, y2, cosa, sina; for(int i = 0; i < (x->f_order * 2 + 2) ; i++) { angle = ((double)(i - 0.5) / (x->f_order * 2 + 2) * HOA_2PI); cosa = cos(angle); sina = sin(angle); x1 = cosa * x->f_radius * 0.2; y1 = sina * x->f_radius * 0.2; x2 = cosa * x->f_radius; y2 = sina * x->f_radius; egraphics_move_to(g, x1, y1); egraphics_line_to(g, x2, y2); egraphics_set_line_width(g, 3); egraphics_set_color_rgba(g, &white); egraphics_stroke(g); egraphics_set_color_rgba(g, &black); egraphics_set_line_width(g, 1); egraphics_stroke(g); } for(int i = 5; i > 0; i--) { egraphics_set_line_width(g, 3); egraphics_set_color_rgba(g, &white); egraphics_arc(g, 0, 0, (double)i * 0.2 * x->f_radius, 0., HOA_2PI); egraphics_stroke(g); egraphics_set_line_width(g, 1); egraphics_set_color_rgba(g, &black); egraphics_stroke(g); } ebox_end_layer((t_ebox*)x, hoa_sym_background_layer); } ebox_paint_layer((t_ebox *)x, hoa_sym_background_layer, 0., 0.); }
void draw_harmonics(t_hoa_scope_3D *x, t_object *view, t_rect *rect) { t_matrix transform; t_elayer *g = ebox_start_layer((t_ebox *)x, hoa_sym_harmonics_layer, rect->width, rect->height); if (g) { double value; egraphics_rotate(g, HOA_PI); egraphics_set_line_width(g, 1); egraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); egraphics_set_matrix(g, &transform); float increment = 2; float ratio = x->f_radius / (x->f_scope->getNumberOfRows() * 0.5); for(int j = x->f_scope->getNumberOfRows() * 0.5; j < x->f_scope->getNumberOfRows(); j++) { for(int i = 0; i < x->f_scope->getNumberOfColumns(); ) { value = x->f_scope->getValue(j, i); if(value > 0) egraphics_set_color_rgba(g, &x->f_color_ph); else egraphics_set_color_rgba(g, &x->f_color_nh); float azym = (double)i / (double)x->f_scope->getNumberOfColumns() * HOA_2PI; float elev = (double)j / (double)x->f_scope->getNumberOfRows() * HOA_PI; float abs = abscissa(x->f_radius, azym, elev); float ord = ordinate(x->f_radius, azym, elev); /* azym = (double)(i + 1) / (double)x->f_scope->getNumberOfColumns() * HOA_2PI; elev = (double)(j + 1) / (double)x->f_scope->getNumberOfRows() * HOA_PI; float abs2 = abscissa(x->f_radius, azym, elev); float ord2 = ordinate(x->f_radius, azym, elev); */ egraphics_circle(g, abs, ord, cos((j - x->f_scope->getNumberOfRows()) / (x->f_scope->getNumberOfRows() * HOA_PI)) * ratio); egraphics_fill(g); i += increment; } /* if(increment < x->f_scope->getNumberOfRows() * 0.5 - 1) increment *= 1.05; */ } ebox_end_layer((t_ebox *)x, hoa_sym_harmonics_layer); } ebox_paint_layer((t_ebox *)x, hoa_sym_harmonics_layer, 0., 0.); }
void hoa_space_draw_harmonics(t_hoa_space *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("harmonics_layer"), rect->width, rect->height); if (g) { t_matrix transform; egraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); egraphics_set_matrix(g, &transform); egraphics_set_line_width(g, 1.); if(x->f_viewer->getBiggestContribution() != 0.) { double max = 0.; double normalize = 1; for(int i = 0 ; i < x->f_number_of_microphones; i++) { if(x->f_microphonesValues[i] > max) max = x->f_microphonesValues[i]; } normalize = max; if(x->f_mode == 1) normalize = x->f_rotation_max; double factor = x->f_radius_global * normalize; egraphics_set_color_rgba(g, &x->f_color_harmonics); egraphics_move_to(g, x->f_viewer->getAbscisseValue(0) * factor, x->f_viewer->getOrdinateValue(0) * factor); for(int i = 0; i < NUMBEROFCIRCLEPOINTS_UI; i += 2) { if(x->f_viewer->getColor(i) == 1) egraphics_line_to(g, x->f_viewer->getAbscisseValue(i) * factor, x->f_viewer->getOrdinateValue(i) * factor); } egraphics_close_path(g); egraphics_fill(g); } ebox_end_layer((t_ebox*)x, gensym("harmonics_layer")); } ebox_paint_layer((t_ebox *)x, gensym("harmonics_layer"), 0., 0.); }
void draw_point(t_plane *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("point_layer"), rect->width, rect->height); if (g) { t_matrix matrix; // Here, an example matrix egraphics_matrix_init(&matrix, x->f_ratio.x, 0.f, 0.f, -x->f_ratio.y, x->f_boundaries.x * -x->f_ratio.x, rect->height + x->f_boundaries.y * x->f_ratio.y); egraphics_set_matrix(g, &matrix); egraphics_set_color_rgba(g, &x->f_color_point); // We use oval to keep a perfect circle with the matrix stranformation egraphics_oval(g, x->f_position.x, x->f_position.y, x->f_size / x->f_ratio.x, x->f_size / x->f_ratio.y); egraphics_set_line_width(g, 2); egraphics_fill(g); ebox_end_layer((t_ebox*)x, gensym("point_layer")); } ebox_paint_layer((t_ebox *)x, gensym("point_layer"), x->f_size + 1, -x->f_size - 1); }
void hoa_space_draw_microphones(t_hoa_space *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("microphones_layer"), rect->width, rect->height); if (g) { t_matrix transform; egraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); egraphics_set_matrix(g, &transform); egraphics_set_color_rgba(g, &x->f_color_points); egraphics_set_line_width(g, 1); double loudspeaker_angle = CICM_2PI / (double)x->f_number_of_microphones; double factor1 = (5 - 1.) * x->f_radius_circle; double factor2 = x->f_radius_circle; for(int i = 0; i < x->f_number_of_microphones; i++) { double angle = loudspeaker_angle * (double)(i) + CICM_PI2; egraphics_arc(g, Tools::abscissa(x->f_microphonesValues[i] * factor1 + factor2, angle), Tools::ordinate(x->f_microphonesValues[i] * factor1 + factor2, angle), 3., 0., EPD_2PI); egraphics_fill(g); } ebox_end_layer((t_ebox*)x, gensym("microphones_layer")); } ebox_paint_layer((t_ebox *)x, gensym("microphones_layer"), 0., 0.); }
void draw_background(t_hoa_meter *x, t_object *view, t_rect *rect) { int i; float coso, sino, angle, x1, y1, x2, y2; t_rgba black, white; t_matrix transform; t_elayer *g = ebox_start_layer((t_ebox *)x, hoa_sym_background_layer, rect->width, rect->height); black = rgba_addContrast(x->f_color_bg, -0.14); white = rgba_addContrast(x->f_color_bg, 0.06); if (g) { egraphics_matrix_init(&transform, 1, 0, 0, -1, rect->width * .5, rect->width * .5); egraphics_set_matrix(g, &transform); egraphics_rotate(g, -HOA_PI2); egraphics_set_line_width(g, 1.); egraphics_set_color_rgba(g, &x->f_color_bg); egraphics_arc(g, 0.f, 0.f, x->f_radius, 0., HOA_2PI); egraphics_fill(g); egraphics_set_color_rgba(g, &x->f_color_bg); egraphics_arc(g, 0.f, 0.f, x->f_radius_center, 0., HOA_2PI); egraphics_fill(g); egraphics_set_color_rgba(g, &white); egraphics_set_line_width(g, 1.f); egraphics_arc(g, 1, 1, x->f_radius, 0., HOA_2PI); egraphics_stroke(g); egraphics_arc(g, 1, 1, x->f_radius_center, 0., HOA_2PI); egraphics_stroke(g); egraphics_set_color_rgba(g, &black); egraphics_set_line_width(g, 1.f); egraphics_arc(g, 0.f, 0.f, x->f_radius, 0., HOA_2PI); egraphics_stroke(g); egraphics_arc(g, 0.f, 0.f, x->f_radius_center, 0., HOA_2PI); egraphics_stroke(g); if(x->f_meter->getNumberOfChannels() != 1) { for(i = 0; i < x->f_meter->getNumberOfChannels(); i++) { angle = x->f_meter->getChannelAzimuthMapped(i) - x->f_meter->getChannelWidth(i) * 0.5f; if(x->f_clockwise == hoa_sym_clockwise) angle = -angle; egraphics_set_line_width(g, 1.f); coso = cosf(angle); sino = sinf(angle); x1 = x->f_radius_center * coso; y1 = x->f_radius_center * sino; x2 = x->f_radius * coso; y2 = x->f_radius * sino; if(isInsideRad(angle, HOA_PI4, HOA_PI + HOA_PI4)) { egraphics_move_to(g, x1 - 0.5, y1 - 0.5); egraphics_line_to(g, x2 - 0.5, y2 - 0.5); } else { egraphics_move_to(g, x1 + 0.5, y1 + 0.5); egraphics_line_to(g, x2 + 0.5, y2 + 0.5); } egraphics_set_color_rgba(g, &white); egraphics_stroke(g); egraphics_move_to(g, x1, y1); egraphics_line_to(g, x2, y2); egraphics_set_color_rgba(g, &black); egraphics_stroke(g); } } ebox_end_layer((t_ebox*)x, hoa_sym_background_layer); } ebox_paint_layer((t_ebox *)x, hoa_sym_background_layer, 0., 0.); }
void egraphics_set_matrix(t_elayer *g, const t_matrix* matrix) { egraphics_matrix_init(&g->e_matrix, matrix->xx, matrix->yx, matrix->xy, matrix->yy, matrix->x0, matrix->y0); }
void draw_harmonics(t_hoa_scope *x, t_object *view, t_rect *rect) { char pathLength; t_matrix transform; t_elayer *g = ebox_start_layer((t_ebox *)x, hoa_sym_harmonics_layer, rect->width, rect->height); if(g) { egraphics_rotate(g, HOA_PI); egraphics_set_line_width(g, 1); egraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); egraphics_set_matrix(g, &transform); // positive harmonics pathLength = 0; egraphics_set_color_rgba(g, &x->f_color_ph); for(int i = 0; i < x->f_scope->getNumberOfPoints(); i++) { if(x->f_scope->getValue(i) >= 0) { if(!pathLength) { egraphics_move_to(g, x->f_scope->getAbscissa(i) * x->f_radius, x->f_scope->getOrdinate(i) * x->f_radius); pathLength++; } else { egraphics_line_to(g, x->f_scope->getAbscissa(i) * x->f_radius, x->f_scope->getOrdinate(i) * x->f_radius); } } } egraphics_close_path(g); if(pathLength) egraphics_stroke(g); // negative harmonics pathLength = 0; egraphics_set_color_rgba(g, &x->f_color_nh); for(int i = 0; i < x->f_scope->getNumberOfPoints(); i++) { if(x->f_scope->getValue(i) < 0) { if(!pathLength) { egraphics_move_to(g, x->f_scope->getAbscissa(i) * x->f_radius, x->f_scope->getOrdinate(i) * x->f_radius); pathLength++; } else { egraphics_line_to(g, x->f_scope->getAbscissa(i) * x->f_radius, x->f_scope->getOrdinate(i) * x->f_radius); } } } egraphics_close_path(g); if(pathLength) egraphics_stroke(g); ebox_end_layer((t_ebox *)x, hoa_sym_harmonics_layer); } ebox_paint_layer((t_ebox *)x, hoa_sym_harmonics_layer, 0., 0.); }
void draw_background(t_hoa_scope_3D *x, t_object *view, t_rect *rect) { int i; double y1, y2, rotateAngle; float radius; t_matrix transform; t_rgba black, white; black = white = x->f_color_bg; black.red = clip_min(black.red - contrast_black, 0.); black.green = clip_min(black.green - contrast_black, 0.); black.blue = clip_min(black.blue - contrast_black, 0.); white.red = clip_max(white.red + contrast_white, 1.); white.green = clip_max(white.green + contrast_white, 1.); white.blue = clip_max(white.blue + contrast_white, 1.); t_elayer *g = ebox_start_layer((t_ebox *)x, hoa_sym_background_layer, rect->width, rect->height); if (g) { egraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); egraphics_set_matrix(g, &transform); for(i = 5; i > 0; i--) { radius = sin((double)i / 5. * HOA_PI2); egraphics_set_line_width(g, 2); egraphics_set_color_rgba(g, &white); egraphics_arc(g, 1, 1, radius * x->f_radius, 0., HOA_2PI); egraphics_stroke(g); egraphics_set_line_width(g, 1); egraphics_set_color_rgba(g, &black); egraphics_arc(g, 0, 0, radius * x->f_radius, 0., HOA_2PI); egraphics_stroke(g); } for(i = 0; i < (x->f_order * 2 + 2) ; i++) { rotateAngle = ((double)i / (x->f_order * 2 + 2) * HOA_2PI ) - (0.5 / (x->f_order * 2 + 2) * HOA_2PI); egraphics_rotate(g, rotateAngle); y1 = 0; y2 = x->f_radius; if(rotateAngle > HOA_PI2 && rotateAngle < HOA_PI + HOA_PI2) { egraphics_move_to(g, -1, long(y1)); egraphics_line_to(g, -1, long(y2)); } else { egraphics_move_to(g, 1, long(y1)); egraphics_line_to(g, 1, long(y2)); } egraphics_set_line_width(g, 1); egraphics_set_color_rgba(g, &white); egraphics_stroke(g); egraphics_move_to(g, 0, y1); egraphics_line_to(g, 0, y2); egraphics_set_color_rgba(g, &black); egraphics_set_line_width(g, 1); egraphics_stroke(g); egraphics_rotate(g, -rotateAngle); } ebox_end_layer((t_ebox*)x, hoa_sym_background_layer); } ebox_paint_layer((t_ebox *)x, hoa_sym_background_layer, 0., 0.); }
void hoa_space_draw_background(t_hoa_space *x, t_object *view, t_rect *rect) { t_matrix transform; t_rgba black, white; black = rgba_addContrast(x->f_color_background, -0.14); white = rgba_addContrast(x->f_color_background, 0.06); t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height); if (g) { egraphics_set_line_width(g, 1); egraphics_set_color_rgba(g, &white); egraphics_arc(g, long(x->f_center)-0.5, long(x->f_center)-0.5, x->f_radius_global, 0., CICM_2PI); egraphics_fill(g); /* Circles */ for(int i = 5; i > 0; i--) { //inner shadow egraphics_set_color_rgba(g, &black); egraphics_arc(g, long(x->f_center)-0.5, long(x->f_center)-0.5, (double)i * x->f_radius_circle, 0., CICM_2PI); egraphics_stroke(g); egraphics_set_color_rgba(g, &x->f_color_background); egraphics_arc(g, long(x->f_center)+0.5, long(x->f_center)+0.5, (double)i * x->f_radius_circle, 0., CICM_2PI); egraphics_stroke(g); } egraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); egraphics_set_matrix(g, &transform); double coso, sino, angle, x1, y1, x2, y2; for(int i = 0; i < x->f_number_of_microphones; i++) { egraphics_set_color_rgba(g, &black); angle = ((double)i / x->f_number_of_microphones * CICM_2PI ) - (0.5 / x->f_number_of_microphones * CICM_2PI); coso = cos(angle); sino = sin(angle); x1 = x->f_radius_circle * coso; y1 = x->f_radius_circle * sino; x2 = x->f_radius_global * coso; y2 = x->f_radius_global * sino; if(!Tools::isInsideDeg(angle / CICM_2PI * 360., 45, 225)) { egraphics_move_to(g, x1 - 0.5, y1 - 0.5); egraphics_line_to(g, x2 - 0.5, y2 - 0.5); } else { egraphics_move_to(g, x1 + 0.5, y1 + 0.5); egraphics_line_to(g, x2 + 0.5, y2 + 0.5); } egraphics_stroke(g); egraphics_set_color_rgba(g, &x->f_color_background); egraphics_move_to(g, x1, y1); egraphics_line_to(g, x2, y2); egraphics_stroke(g); } ebox_end_layer((t_ebox*)x, gensym("background_layer")); } ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.); }