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_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); }
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_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_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.); }
void draw_buffer(t_carray *x, t_object *view, t_rect *rect) { int i; float x1, y1; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("buffer_layer"), rect->width, rect->height); if(g) { post("%ld %i", (long)x->f_buffer, x->f_buffer_size); if(x->f_buffer_size && x->f_buffer) { egraphics_set_line_width(g, 2); y1 = (x->f_buffer[0] * 0.5f + 0.5f) * rect->height; egraphics_move_to(g, 0, rect->height - x->f_buffer[0] * rect->height); for(i = 1; i < x->f_buffer_size; i++) { x1 = ((float)i / (float)x->f_buffer_size) * rect->width; y1 = (x->f_buffer[i] * 0.5f + 0.5f) * rect->height; egraphics_line_to(g, x1, y1); post("%f", x->f_buffer[i]); } egraphics_stroke(g); post("array draw"); } ebox_end_layer((t_ebox*)x, gensym("buffer_layer")); } ebox_paint_layer((t_ebox *)x, gensym("buffer_layer"), 0., 0.); }
void egraphics_line_fast(t_elayer *g, float x0, float y0, float x1, float y1) { if(g->e_state == EGRAPHICS_OPEN) { egraphics_move_to(g, x0, y0); egraphics_line_to(g, x1, y1); } egraphics_stroke(g); }
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.); }
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_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 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.); }
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.); }
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 draw_points(t_breakpoints *x, t_object *view, t_rect *rect) { int i; float abs, ord; float max, inc; float abs2; float ratiox, ratioy; float height = sys_fontheight(ebox_getfontsize((t_ebox *)x)) + 2; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("points_layer"), rect->width, rect->height); if (g && x->f_number_of_points) { ratiox = (rect->width - 4.) / (x->f_range_abscissa[1] - x->f_range_abscissa[0]); ratioy = (rect->height - height - 4.) / (x->f_range_ordinate[1] - x->f_range_ordinate[0]); egraphics_set_line_width(g, 2); egraphics_set_color_rgba(g, &x->f_color_line); if(x->f_outline_mode == 0) { abs = (x->f_point_abscissa[0] - x->f_range_abscissa[0]) * ratiox + 2.; ord = rect->height - (x->f_point_ordinate[0] - x->f_range_ordinate[0]) * ratioy - 2.; egraphics_move_to(g, abs, ord); for(i = 0; i < x->f_number_of_points; i++) { abs = (x->f_point_abscissa[i] - x->f_range_abscissa[0]) * ratiox + 2.; ord = rect->height - (x->f_point_ordinate[i] - x->f_range_ordinate[0]) * ratioy - 2.; egraphics_line_to(g, abs, ord); } egraphics_stroke(g); } else if (x->f_outline_mode == 1 || x->f_outline_mode == 2) { abs = (x->f_point_abscissa[0] - x->f_range_abscissa[0]) * ratiox + 2.; ord = rect->height - (x->f_point_ordinate[0] - x->f_range_ordinate[0]) * ratioy - 2.; egraphics_move_to(g, abs, ord); max = (x->f_point_abscissa[x->f_number_of_points-1] - x->f_range_ordinate[0]) * ratiox + 2.; inc = (x->f_point_abscissa[x->f_number_of_points-1] - x->f_point_abscissa[0]) / (float)(max - abs); abs2 = x->f_point_abscissa[0]+inc; if(x->f_point_abscissa[x->f_number_of_points-1] == x->f_point_abscissa[x->f_number_of_points-2]) { for(i = abs; i <= max && abs2 <= x->f_point_abscissa[x->f_number_of_points-1]+inc; i++, abs2 += inc) { ord = rect->height - (breakpoints_interpolation(x, abs2) - x->f_range_ordinate[0]) * ratioy - 2.; egraphics_line_to(g, i, ord); } } else { for(i = abs; i <= max && abs2 <= x->f_point_abscissa[x->f_number_of_points-1]; i++, abs2 += inc) { ord = rect->height - (breakpoints_interpolation(x, abs2) - x->f_range_ordinate[0]) * ratioy - 2.; egraphics_line_to(g, i, ord); } } egraphics_stroke(g); } egraphics_set_color_rgba(g, &x->f_color_point); for(i = 0; i < x->f_number_of_points; i++) { abs = (x->f_point_abscissa[i] - x->f_range_abscissa[0]) * ratiox + 2; ord = rect->height - (x->f_point_ordinate[i] - x->f_range_ordinate[0]) * ratioy - 2; if(i == x->f_point_hover || i == x->f_point_selected) { egraphics_circle(g, abs, ord, 4.); } else egraphics_circle(g, abs, ord, 3.); egraphics_fill(g); } } if(g) { egraphics_set_color_rgba(g, &x->f_color_border); egraphics_set_line_width(g, 2.); egraphics_line_fast(g, -2, height - 1, rect->width+4, height - 1); ebox_end_layer((t_ebox*)x, gensym("points_layer")); } ebox_paint_layer((t_ebox *)x, gensym("points_layer"), 0., 0.); }
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.); }