void draw_background(t_matrixctrl *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_background_layer, rect->width, rect->height); int i, j, incx, incY; int block_width = rect->width / x->f_size.x; int block_height = rect->height / x->f_size.y; if (g) { for(incx = 0, i = 0; i < x->f_size.x; i++, incx += block_width) { for(incY = 0, j = 0; j < x->f_size.y; j++, incY += block_height) { if(x->f_values[j * (long)x->f_size.x + i]) { egraphics_set_color_rgba(g, &x->f_color_on); egraphics_rectangle_rounded(g, incx+1, incY+1, block_width-2, block_height-2, 1); egraphics_fill(g); } egraphics_set_color_rgba(g, &x->f_color_border); egraphics_rectangle_rounded(g, incx+1, incY+1, block_width-2, block_height-2, 1); egraphics_stroke(g); } } ebox_end_layer((t_ebox*)x, cream_sym_background_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_background_layer, 0, 0); }
static void draw_background(t_dsp_tilde *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_background_layer, rect->width, rect->height); if (g) { if(x->f_state) { egraphics_set_color_rgba(g, &x->f_color_logo); } else { egraphics_set_color_rgba(g, &x->f_color_border); } egraphics_circle(g, round(rect->width * 0.5f - 0.5f), round(rect->width * 0.5f - 0.5f), round(rect->width * 0.15f - 0.5f)); egraphics_fill(g); egraphics_set_line_width(g, 2.); egraphics_arc(g, round(rect->width * 0.5f - 0.5f), round(rect->width * 0.5f - 0.5f), round(rect->width * 0.25f - 0.5f), EPD_PI, EPD_2PI); egraphics_stroke(g); egraphics_arc(g, round(rect->width * 0.5f - 0.5f), round(rect->width * 0.5f - 0.5f), round(rect->width * 0.35f - 0.5f), EPD_PI, EPD_2PI); egraphics_stroke(g); ebox_end_layer((t_ebox*)x, cream_sym_background_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_background_layer, 0.f, 0.f); }
void draw_background(t_knob *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height); if (g) { float size = rect->width * 0.5; egraphics_set_color_rgba(g, &x->f_color_border); egraphics_rectangle(g, -1, -1, rect->width+1, rect->height+1); egraphics_fill(g); egraphics_set_color_rgba(g, &x->f_color_background); egraphics_circle(g, rect->width * 0.5, rect->height * 0.5, size * 0.9); egraphics_fill(g); if(!x->f_endless) { float hsize = pd_clip_min(size * 0.15, 2); float alpha = rect->height - hsize; egraphics_set_color_rgba(g, &x->f_color_border); egraphics_move_to(g, rect->width * 0.5, rect->height * 0.5 + hsize); egraphics_line_to(g, rect->height * 0.5 - alpha * 0.5, rect->height); egraphics_line_to(g, rect->height * 0.5 + alpha * 0.5, rect->height); egraphics_fill(g); egraphics_set_color_rgba(g, &x->f_color_background); egraphics_circle(g, rect->width * 0.5, rect->height * 0.5, pd_clip_min(size * 0.3, 3)); egraphics_fill(g); } egraphics_set_color_rgba(g, &x->f_color_needle); egraphics_circle(g, rect->width * 0.5, rect->height * 0.5, pd_clip_min(size * 0.2, 2)); egraphics_fill(g); ebox_end_layer((t_ebox*)x, gensym("background_layer")); } ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.); }
void draw_leds(t_meter *x, t_object *view, t_rect *rect) { float i; float dB; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("leds_layer"), rect->width, rect->height); if (g) { float led_height = rect->height / 13.f; float led_width = rect->width / 13.f; for(i = 12, dB = -39; i > 0; i--, dB += 3.f) { if(x->f_peak_value >= dB) { if(i > 9) egraphics_set_color_rgba(g, &x->f_color_signal_cold); else if(i > 6) egraphics_set_color_rgba(g, &x->f_color_signal_tepid); else if(i > 3) egraphics_set_color_rgba(g, &x->f_color_signal_warm); else if(i > 0) egraphics_set_color_rgba(g, &x->f_color_signal_hot); if(!x->f_direction) { if(i > 11) egraphics_rectangle_rounded(g, 0, i * led_height + 1, rect->width, led_height, 1.f); else egraphics_rectangle_rounded(g, 0, i * led_height + 1, rect->width, led_height - 1, 1.f); } else { if(i > 11) egraphics_rectangle_rounded(g, 0, 0, led_width, rect->height, 1.); else egraphics_rectangle_rounded(g, (12 - i) * led_width + 1, 0, led_width - 1, rect->height, 1.); } egraphics_fill(g); } } if(x->f_over_led_preserved) { egraphics_set_color_rgba(g, &x->f_color_signal_over); if(!x->f_direction) { egraphics_rectangle_rounded(g, 0, 0, rect->width, led_height, 1.f); } else { egraphics_rectangle_rounded(g, 12 * led_width + 1, 0, led_width, rect->height, 1.); } egraphics_fill(g); } ebox_end_layer((t_ebox *)x, gensym("leds_layer")); } ebox_paint_layer((t_ebox *)x, gensym("leds_layer"), 0., 0.); }
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.); }
static void incdec_paint(t_incdec *x, t_object *view) { t_rect rect; ebox_get_rect_for_view((t_ebox *)x, &rect); t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_background_layer, rect.width, rect.height); if (g) { egraphics_set_color_rgba(g, &x->f_color_arrow); if(x->f_mouse_down) { if(x->f_mouse_down == 1) { egraphics_rectangle(g, 0.f, 0.f, rect.width, rect.height * 0.5f); } else { egraphics_rectangle(g, 0.f, rect.height * 0.5f, rect.width, rect.height); } egraphics_fill(g); } if(x->f_mouse_down == 1) { egraphics_set_color_rgba(g, &x->f_color_background); } egraphics_move_to(g, 2.f, rect.height * 0.5f - 3.f); egraphics_line_to(g, rect.width - 2.f, rect.height * 0.5f - 3.f); egraphics_line_to(g, rect.width * 0.5f, 2.f); egraphics_fill(g); if(x->f_mouse_down == -1) { egraphics_set_color_rgba(g, &x->f_color_background); } else { egraphics_set_color_rgba(g, &x->f_color_arrow); } egraphics_move_to(g, 2.f, rect.height * 0.5f + 3.f); egraphics_line_to(g, rect.width - 2.f, rect.height * 0.5f + 3.f); egraphics_line_to(g, rect.width * 0.5f, rect.height - 2.f); egraphics_fill(g); egraphics_set_color_rgba(g, &x->f_color_border); egraphics_set_line_width(g, 2.f); egraphics_line_fast(g, 0., rect.height * 0.5f, rect.width, rect.height * 0.5f); ebox_end_layer((t_ebox*)x, cream_sym_background_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_background_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 draw_background(t_meter *x, t_object *view, t_rect *rect) { int i; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height); if (g) { egraphics_set_color_rgba(g, &x->f_color_border); if(!x->f_direction) { for(i = 1; i < 13; i++) { egraphics_move_to(g, 0., i * rect->height / 13.f); egraphics_line_to(g, rect->width, i * rect->height / 13.f); egraphics_stroke(g); } } else { for(i = 1; i < 13; i++) { egraphics_move_to(g, i * rect->width / 13.f, 0.f); egraphics_line_to(g, i * rect->width / 13.f, rect->height); egraphics_stroke(g); } } ebox_end_layer((t_ebox*)x, gensym("background_layer")); } ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0.f, 0.f); }
static void draw_background(t_tab *x, t_object *view, t_rect *rect) { int i; t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_background_layer, rect->width, rect->height); if(g) { egraphics_set_color_rgba(g, &x->f_color_border); egraphics_set_line_width(g, 2); if(x->f_orientation) { const float ratio = rect->height / (float)x->f_nitems; for(i = 1; i < x->f_nitems; i++) { egraphics_line_fast(g, 0, ratio * i, rect->width, ratio * i); } } else { const float ratio = rect->width / (float)x->f_nitems; for(i = 1; i < x->f_nitems; i++) { egraphics_line_fast(g, ratio * i, 0, ratio * i, rect->height); } } ebox_end_layer((t_ebox*)x, cream_sym_background_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_background_layer, 0., 0.); }
static void draw_signalXY(t_scope *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_signal_layer, rect->width, rect->height); if (g) { float i; float ratioy = -rect->height / pd_clip_min((x->f_range[1] - x->f_range[0]), 0.001); float ratiox = rect->width / pd_clip_min((x->f_range[1] - x->f_range[0]), 0.001); int increment = pd_clip_min((float)x->f_signal_size / (float)x->f_display_size, 1); egraphics_set_color_rgba(g, &x->f_color_signal); egraphics_set_line_width(g, 2); egraphics_move_to(g, (x->f_buffer_x[0] - x->f_range[0]) * ratiox, (x->f_buffer_y[0] - x->f_range[0]) * ratioy + rect->height); for(i = increment; i < x->f_signal_size; i += increment) { egraphics_line_to(g, (x->f_buffer_x[(int)i] - x->f_range[0]) * ratiox, (x->f_buffer_y[(int)i] - x->f_range[0]) * ratioy + rect->height); } egraphics_stroke(g); x->f_index = 0; ebox_end_layer((t_ebox *)x, cream_sym_signal_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_signal_layer, 0., 0.); }
static void plane_paint(t_plane *x, t_object *view) { t_rect rect; ebox_get_rect_for_view((t_ebox *)x, &rect); t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_points_layer, rect.width, rect.height); if(g) { const float size = x->f_size; const char inv1 = ebox_parameter_isinverted((t_ebox *)x, 1); const char inv2 = ebox_parameter_isinverted((t_ebox *)x, 2); const float valx = ebox_parameter_getvalue_normalized((t_ebox *)x, 1); const float valy = ebox_parameter_getvalue_normalized((t_ebox *)x, 2); egraphics_set_color_rgba(g, &x->f_color_point); if(!inv1 && !inv2) egraphics_circle(g, valx * (rect.width - size * 2.f) + size, (1.f - valy) * (rect.height - size * 2.f) + size, size); else if(!inv1 && inv2) egraphics_circle(g, valx * (rect.width - size * 2.f) + size, valy * (rect.height - size * 2.f) + size, size); else if(inv1 && !inv2) egraphics_circle(g, (1.f - valx) * (rect.width - size * 2.f) + size, (1.f - valy) * (rect.height - size * 2.f) + size, size); else egraphics_circle(g, (1.f - valx) * (rect.width - size * 2.f) + size, valy * (rect.height - size * 2.f) + size, size); egraphics_fill(g); ebox_end_layer((t_ebox*)x, cream_sym_points_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_points_layer, 0, 0); }
void draw_knob(t_gain *x, t_object *view, t_rect *rect) { float ratio; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("knob_layer"), rect->width, rect->height); if (g) { float value = (x->f_value + 90.) / 108.; egraphics_set_color_rgba(g, &x->f_color_knob); if(x->f_direction) { ratio = pd_clip_minmax(rect->width * 0.05, 4., 12.); egraphics_set_line_width(g, ratio); egraphics_line_fast(g, value * rect->width, -2, value * rect->width, rect->height+4); } else { ratio = pd_clip_minmax(rect->height * 0.05, 4., 12.); egraphics_set_line_width(g, ratio); egraphics_line_fast(g, -2, (1. - value) * rect->height, rect->width+4, (1. - value) * rect->height); } ebox_end_layer((t_ebox*)x, gensym("knob_layer")); } ebox_paint_layer((t_ebox *)x, gensym("knob_layer"), 0., 0.); }
static void draw_selection(t_tab *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_selection_layer, rect->width, rect->height); if(g) { const int selec = (int)ebox_parameter_getvalue((t_ebox *)x, 1); egraphics_set_line_width(g, 2); if(x->f_orientation) { const float ratio = rect->height / (float)x->f_nitems; if(x->f_item_hover != -1) { egraphics_set_color_rgba(g, &x->f_color_hover); egraphics_rectangle(g, 0, ratio * x->f_item_hover, rect->width, ratio); egraphics_fill(g); } if(x->f_toggle || !x->f_off) { egraphics_set_color_rgba(g, &x->f_color_select); egraphics_rectangle(g, 0, ratio * selec, rect->width, ratio); egraphics_fill(g); } } else { const float ratio = rect->width / (float)x->f_nitems; if(x->f_item_hover != -1) { egraphics_set_color_rgba(g, &x->f_color_hover); egraphics_rectangle(g, ratio * x->f_item_hover, 0, ratio, rect->height); egraphics_fill(g); } if(x->f_toggle || !x->f_off) { egraphics_set_color_rgba(g, &x->f_color_select); egraphics_rectangle(g, ratio * selec, 0, ratio, rect->height); egraphics_fill(g); } } ebox_end_layer((t_ebox*)x, cream_sym_selection_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_selection_layer, 0., 0.); }
void draw_background(t_bang *x, t_object *view, t_rect *rect) { float size; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height); if (g) { size = rect->width * 0.5; if(x->f_active) { egraphics_set_color_rgba(g, &x->f_color_bang); } else { egraphics_set_color_rgba(g, &x->f_color_background); } egraphics_circle(g, floor(size + 0.5), floor(size+ 0.5), size * 0.9); egraphics_fill(g); ebox_end_layer((t_ebox*)x, gensym("background_layer")); } ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.); }
void hoa_space_draw_center(t_hoa_space *x, t_object *view, t_rect *rect) { 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("center_layer"), rect->width, rect->height); if (g) { egraphics_set_line_width(g, 1); egraphics_set_color_rgba(g, &black); egraphics_arc(g, long(x->f_center)-0.5, long(x->f_center)-0.5, x->f_radius_circle, 0., CICM_2PI); egraphics_stroke(g); egraphics_arc(g, long(x->f_center), long(x->f_center), 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, x->f_radius_circle, 0., CICM_2PI); egraphics_fill(g); ebox_end_layer((t_ebox*)x, gensym("center_layer")); } ebox_paint_layer((t_ebox *)x, gensym("center_layer"), 0., 0.); }
static void draw_background(t_knob *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_background_layer, rect->width, rect->height); if (g) { const float size = rect->width * 0.5f; egraphics_set_color_rgba(g, &x->f_color_needle); egraphics_set_line_width(g, x->f_bdsize); egraphics_circle(g, size, size, size - 2.f); egraphics_stroke(g); ebox_end_layer((t_ebox*)x, cream_sym_background_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_background_layer, 0., 0.); }
void draw_background(t_toggle *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height); if (g) { if(x->f_active) { egraphics_set_color_rgba(g, &x->f_color_cross); egraphics_set_line_width(g, 2); egraphics_line_fast(g, 0, 0, rect->width, rect->height); egraphics_line_fast(g, 0, rect->height, rect->width, 0); } ebox_end_layer((t_ebox*)x, gensym("background_layer")); } ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.); }
static void draw_background(t_presetobj *x, t_object *view, t_rect *rect) { int i, xc, yc; char number[256]; t_rgba color; t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_background_layer, rect->width, rect->height); t_etext *jtl = etext_layout_create(); if (g && jtl) { for(xc = x->f_font.size * 1.25, yc = x->f_font.size * 1.25, i = 1; yc + x->f_font.size / 2. < rect->height; ) { if(x->f_binbuf_selected == i-1 && binbuf_getnatom(x->f_binbuf[i-1])){ color = rgba_addContrast(x->f_color_button_selected, 0.1);} else if(!binbuf_getnatom(x->f_binbuf[i-1])) color = rgba_addContrast(x->f_color_button_empty, 0.1); else if(binbuf_getnatom(x->f_binbuf[i-1])) color = rgba_addContrast(x->f_color_button_stored, -0.1); egraphics_set_color_rgba(g, &color); if(x->f_binbuf_hover != i) { egraphics_circle(g, xc, yc, x->f_font.size); egraphics_fill(g); } sprintf(number, "%i", i); etext_layout_set(jtl, number, &x->f_font, xc, yc, rect->width, 0, ETEXT_CENTRED, ETEXT_NOWRAP); etext_layout_settextcolor(jtl, &x->f_color_text); etext_layout_draw(jtl, g); xc += x->f_font.size * 2.5; if(xc + x->f_font.size / 2. > rect->width) { xc = x->f_font.size * 1.25; yc += x->f_font.size * 2.5; } i++; } ebox_end_layer((t_ebox*)x, cream_sym_background_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_background_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.); }
static void draw_background(t_scope *x, t_object *view, t_rect *rect) { int i; t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_background_layer, rect->width, rect->height); if (g) { egraphics_set_color_rgba(g, &x->f_color_border); for(i = 1; i < 4; i++) { egraphics_line_fast(g, -2, rect->height * 0.25 * (float)i, rect->width + 4, rect->height * 0.25 * (float)i); } for(i = 1; i < 6; i++) { egraphics_line_fast(g, rect->width * (1. / 6.) * (float)i, -2, rect->width * (1. / 6.) * (float)i, rect->height + 4); } ebox_end_layer((t_ebox*)x, cream_sym_background_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_background_layer, 0.f, 0.f); }
static void draw_needle(t_knob *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_needle_layer, rect->width, rect->height); if(g) { const float size = rect->width * 0.5f; egraphics_set_color_rgba(g, &x->f_color_needle); egraphics_set_line_width(g, x->f_bdsize); if(ebox_parameter_isinverted((t_ebox *)x, 1)) { const float ratio1 = x->f_endless ? (float)(EPD_2PI) : (float)(EPD_PI + EPD_PI2); const float ratio2 = x->f_endless ? (float)(EPD_PI2) : (float)(EPD_PI2 + EPD_PI4); const float angle = (1.f - ebox_parameter_getvalue_normalized((t_ebox *)x, 1)) * ratio1 + ratio2; egraphics_line(g, pd_abscissa(size - 10.f, angle) + size, pd_ordinate(size - 10.f, angle) + size, pd_abscissa(size - 2.f, angle) + size, pd_ordinate(size - 2.f, angle) + size); } else { const float ratio1 = x->f_endless ? (float)(EPD_2PI) : (float)(EPD_PI + EPD_PI2); const float ratio2 = x->f_endless ? (float)(EPD_PI2) : (float)(EPD_PI2 + EPD_PI4); const float angle = ebox_parameter_getvalue_normalized((t_ebox *)x, 1) * ratio1 + ratio2; egraphics_line(g, pd_abscissa(size - 10.f, angle) + size, pd_ordinate(size - 10.f, angle) + size, pd_abscissa(size - 2.f, angle) + size, pd_ordinate(size - 2.f, angle) + size); } egraphics_stroke(g); ebox_end_layer((t_ebox*)x, cream_sym_needle_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_needle_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 draw_needle(t_knob *x, t_object *view, t_rect *rect) { float size, abs, ord, pimul, pimin; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("needle_layer"), rect->width, rect->height); if (g) { size = rect->width * 0.5; if(x->f_endless) { pimul = EPD_2PI; pimin = EPD_PI2; } else { pimul = 1.5 * EPD_PI; if (x->f_min < x->f_max) pimin = 1.5 * EPD_PI2; else pimin = 0.5 * EPD_PI2; } if(x->f_min < x->f_max) { abs = pd_abscissa(size * 0.9 - 1, (x->f_value - x->f_min) / (x->f_max - x->f_min) * pimul + pimin); ord = pd_ordinate(size * 0.9 - 1, (x->f_value - x->f_min) / (x->f_max - x->f_min) * pimul + pimin); } else { abs = pd_abscissa(size * 0.9 - 1, -(x->f_value - x->f_max) / (x->f_min - x->f_max) * pimul + pimin); ord = pd_ordinate(size * 0.9 - 1, -(x->f_value - x->f_max) / (x->f_min - x->f_max) * pimul + pimin); } egraphics_set_line_width(g, 2); egraphics_set_color_rgba(g, &x->f_color_needle); egraphics_line_fast(g, rect->width * 0.5, rect->height * 0.5, abs + rect->width * 0.5, ord + rect->height * 0.5); ebox_end_layer((t_ebox*)x, gensym("needle_layer")); } ebox_paint_layer((t_ebox *)x, gensym("needle_layer"), 0., 0.); }
void draw_background(t_number_tilde *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_background_layer, rect->width, rect->height); t_etext *jtl = etext_layout_create(); if (g && jtl) { etext_layout_set(jtl, "~", &x->j_box.b_font, 1, rect->height / 2., rect->width, 0, ETEXT_LEFT, ETEXT_JLEFT, ETEXT_NOWRAP); etext_layout_settextcolor(jtl, &x->f_color_text); etext_layout_draw(jtl, g); egraphics_set_line_width(g, 2); egraphics_set_color_rgba(g, &x->f_color_border); egraphics_move_to(g, 0, 0); egraphics_line_to(g, sys_fontwidth(x->j_box.b_font.c_size) + 6, rect->height / 2.); egraphics_line_to(g, 0, rect->height); egraphics_stroke(g); ebox_end_layer((t_ebox*)x, cream_sym_background_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_background_layer, 0., 0.); etext_layout_destroy(jtl); }
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_gain *x, t_object *view, t_rect *rect) { float ratio; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height); if (g) { if(x->f_direction) { ratio = 90. / 108.; egraphics_set_line_width(g, pd_clip_minmax(rect->height * 0.1, 2., 4.)); egraphics_set_color_rgba(g, &x->f_color_border); egraphics_line_fast(g, rect->width * ratio, 0, rect->width * ratio, rect->height); egraphics_set_color_rgba(g, &x->f_color_background); egraphics_line_fast(g, rect->width * ratio, pd_clip_min(rect->height * 0.1, 2), rect->width * ratio, rect->height - pd_clip_min(rect->height * 0.1, 2)); egraphics_set_color_rgba(g, &x->f_color_border); egraphics_line_fast(g, pd_clip_min(rect->height * 0.1, 2), rect->height * 0.5, rect->width-pd_clip_min(rect->height * 0.1, 2), rect->height * 0.5); } else { ratio = 1. - 90. / 108.; egraphics_set_line_width(g, pd_clip_minmax(rect->width * 0.1, 2., 4.)); egraphics_set_color_rgba(g, &x->f_color_border); egraphics_line_fast(g, 0, rect->height * ratio, rect->width, rect->height * ratio); egraphics_set_color_rgba(g, &x->f_color_background); egraphics_line_fast(g, pd_clip_min(rect->width * 0.1, 2), rect->height * ratio, rect->width - pd_clip_min(rect->width * 0.1, 2), rect->height * ratio); egraphics_set_color_rgba(g, &x->f_color_border); egraphics_line_fast(g, rect->width * 0.5, pd_clip_min(rect->width * 0.1, 2), rect->width * 0.5, rect->height -pd_clip_min(rect->width * 0.1, 2)); } ebox_end_layer((t_ebox*)x, gensym("background_layer")); } ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.); }
void draw_background(t_incdec *x, t_object *view, t_rect *rect) { float height; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height); if (g) { // Background // egraphics_set_color_rgba(g, &x->f_color_arrow); if(x->f_mouse_down == 1) egraphics_rectangle(g, 0, 0, rect->width, rect->height / 2.); else if(x->f_mouse_down == -1) egraphics_rectangle(g, 0, rect->height / 2., rect->width, rect->height); egraphics_fill(g); egraphics_set_color_rgba(g, &x->f_color_arrow); // Arrow Up // if(x->f_mouse_down == 1) egraphics_set_color_rgba(g, &x->f_color_background); else egraphics_set_color_rgba(g, &x->f_color_arrow); #ifdef __APPLE__ height = rect->height / 2. - 2; egraphics_move_to(g, rect->width * 0.1, pd_clip_max(height * 0.9, height - 1)); egraphics_line_to(g, rect->width * 0.9, pd_clip_max(height * 0.9, height - 1)); egraphics_line_to(g, rect->width * 0.5, pd_clip_min(height* 0.1, 1)); egraphics_fill(g); #elif _WINDOWS height = rect->height / 2. - 2; egraphics_move_to(g, rect->width * 0.1, pd_clip_max(height * 0.9, height - 1)); egraphics_line_to(g, rect->width * 0.9, pd_clip_max(height * 0.9, height - 1)); egraphics_line_to(g, rect->width * 0.5, pd_clip_min(height* 0.1, 1)); egraphics_fill(g); #else height = rect->height / 2.; egraphics_move_to(g, rect->width * 0.1, pd_clip_max(height * 0.9, height - 2)); egraphics_line_to(g, rect->width * 0.9, pd_clip_max(height * 0.9, height - 2)); egraphics_line_to(g, rect->width * 0.5, pd_clip_min(height* 0.1, 1)); egraphics_fill(g); #endif // Arrow Down // if(x->f_mouse_down == -1) egraphics_set_color_rgba(g, &x->f_color_background); else egraphics_set_color_rgba(g, &x->f_color_arrow); #ifdef __APPLE__ egraphics_move_to(g, rect->width * 0.1, pd_clip_min(height * 0.1 + rect->height / 2. + 2.5, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.9, pd_clip_min(height * 0.1 + rect->height / 2. + 2.5, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.5, pd_clip_max(height * 0.9 + rect->height / 2. + 2.5, rect->height - 1)); egraphics_fill(g); #elif _WINDOWS egraphics_move_to(g, rect->width * 0.1, pd_clip_min(height * 0.1 + rect->height / 2. + 2.5, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.9, pd_clip_min(height * 0.1 + rect->height / 2. + 2.5, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.5, pd_clip_max(height * 0.9 + rect->height / 2. + 2.5, rect->height - 1)); egraphics_fill(g); #else egraphics_move_to(g, rect->width * 0.1, pd_clip_min(height * 0.1 + rect->height / 2. + 1, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.9, pd_clip_min(height * 0.1 + rect->height / 2. + 1, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.5, pd_clip_max(height * 0.9 + rect->height / 2. + 1, rect->height - 1)); egraphics_fill(g); #endif // Middle Line // egraphics_set_color_rgba(g, &x->f_color_border); egraphics_set_line_width(g, 2); egraphics_line_fast(g, 0., rect->height / 2. + 0.5, rect->width, rect->height / 2. + 0.5); ebox_end_layer((t_ebox*)x, gensym("background_layer")); } ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.); }
void draw_leds(t_hoa_meter *x, t_object *view, t_rect *rect) { int i; float j, h, dB; float angle_start, angle, angle_end, radius, center_x, center_y; float led_width = 0.49 * rect->width / 18.; t_rgba black = rgba_addContrast(x->f_color_bg, -0.14); t_elayer *g = ebox_start_layer((t_ebox *)x, hoa_sym_leds_layer, rect->width, rect->height); if (g) { h = led_width * 17.; for(i = 0; i < x->f_meter->getNumberOfChannels(); i++) { if(x->f_clockwise != hoa_sym_clockwise) angle = x->f_meter->getChannelAzimuthMapped(i) + HOA_PI2; else angle = -x->f_meter->getChannelAzimuthMapped(i) + HOA_PI2; center_x = pd_abscissa(x->f_radius - h, angle); center_y = -pd_ordinate(x->f_radius - h, angle); angle_start = angle - x->f_meter->getChannelWidth(i) * 0.5f; angle_end = angle + x->f_meter->getChannelWidth(i) * 0.5f; for(j = 11, dB = -34.5; j > -1; j--, dB += 3.) { radius = (j + 5.) * led_width; if(x->f_meter->getChannelEnergy(i) > dB) { if(j > 8) egraphics_set_color_rgba(g, &x->f_color_cold_signal); else if(j > 5) egraphics_set_color_rgba(g, &x->f_color_tepid_signal); else if(j > 2) egraphics_set_color_rgba(g, &x->f_color_warm_signal); else egraphics_set_color_rgba(g, &x->f_color_hot_signal); egraphics_set_line_width(g, led_width - pd_clip_min(360. / rect->width, 2.)); egraphics_arc(g, center_x + rect->width * 0.5f, center_y + rect->width * 0.5f, radius, angle_start, angle_end); egraphics_stroke(g); } else if(j != -1) { egraphics_set_color_rgba(g, &black); egraphics_set_line_width(g, led_width - pd_clip_min(360. / rect->width, 2.)); egraphics_arc(g, center_x + rect->width * 0.5f, center_y + rect->width * 0.5f, radius, angle_start, angle_end); egraphics_stroke(g); } } if(x->f_over_leds[i]) { radius = (4.) * led_width; egraphics_set_color_rgba(g, &x->f_color_over_signal); egraphics_set_line_width(g, led_width - pd_clip_min(360. / rect->width, 2.)); egraphics_arc(g, center_x + rect->width * 0.5f, center_y + rect->width * 0.5f, radius, angle_start, angle_end); egraphics_stroke(g); } } ebox_end_layer((t_ebox*)x, hoa_sym_leds_layer); } ebox_paint_layer((t_ebox *)x, hoa_sym_leds_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.); }