void draw_contribution(t_scope *x, t_object *view, t_rect *rect) { double x1, y1, biggestcontrib; t_jfont *jf; t_jtextlayout *jtl; char text[64]; t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("contrib_layer"), rect->width, rect->height); if (g) { x1 = x->f_center.x; y1 = x->f_center.y - 2 * x->f_fontsize; jf = jfont_create(jbox_get_fontname((t_object *)x)->s_name, JGRAPHICS_FONT_SLANT_NORMAL, JGRAPHICS_FONT_WEIGHT_NORMAL, x->f_fontsize * 0.75); jtl = jtextlayout_create(); jtextlayout_settextcolor(jtl, &x->f_colorText); biggestcontrib = (x->f_viewer->getBiggestContribution() + 0.5 * x->f_harmonicsValues[0]) / ((double)(x->f_order + 1) * 4.); for(int i = 1; i < 5; i++) { sprintf(text,"%.2f", (float)(i * biggestcontrib)); jtextlayout_set(jtl, text, jf, x1 - x->f_fontsize * 2, y1 - i * x->f_rayonCircle, x->f_fontsize * 4, x->f_fontsize, JGRAPHICS_TEXT_JUSTIFICATION_CENTERED, JGRAPHICS_TEXTLAYOUT_NOWRAP); jtextlayout_draw(jtl, g); } jbox_end_layer((t_object*)x, view, gensym("contrib_layer")); jtextlayout_destroy(jtl); jfont_destroy(jf); } jbox_paint_layer((t_object *)x, view, gensym("contrib_layer"), 0., 0.); }
void draw_angles(t_scope *x, t_object *view, t_rect *rect) { int i; double x1, y1; t_jfont *jf; t_jtextlayout *jtl; char text[16]; t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("angle_layer"), rect->width, rect->height); if (g) { jf = jfont_create(jbox_get_fontname((t_object *)x)->s_name, JGRAPHICS_FONT_SLANT_NORMAL, JGRAPHICS_FONT_WEIGHT_NORMAL, x->f_fontsize); jtl = jtextlayout_create(); jtextlayout_settextcolor(jtl, &x->f_colorText); for(i = 0; i < (x->f_order*2+2); i++) { x1 = x->f_rayonAngle * cos((double)-i * CICM_2PI / (x->f_order*2+2) - CICM_PI / 2.) + x->f_center.x; y1 = x->f_rayonAngle * sin((double)-i * CICM_2PI / (x->f_order*2+2) - CICM_PI / 2.) + x->f_center.y; sprintf(text,"%ld°", long( (360*i) / (x->f_order*2+2) ) ); jtextlayout_set(jtl, text, jf, x1 - x->f_fontsize * 1.5, y1 - 10, x->f_fontsize * 3., 20, JGRAPHICS_TEXT_JUSTIFICATION_CENTERED, JGRAPHICS_TEXTLAYOUT_NOWRAP); jtextlayout_draw(jtl, g); } jtextlayout_destroy(jtl); jfont_destroy(jf); jbox_end_layer((t_object*)x, view, gensym("angle_layer")); } jbox_paint_layer((t_object *)x, view, gensym("angle_layer"), 0., 0.); }
void draw_microphones_points(t_space *x, t_object *view, t_rect *rect) { t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("microphones_points_layer"), rect->width, rect->height); if (g) { t_jmatrix transform; jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center.x, x->f_center.y); jgraphics_set_matrix(g, &transform); jgraphics_set_source_jrgba(g, &x->f_color_points); double loudspeaker_angle = CICM_2PI / (double)x->f_number_of_microphones; double factor1 = 4. * x->f_rayonCircle; double factor2 = x->f_rayonCircle; for(int i = 0; i < x->f_number_of_microphones; i++) { jgraphics_set_source_jrgba(g, &x->f_color_points); double angle = loudspeaker_angle * (double)(i) + CICM_PI2; jgraphics_arc(g, Tools::abscisse(x->f_microphonesValues[i] * factor1 + factor2, angle), Tools::ordinate(x->f_microphonesValues[i] * factor1 + factor2, angle), 3., 0., JGRAPHICS_2PI); jgraphics_fill(g); } jbox_end_layer((t_object*)x, view, gensym("microphones_points_layer")); } jbox_paint_layer((t_object *)x, view, gensym("microphones_points_layer"), 0., 0.); }
void tralala_paintCurrentZone(t_tll *x, t_object *pv, long argc, t_atom *argv, long status) { double w = (PIZ_SEQUENCE_SIZE_TIMELINE * TLL_PIXELS_PER_STEP); double h = ((PIZ_MAGIC_PITCH + 1) * TLL_PIXELS_PER_SEMITONE); t_jgraphics *g = NULL; if (g = jbox_start_layer((t_object *)x, pv, TLL_SYM_ZONE, w, h)) { // t_rect r; long zone[4]; atom_getlong_array(argc - 1, argv + 1, 4, zone); r.x = TLL_POSITION_TO_X(zone[0]); r.y = TLL_PITCH_TO_Y_UP(zone[3]); r.width = TLL_POSITION_TO_X(zone[1]) - r.x; r.height = TLL_PITCH_TO_Y_DOWN(zone[2]) - r.y; if (status) { jgraphics_set_source_jrgba(g, &x->hColor2); } else { jgraphics_set_source_jrgba(g, &x->color); } jgraphics_rectangle_draw_fast(g, r.x, r.y, r.width, r.height, 1.); jbox_end_layer((t_object*)x, pv, TLL_SYM_ZONE); // } jbox_paint_layer((t_object *)x, pv, TLL_SYM_ZONE, -x->offsetX, -x->offsetY); }
void tralala_paintRun(t_tll *x, t_object *pv) { double w = (PIZ_SEQUENCE_SIZE_TIMELINE * TLL_PIXELS_PER_STEP); double h = ((PIZ_MAGIC_PITCH + 1) * TLL_PIXELS_PER_SEMITONE); t_jgraphics *g = NULL; PIZEvent *event = NULL; PIZEvent *nextEvent = NULL; pizArrayClear(x->temp[0]); TLL_DAEMON_LOCK pizLinklistPtrAtIndex(x->daemon, 0, (void **)&event); while (event) { // long argc; long *argv = NULL; pizLinklistNextWithPtr(x->daemon, (void *)event, (void **)&nextEvent); pizEventData(event, &argc, &argv); pizArrayAppend(x->temp[0], argv[0]); pizArrayAppend(x->temp[0], argv[1]); pizArrayAppend(x->temp[0], argv[2]); pizArrayAppend(x->temp[0], argv[3]); event = nextEvent; // } TLL_DAEMON_UNLOCK if (g = jbox_start_layer((t_object *)x, pv, TLL_SYM_RUN, w, h)) { // long j; long *note = pizArrayPtr(x->temp[0]); for (j = 0; j < pizArrayCount(x->temp[0]); j += 4) { t_rect r; r.x = TLL_POSITION_TO_X(note[j]); r.y = TLL_PITCH_TO_Y_UP(note[j + 1]); r.width = TLL_POSITION_TO_X(note[j] + note[j + 3]) - r.x; r.height = TLL_PITCH_TO_Y_DOWN(note[j + 1]) - r.y; jgraphics_set_source_jrgba(g, &x->hColor3); jgraphics_rectangle_fill_fast(g, r.x, r.y, r.width, r.height); } jbox_end_layer((t_object*)x, pv, TLL_SYM_RUN); // } jbox_paint_layer((t_object *)x, pv, TLL_SYM_RUN, -x->offsetX, -x->offsetY); }
void tralala_paintBackground(t_tll *x, t_object *pv) { double w = (PIZ_SEQUENCE_SIZE_TIMELINE * TLL_PIXELS_PER_STEP); double h = ((PIZ_MAGIC_PITCH + 1) * TLL_PIXELS_PER_SEMITONE); t_jgraphics *g = NULL; if (g = jbox_start_layer((t_object *)x, pv, TLL_SYM_BACKGROUND, w, h)) { jgraphics_set_source_jrgba(g, &x->color); jgraphics_rectangle_draw_fast(g, 0., 0., w, h, 1.); jbox_end_layer((t_object*)x, pv, TLL_SYM_BACKGROUND); } jbox_paint_layer((t_object *)x, pv, TLL_SYM_BACKGROUND, -x->offsetX, -x->offsetY); }
void draw_rotation(t_space *x, t_object *view, t_rect *rect) { t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("rotation_layer"), rect->width, rect->height); if (g) { for(int i = 0; i < 24; i++) { double angle = x->f_rotation * -1 - CICM_PI2 + CICM_2PI * (double)i / 24.; jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_line_draw_fast(g, Tools::abscisse((double)5.5 * x->f_rayonCircle, angle) + rect->width * 0.5, Tools::ordinate((double)5.5 * x->f_rayonCircle,angle) + rect->width * 0.5,Tools::abscisse((double)5.8 * x->f_rayonCircle, angle) + rect->width * 0.5, Tools::ordinate((double)5.8 * x->f_rayonCircle, angle) + rect->width * 0.5, 5.); } jbox_end_layer((t_object*)x, view, gensym("rotation_layer")); } jbox_paint_layer((t_object *)x, view, gensym("rotation_layer"), 0., 0.); }
void draw_separator(t_meter *x, t_object *view, t_rect *rect) { t_jgraphics *g = jbox_start_layer((t_object *)x, view, hoa_sym_separator_layer, rect->width, rect->height); if (g) { double rotateAngle, channelWidth; t_jmatrix transform; t_jrgba black = rgba_addContrast(x->f_color_mbg, -0.12); jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); jgraphics_set_matrix(g, &transform); // skelton separators and leds bg: for(int i=0; i < x->f_meter->getNumberOfPlanewaves(); i++) { channelWidth = radToDeg(x->f_meter->getPlanewaveWidth(i)); rotateAngle = radToDeg(x->f_meter->getPlanewaveAzimuthMapped(i) + x->f_meter->getPlanewavesRotationX()) - (channelWidth*0.5); if (!x->f_rotation) { rotateAngle += channelWidth; rotateAngle *= -1; } jgraphics_rotate(g, degToRad(rotateAngle)); // separator if (x->f_meter->getNumberOfPlanewaves() > 1) { jgraphics_set_line_width(g, 1); jgraphics_set_source_jrgba(g, &black); jgraphics_move_to(g, 0., x->f_rayonInt); jgraphics_line_to(g, 0, x->f_rayonExt); jgraphics_stroke(g); } jgraphics_rotate(g, degToRad(-rotateAngle)); } jbox_end_layer((t_object*)x, view, hoa_sym_separator_layer); } jbox_paint_layer((t_object *)x, view, hoa_sym_separator_layer, 0., 0.); }
void tralala_paintCurrentNote(t_tll *x, t_object *pv) { double w = (PIZ_SEQUENCE_SIZE_TIMELINE * TLL_PIXELS_PER_STEP); double h = ((PIZ_MAGIC_PITCH + 1) * TLL_PIXELS_PER_SEMITONE); t_jgraphics *g = NULL; if (g = jbox_start_layer((t_object *)x, pv, TLL_SYM_NOTE, w, h)) { // long i; for (i = 0; i < 3; i++) { // long j; long *note = pizArrayPtr(x->temp[i]); for (j = 0; j < pizArrayCount(x->temp[i]); j += 4) { t_rect r; r.x = TLL_POSITION_TO_X(note[j + 0]); r.y = TLL_PITCH_TO_Y_UP(note[j + 1]); r.width = TLL_POSITION_TO_X(note[j + 0] + note[j + 3]) - r.x; r.height = TLL_PITCH_TO_Y_DOWN(note[j + 1]) - r.y; if (i == 0 ) { jgraphics_set_source_jrgba(g, &x->color); } else if (i == 1) { jgraphics_set_source_jrgba(g, &x->hColor1); } else { jgraphics_set_source_jrgba(g, &x->hColor2); } jgraphics_rectangle_fill_fast(g, r.x, r.y, r.width, r.height); } // } jbox_end_layer((t_object*)x, pv, TLL_SYM_NOTE); // } jbox_paint_layer((t_object *)x, pv, TLL_SYM_NOTE, -x->offsetX, -x->offsetY); }
void draw_background(t_hoa_3d_scope *x, t_object *view, t_rect *rect) { t_jgraphics *g = jbox_start_layer((t_object *)x, view, hoa_sym_background_layer, rect->width, rect->height); if (g) { jgraphics_rectangle(g, 0, 0, rect->width, rect->height); jgraphics_set_source_jrgba(g, &x->f_color_bg); jgraphics_fill(g); // Border jgraphics_rectangle(g, 0, 0, rect->width, rect->height); t_jrgba black = rgba_addContrast(x->f_color_bg, -contrast_black); jgraphics_set_source_jrgba(g, &black); jgraphics_set_line_width(g, 1.); jgraphics_stroke(g); jbox_end_layer((t_object*)x, view, hoa_sym_background_layer); } jbox_paint_layer((t_object *)x, view, hoa_sym_background_layer, 0., 0.); }
void draw_cursor(t_hoa_gain *x, t_object *view, t_rect *rect, char isHoriz) { t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("cursor_layer"), rect->width, rect->height); if (g) { long pos = (long)hoa_gain_dBvaltopos(x, CLAMP(x->j_valdB, x->f_range[0], x->f_range[1]), rect, isHoriz); // draw knob rect jgraphics_set_source_jrgba(g, &x->j_knobcolor); if (isHoriz) jgraphics_rectangle(g, pos - hoa_gain_DISPLAYINSET*0.5, knobMargin, hoa_gain_DISPLAYINSET, rect->height - (knobMargin*2)); else jgraphics_rectangle(g, knobMargin, pos - hoa_gain_DISPLAYINSET*0.5, rect->width - (knobMargin*2), hoa_gain_DISPLAYINSET); jgraphics_fill(g); jbox_end_layer((t_object*)x, view, gensym("cursor_layer")); } jbox_paint_layer((t_object *)x, view, gensym("cursor_layer"), 0., 0.); }
/* Paint ------------------------------------- */ void draw_background(t_hoa_gain *x, t_object *view, t_rect *rect, char isHoriz) { t_jgraphics *g = jbox_start_layer((t_object *)x, view, hoa_sym_background_layer, rect->width, rect->height); if (g) { long zerodBpos = (long)hoa_gain_dBvaltopos(x, 0, rect, isHoriz); // Background jgraphics_rectangle(g, 0, 0, rect->width, rect->height); jgraphics_set_source_jrgba(g, &x->j_brgba); jgraphics_fill(g); // Border : jgraphics_rectangle(g, 0., 0., rect->width, rect->height); jgraphics_set_source_jrgba(g, &x->j_knobcolor); jgraphics_set_line_width(g, 1.); jgraphics_stroke(g); jgraphics_set_source_jrgba(g, &x->j_knobcolor); if (isHoriz) { jgraphics_line_draw_fast(g, zerodBpos - hoa_gain_DISPLAYINSET*0.5-knobMargin, knobMargin*0.5, zerodBpos + hoa_gain_DISPLAYINSET, knobMargin*0.5, 1); jgraphics_line_draw_fast(g, zerodBpos - hoa_gain_DISPLAYINSET*0.5-knobMargin, rect->height - knobMargin*0.5, zerodBpos + hoa_gain_DISPLAYINSET, rect->height - knobMargin*0.5, 1); } else { jgraphics_line_draw_fast(g, knobMargin*0.5, zerodBpos - hoa_gain_DISPLAYINSET*0.5-knobMargin, knobMargin*0.5, zerodBpos + hoa_gain_DISPLAYINSET, 1); jgraphics_line_draw_fast(g, rect->width - knobMargin*0.5, zerodBpos - hoa_gain_DISPLAYINSET*0.5-knobMargin, rect->width - knobMargin*0.5, zerodBpos + hoa_gain_DISPLAYINSET, 1); } jbox_end_layer((t_object*)x, view, hoa_sym_background_layer); } jbox_paint_layer((t_object *)x, view, hoa_sym_background_layer, 0, 0); }
void tralala_paintLasso(t_tll *x, t_object *pv) { double w = (PIZ_SEQUENCE_SIZE_TIMELINE * TLL_PIXELS_PER_STEP); double h = ((PIZ_MAGIC_PITCH + 1) * TLL_PIXELS_PER_SEMITONE); t_jgraphics *g = NULL; if (g = jbox_start_layer((t_object *)x, pv, TLL_SYM_LASSO, w, h)) { t_rect r; r.x = MIN(x->origin.x, x->cursor.x); r.y = MIN(x->origin.y, x->cursor.y); r.width = MAX(x->origin.x, x->cursor.x) - r.x; r.height = MAX(x->origin.y, x->cursor.y) - r.y; if (TLL_FLAG_TRUE(TLL_FLAG_LASSO)) { jgraphics_set_source_jrgba(g, &x->lasso); jgraphics_rectangle_fill_fast(g, TLL_X_OFFSET(r.x), TLL_Y_OFFSET(r.y), r.width, r.height); } jbox_end_layer((t_object*)x, pv, TLL_SYM_LASSO); } jbox_paint_layer((t_object *)x, pv, TLL_SYM_LASSO, -x->offsetX, -x->offsetY); }
void draw_harmonics(t_scope *x, t_object *view, t_rect *rect) { t_jmatrix transform; t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("harmonics_layer"), rect->width, rect->height); if (g) { t_jrgba grey = {0.5, 0.5, 0.5, 1.}; double factor = (x->f_rayonGlobal * 5. / 6.); jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center.x, x->f_center.y); jgraphics_set_matrix(g, &transform); if(x->f_viewer->getBiggestContribution() > 0.) { jgraphics_set_line_width(g, 1.); double shadow = 1.; double x1; double y1; x1 = x->f_viewer->getAbscisseValue(0) * factor + shadow; y1 = x->f_viewer->getOrdinateValue(0) * factor + shadow; jgraphics_move_to(g, x1, y1); for(int i = 0; i < NUMBEROFCIRCLEPOINTS_UI; i += 2) { x1 = x->f_viewer->getAbscisseValue(i) * factor + shadow; y1 = x->f_viewer->getOrdinateValue(i) * factor + shadow; jgraphics_line_to(g, x1, y1); } x1 = x->f_viewer->getAbscisseValue(0) * factor + shadow; y1 = x->f_viewer->getOrdinateValue(0) * factor + shadow; jgraphics_line_to(g, x1, y1); //jgraphics_smooth_line(g); jgraphics_set_source_jrgba(g, &grey); jgraphics_stroke(g); jgraphics_set_line_width(g, 1.); int color = x->f_viewer->getColor(0); x1 = x->f_viewer->getAbscisseValue(0) * factor; y1 = x->f_viewer->getOrdinateValue(0) * factor; jgraphics_move_to(g, x1, y1); for(int i = 0; i < NUMBEROFCIRCLEPOINTS_UI; i += 2) { if(x->f_viewer->getColor(i) == color) { x1 = x->f_viewer->getAbscisseValue(i) * factor; y1 = x->f_viewer->getOrdinateValue(i) * factor; jgraphics_line_to(g, x1, y1); } else { if(color == 1) jgraphics_set_source_jrgba(g, &x->f_colorPositif); else jgraphics_set_source_jrgba(g, &x->f_colorNegatif); jgraphics_line_to(g, x1, y1); //jgraphics_smooth_line(g); jgraphics_stroke(g); color = x->f_viewer->getColor(i); x1 = x->f_viewer->getAbscisseValue(i) * factor; y1 = x->f_viewer->getOrdinateValue(i) * factor; jgraphics_move_to(g, x1, y1); } } x1 = x->f_viewer->getAbscisseValue(0) * factor; y1 = x->f_viewer->getOrdinateValue(0) * factor; jgraphics_line_to(g, x1, y1); if(color == 1) jgraphics_set_source_jrgba(g, &x->f_colorPositif); else jgraphics_set_source_jrgba(g, &x->f_colorNegatif); //jgraphics_smooth_line(g); jgraphics_stroke(g); } jbox_end_layer((t_object*)x, view, gensym("harmonics_layer")); } jbox_paint_layer((t_object *)x, view, gensym("harmonics_layer"), 0., 0.); }
void draw_background(t_scope *x, t_object *view, t_rect *rect) { t_jmatrix transform; t_jrgba black, white; double contrastBlack = 0.14; double contrastWhite = 0.06; black = white = x->f_colorBackground; black.red = Tools::clip_min(black.red -= contrastBlack); black.green = Tools::clip_min(black.green -= contrastBlack); black.blue = Tools::clip_min(black.blue -= contrastBlack); white.red = Tools::clip_max(white.red += contrastWhite, 1.); white.green = Tools::clip_max(white.green += contrastWhite, 1.); white.blue = Tools::clip_max(white.blue += contrastWhite, 1.); t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("background_layer"), rect->width, rect->height); if (g) { /* Circles */ for(int i = 5; i > 0; i--) { //inner shadow jgraphics_set_line_width(g, 1); jgraphics_set_source_jrgba(g, &white); jgraphics_arc(g, long(x->f_center.x)+0.5, long(x->f_center.y)+0.5, (double)i * x->f_rayonCircle, 0., CICM_2PI); jgraphics_stroke(g); jgraphics_set_line_width(g, 1); jgraphics_set_source_jrgba(g, &black); jgraphics_arc(g, long(x->f_center.x)-0.5, long(x->f_center.y)-0.5, (double)i * x->f_rayonCircle, 0., CICM_2PI); jgraphics_stroke(g); } jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center.x, x->f_center.y); jgraphics_set_matrix(g, &transform); double coso, sino, angle, x1, y1, x2, y2, rad1, rad2; rad1 = 1. / 6. * x->f_rayonGlobal; rad2 = 5. / 6. * x->f_rayonGlobal; for(int i = 0; i < (x->f_order * 2 + 2); i++) { jgraphics_set_source_jrgba(g, &white); angle = ( (double)i/(x->f_order * 2 + 2) * CICM_2PI ) - ( 0.5/(x->f_order * 2 + 2) * CICM_2PI ); coso = cos(angle); sino = sin(angle); x1 = rad1 * coso; y1 = rad1 * sino; x2 = rad2 * coso; y2 = rad2 * sino; if(Tools::isInsideDeg(angle / CICM_2PI * 360., 45, 225)) { jgraphics_move_to(g, x1 - 0.5, y1 - 0.5); jgraphics_line_to(g, x2 - 0.5, y2 - 0.5); } else { jgraphics_move_to(g, x1 + 0.5, y1 + 0.5); jgraphics_line_to(g, x2 + 0.5, y2 + 0.5); } jgraphics_stroke(g); jgraphics_set_source_jrgba(g, &black); jgraphics_move_to(g, x1, y1); jgraphics_line_to(g, x2, y2); jgraphics_stroke(g); } jbox_end_layer((t_object*)x, view, gensym("background_layer")); } jbox_paint_layer((t_object *)x, view, gensym("background_layer"), 0., 0.); }
void draw_skeleton(t_meter *x, t_object *view, t_rect *rect) { t_jgraphics *g = jbox_start_layer((t_object *)x, view, hoa_sym_skeleton_layer, rect->width, rect->height); if (g) { double deg1, deg2, rotateAngle, ledContainerSize, ledStroke, ledMargin, ledOffset, channelWidth; t_jmatrix transform; deg1 = HOA_PI2; ledContainerSize = x->f_rayonExt - x->f_rayonInt - (1*4); ledOffset = ledContainerSize / (x->f_numleds+1); ledStroke = ledOffset * 0.75; ledMargin = ledOffset * 0.5; t_jrgba black = rgba_addContrast(x->f_color_mbg, -0.12); // Background : jgraphics_rectangle(g, 0., 0., rect->width, rect->height); jgraphics_set_source_jrgba(g, &x->f_color_bg); jgraphics_fill_preserve(g); // Border : jgraphics_set_source_jrgba(g, &black); jgraphics_set_line_width(g, 1); jgraphics_stroke(g); // Meter Background : jgraphics_set_source_jrgba(g, &x->f_color_mbg); jgraphics_set_line_width(g, (x->f_rayonExt - x->f_rayonInt) - 0.5); jgraphics_arc(g, x->f_center, x->f_center, x->f_rayonExt*0.5+(x->f_rayonInt*0.5), 0., HOA_2PI); jgraphics_stroke(g); jgraphics_arc_negative(g, x->f_center, x->f_center, x->f_rayonExt*0.5+(x->f_rayonInt*0.5), HOA_PI, -HOA_2PI); // due to a stroke bug ! jgraphics_stroke(g); // skelton circles : if (x->f_drawmborder == 1 || x->f_drawmborder == 3) { jgraphics_set_source_jrgba(g, &black); jgraphics_set_line_width(g, 1); jgraphics_arc(g, x->f_center, x->f_center, x->f_rayonExt, 0., HOA_2PI); jgraphics_stroke(g); jgraphics_arc(g, x->f_center, x->f_center, x->f_rayonInt, 0., HOA_2PI); jgraphics_stroke(g); } if (x->f_drawledsbg) { jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); jgraphics_set_matrix(g, &transform); // skelton separators and leds bg: for(ulong i = 0; i < x->f_meter->getNumberOfPlanewaves(); i++) { channelWidth = radToDeg(x->f_meter->getPlanewaveWidth(i)); deg2 = degToRad(90. + channelWidth); rotateAngle = radToDeg(x->f_meter->getPlanewaveAzimuthMapped(i) + x->f_meter->getPlanewavesRotationX()) - (channelWidth*0.5); if (!x->f_rotation) { rotateAngle += channelWidth; rotateAngle *= -1; } jgraphics_rotate(g, degToRad(rotateAngle)); // leds Background : jgraphics_set_line_width(g, ledStroke); jgraphics_set_line_cap(g, JGRAPHICS_LINE_CAP_BUTT); jgraphics_set_source_jrgba(g, &x->f_color_ledbg); for(ulong j=0; j < x->f_numleds; j++ ) { if (x->f_meter->getNumberOfPlanewaves() > 1) { if ( x->f_meter->getNumberOfPlanewaves() < 24 && (channelWidth > 14.5)) { double tmpdeg1 = 0, tmpdeg2 = 0, tmprad = 0; if (x->f_direction == 0) // inside { tmpdeg1 = deg1 + (0.008 * (j+4) * x->f_metersize); tmpdeg2 = deg2 - (0.008 * (j+4) * x->f_metersize); tmprad = x->f_rayonExt - (j*ledOffset) - ledMargin - 2; } else // outside { tmpdeg1 = deg1 + (0.008 * (x->f_numleds+3-(j)) * x->f_metersize); tmpdeg2 = deg2 - (0.008 * (x->f_numleds+3-(j)) * x->f_metersize); tmprad = x->f_rayonInt + (j*ledOffset) + ledMargin + 2; } if (tmpdeg1 < tmpdeg2) jgraphics_arc(g, 0, 0, tmprad, tmpdeg1, tmpdeg2); else jgraphics_arc(g, 0, 0, tmprad, tmpdeg2, tmpdeg1); } else { if (x->f_direction == 0) jgraphics_arc_negative(g, 0, 0, x->f_rayonExt-(j*ledOffset) - ledMargin - 2, deg2, deg1); else jgraphics_arc_negative(g, 0, 0, x->f_rayonInt+(j*ledOffset) + ledMargin + 2, deg2, deg1); } } else // mono { if (x->f_direction == 0) jgraphics_arc(g, 0, 0, x->f_rayonExt - (j*ledOffset) - ledMargin - 2, 0, HOA_2PI); else jgraphics_arc(g, 0, 0, x->f_rayonInt + (j*ledOffset) + ledMargin + 2, 0, HOA_2PI); } jgraphics_stroke(g); } jgraphics_rotate(g, degToRad(-rotateAngle)); } } jbox_end_layer((t_object*)x, view, hoa_sym_skeleton_layer); } jbox_paint_layer((t_object *)x, view, hoa_sym_skeleton_layer, 0., 0.); }
void draw_harmonics(t_space *x, t_object *view, t_rect *rect) { int pathLength = 0; t_pt beginCoord; t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("harmonics_layer"), rect->width, rect->height); if (g) { t_jmatrix transform; jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center.x, x->f_center.y); jgraphics_set_matrix(g, &transform); jgraphics_set_line_width(g, 2); 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 / x->f_viewer->getBiggestContribution(); if(x->f_mode == 1) normalize = x->f_rotation_max / x->f_viewer->getBiggestContribution(); double factor = (x->f_rayonGlobal * 5. / 6.) * normalize; jgraphics_set_source_jrgba(g, &x->f_color_harmonics); for(int i = 0; i < NUMBEROFCIRCLEPOINTS; i++) { if (i == NUMBEROFCIRCLEPOINTS-1) { jgraphics_line_to(g, beginCoord.x, beginCoord.y ); } else if(x->f_viewer->getColor(i) == 1) { if (pathLength == 0) { beginCoord.x = x->f_viewer->getAbscisseValue(i) * factor; beginCoord.y = x->f_viewer->getOrdinateValue(i) * factor; jgraphics_move_to(g, beginCoord.x, beginCoord.y ); pathLength++; } else { jgraphics_line_to(g, x->f_viewer->getAbscisseValue(i) * factor, x->f_viewer->getOrdinateValue(i) * factor); } } } if (pathLength) { jgraphics_close_path(g); jgraphics_fill_preserve(g); jgraphics_stroke(g); } } jbox_end_layer((t_object*)x, view, gensym("harmonics_layer")); } jbox_paint_layer((t_object *)x, view, gensym("harmonics_layer"), 0., 0.); }
void draw_leds(t_meter *x, t_object *view, t_rect *rect) { t_jgraphics *g = jbox_start_layer((t_object *)x, view, hoa_sym_leds_layer, rect->width, rect->height); if (g) { int i, j, nbLed, tepidLimit, warmLimit, hotLimit; long nLoudSpeak = x->f_meter->getNumberOfPlanewaves(); double deg1, deg2, rotateAngle, ledContainerSize, ledMargin, ledOffset, meter_dB, min_dB_to_display, channelWidth; double tmpdeg1, tmpdeg2, tmprad; t_jrgba ledColor; t_jmatrix transform; deg1 = HOA_PI2; nbLed = x->f_numleds+1; ledContainerSize = x->f_rayonExt - x->f_rayonInt - 4; ledOffset = ledContainerSize / nbLed; ledMargin = ledOffset * 0.50; hotLimit = x->f_numleds - x->f_nhotleds; warmLimit = hotLimit - x->f_nwarmleds; tepidLimit = warmLimit - x->f_ntepidleds; min_dB_to_display = -1 * ( (x->f_numleds * x->f_dbperled) - (x->f_dbperled * 0.5) ); jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); jgraphics_set_matrix(g, &transform); jgraphics_set_line_cap(g, JGRAPHICS_LINE_CAP_BUTT); for(i = 0; i < nLoudSpeak; i++) { // dB (negatif) de -240 à 0; meter_dB = x->f_meter->getPlanewaveEnergy(i); channelWidth = radToDeg(x->f_meter->getPlanewaveWidth(i)); deg2 = degToRad(90+(channelWidth)); rotateAngle = radToDeg(x->f_meter->getPlanewaveAzimuthMapped(i) + x->f_meter->getPlanewavesRotationX()) - (channelWidth*0.5); if(!x->f_rotation) { rotateAngle += channelWidth; rotateAngle *= -1; } jgraphics_rotate(g, degToRad(rotateAngle)); if ( meter_dB > min_dB_to_display ) // si on est en dessous pas la peine de dessiner { // leds : jgraphics_set_line_width(g, ledMargin); for(j=0; j<nbLed-1; j++) { if ( ( j < nbLed-1 ) && ( meter_dB > min_dB_to_display + (x->f_dbperled * j) ) ) { if ( j < tepidLimit ) ledColor = x->f_color_cold; else if ( j < warmLimit ) ledColor = x->f_color_tepid; else if ( j < hotLimit ) ledColor = x->f_color_warm; else ledColor = x->f_color_hot; jgraphics_set_source_jrgba(g, &ledColor); jgraphics_set_line_width(g, ledMargin); if (nLoudSpeak > 1) { if ( nLoudSpeak < 24 && (channelWidth > 14.5 )) { tmpdeg1 = 0, tmpdeg2 = 0, tmprad = 0; if (x->f_direction == 0) // inside { tmpdeg1 = deg1 + (0.01 * (j+4) * x->f_metersize); tmpdeg2 = deg2 - (0.01 * (j+4) * x->f_metersize); tmprad = x->f_rayonExt - (j*ledOffset) - ledMargin - 2; } else // outside { tmpdeg1 = deg1 + (0.01 * (nbLed+3-(j)) * x->f_metersize); tmpdeg2 = deg2 - (0.01 * (nbLed+3-(j)) * x->f_metersize); tmprad = x->f_rayonInt + (j*ledOffset) + ledMargin + 2; } if (tmpdeg1 < tmpdeg2) jgraphics_arc(g, 0, 0, tmprad, tmpdeg1, tmpdeg2); else jgraphics_arc(g, 0, 0, tmprad, tmpdeg2, tmpdeg1); } else { if (x->f_direction == 0) jgraphics_arc_negative(g, 0, 0, x->f_rayonExt-(j*ledOffset) - ledMargin - 2, deg2, deg1); else jgraphics_arc_negative(g, 0, 0, x->f_rayonInt+(j*ledOffset) + ledMargin + 2, deg2, deg1); } } else { if (x->f_direction == 0) jgraphics_arc(g, 0, 0, x->f_rayonExt-(j*ledOffset) - ledMargin - 2, 0, HOA_2PI); else jgraphics_arc(g, 0, 0, x->f_rayonInt+(j*ledOffset) + ledMargin + 2, 0, HOA_2PI); } jgraphics_stroke(g); } else { break; } } } if(x->f_meter->getPlanewaveOverLed(i)) { jgraphics_set_source_jrgba(g, &x->f_color_over); jgraphics_set_line_width(g, ledMargin); if (nLoudSpeak > 1) { if ( nLoudSpeak < 24 && (channelWidth > 14.5 )) { double tmpdeg1 = 0, tmpdeg2 = 0, tmprad = 0; if (x->f_direction == 0) // inside { tmpdeg1 = deg1 + (0.01 * (nbLed+1) * x->f_metersize); tmpdeg2 = deg2 - (0.01 * (nbLed+1) * x->f_metersize); tmprad = x->f_rayonInt + ledMargin + 1; } else // outside { tmpdeg1 = deg1+(0.008 * 3 * x->f_metersize); tmpdeg2 = deg2-(0.008 * 3 * x->f_metersize); tmprad = x->f_rayonExt - ledMargin - 1; } if (tmpdeg1 < tmpdeg2) jgraphics_arc(g, 0, 0, tmprad, tmpdeg1, tmpdeg2); else jgraphics_arc_negative(g, 0, 0, tmprad, tmpdeg1, tmpdeg2); } else { if (x->f_direction == 0) // inside jgraphics_arc_negative(g, 0, 0, x->f_rayonInt + ledMargin + 1, deg2, deg1); else // outside jgraphics_arc_negative(g, 0, 0, x->f_rayonExt - ledMargin - 1, deg2, deg1); } } else { if (x->f_direction == 0) jgraphics_arc(g, 0, 0, x->f_rayonInt + ledMargin, 0, HOA_2PI); else jgraphics_arc(g, 0, 0, x->f_rayonExt - ledMargin, 0, HOA_2PI); } jgraphics_stroke(g); } jgraphics_rotate(g, degToRad(-rotateAngle)); } jbox_end_layer((t_object*)x, view, hoa_sym_leds_layer); } jbox_paint_layer((t_object *)x, view, hoa_sym_leds_layer, 0., 0.); }
void draw_background(t_space *x, t_object *view, t_rect *rect) { int i; double y1, y2, rotateAngle; t_jmatrix transform; t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("background_layer"), rect->width, rect->height); if (g) { /* Background ************************************/ jgraphics_rectangle_rounded(g, 0.5, 0.5, rect->width-1., rect->height-1., 12, 12); jgraphics_set_source_jrgba(g, &x->f_color_background); jgraphics_fill_preserve(g); jgraphics_set_source_jrgba(g, &x->f_color_border_box); jgraphics_stroke(g); /* Rotation slider *******************************/ if (x->f_shadow) { /* Inner shadow */ jgraphics_set_line_width(g, 4); jgraphics_set_source_jrgba(g, &x->f_color_circleShadow); jgraphics_arc(g, x->f_center.x+0.5, x->f_center.y+0.5, (double)5.5 * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); jgraphics_set_line_width(g, 4); jgraphics_set_source_jrgba(g, &x->f_color_circleShadow); jgraphics_arc(g, x->f_center.x+0.5, x->f_center.y+0.5, (double)5.8 * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); } /* Circle color */ jgraphics_set_line_width(g, 3); jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_arc(g, x->f_center.x, x->f_center.y, (double)5.5 * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); jgraphics_set_line_width(g, 3); jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_arc(g, x->f_center.x, x->f_center.y, (double)5.8 * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); /* Gros cercle */ jgraphics_arc(g, x->f_center.x, x->f_center.y, 5 * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_set_source_jrgba(g, &x->f_color_circleInner); jgraphics_fill(g); /* Circles ***************************************/ for(i = 5; i > 0; i--) { if (x->f_shadow) { /* Inner shadow */ jgraphics_set_line_width(g, 2); jgraphics_set_source_jrgba(g, &x->f_color_circleShadow); jgraphics_arc(g, x->f_center.x+0.5, x->f_center.y+0.5, (double)i * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); } /* Circle color */ jgraphics_set_line_width(g, 1); jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_arc(g, x->f_center.x, x->f_center.y, (double)i * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); } /* Axes *******************************************/ jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center.x, x->f_center.y); jgraphics_set_matrix(g, &transform); for(i = 0; i < x->f_number_of_microphones; i++) { rotateAngle = (double)i/ (double)x->f_number_of_microphones * JGRAPHICS_2PI - JGRAPHICS_2PI / ((double)x->f_number_of_microphones * 2.); jgraphics_rotate(g, rotateAngle); y1 = 1. / 6. * x->f_rayonGlobal; y2 = 5. / 6. * x->f_rayonGlobal; if (x->f_shadow) { if ( (rotateAngle <= JGRAPHICS_PI && rotateAngle > 0.) ) { jgraphics_move_to(g, -0.5, y1-0.5); jgraphics_line_to(g, -0.5, y2-0.5); } else { jgraphics_move_to(g, 0.5, y1+0.5); jgraphics_line_to(g, 0.5, y2+0.5); } jgraphics_set_line_width(g, 2); jgraphics_set_source_jrgba(g, &x->f_color_circleShadow); jgraphics_stroke(g); } jgraphics_move_to(g, 0, y1); jgraphics_line_to(g, 0, y2); jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_set_line_width(g, 1); jgraphics_stroke(g); jgraphics_rotate(g, -rotateAngle); } jbox_end_layer((t_object*)x, view, gensym("background_layer")); } jbox_paint_layer((t_object *)x, view, gensym("background_layer"), 0., 0.); }
void draw_harmonics(t_scope *x, t_object *view, t_rect *rect) { int pathLength = 0; t_pt beginCoord; t_jpath* posHarmPath = NULL; t_jpath* negHarmPath = NULL; t_jmatrix transform; t_jrgba shadcolor = {0.4, 0.4, 0.4, 0.9}; double alphaShadow = 1.; long posPathLen, negPathLen; long precIndex = 0; double factor; posPathLen = negPathLen = 0; t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("harmonics_layer"), rect->width, rect->height); if (alphaShadow > x->f_colorPositif.alpha ) alphaShadow = x->f_colorPositif.alpha; if (alphaShadow > x->f_colorNegatif.alpha ) alphaShadow = x->f_colorNegatif.alpha; alphaShadow -= 0.5; if (alphaShadow < 0.) alphaShadow = 0; shadcolor.alpha = alphaShadow; if (g) { jgraphics_set_line_join(g, JGRAPHICS_LINE_JOIN_ROUND); jgraphics_set_line_cap(g, JGRAPHICS_LINE_CAP_ROUND); jgraphics_set_line_width(g, 1); if(x->f_viewer->getBiggestContribution() > 0.) { factor = (x->f_rayonGlobal * 5. / 6.); if (x->f_viewer->getBiggestContribution() > 1) factor /= x->f_viewer->getBiggestContribution(); Tools::clip(&factor, 0., (x->f_rayonGlobal * 5. / 6.)); // positiv harmonics for(int i = 0; i < NUMBEROFCIRCLEPOINTS_UI; i++) { precIndex = i-1; if (precIndex < 0) precIndex += NUMBEROFCIRCLEPOINTS_UI; if (i == NUMBEROFCIRCLEPOINTS_UI-1) { jgraphics_line_to(g, beginCoord.x, beginCoord.y ); } else if(x->f_viewer->getColor(i) == 1 || x->f_viewer->getColor(i) == 0) { if (pathLength == 0) { beginCoord.x = x->f_viewer->getAbscisseValue(i) * factor; beginCoord.y = x->f_viewer->getOrdinateValue(i) * factor; jgraphics_move_to(g, beginCoord.x, beginCoord.y ); pathLength++; } else if(x->f_viewer->getColor(precIndex) != 1) { jgraphics_line_to(g, 0, 0); jgraphics_move_to(g, x->f_viewer->getAbscisseValue(i) * factor, x->f_viewer->getOrdinateValue(i) * factor); } else { jgraphics_line_to(g, x->f_viewer->getAbscisseValue(i) * factor, x->f_viewer->getOrdinateValue(i) * factor); } } } if (pathLength) { //jgraphics_close_path(g); posHarmPath = jgraphics_copy_path(g); } posPathLen = pathLength; pathLength = 0; jgraphics_new_path(g); for(int i = 0; i < NUMBEROFCIRCLEPOINTS_UI; i++) { precIndex = i-1; if (precIndex < 0) precIndex += NUMBEROFCIRCLEPOINTS_UI; if (i == NUMBEROFCIRCLEPOINTS_UI-1) { jgraphics_line_to(g, beginCoord.x, beginCoord.y ); } else if(x->f_viewer->getColor(i) == -1 || x->f_viewer->getColor(i) == 0) { if (!pathLength) { beginCoord.x = x->f_viewer->getAbscisseValue(i) * factor; beginCoord.y = x->f_viewer->getOrdinateValue(i) * factor; jgraphics_move_to(g, beginCoord.x, beginCoord.y ); pathLength++; } else if(x->f_viewer->getColor(precIndex) != -1) { jgraphics_line_to(g, 0, 0); jgraphics_move_to(g, x->f_viewer->getAbscisseValue(i) * factor, x->f_viewer->getOrdinateValue(i) * factor); } else { jgraphics_line_to(g, x->f_viewer->getAbscisseValue(i) * factor, x->f_viewer->getOrdinateValue(i) * factor); } } } if (pathLength) { //jgraphics_close_path(g); negHarmPath = jgraphics_copy_path(g); } negPathLen = pathLength; // draw harmonics : if (posPathLen || negPathLen) { jgraphics_new_path(g); jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center.x, x->f_center.y); jgraphics_set_matrix(g, &transform); // shadows if (posPathLen) jgraphics_append_path(g, posHarmPath); //if (negPathLen) jgraphics_append_path(g, negHarmPath); jgraphics_set_source_jrgba(g, &shadcolor); jgraphics_stroke(g); jgraphics_translate(g, 1, 1); // harmocolor if (posPathLen) jgraphics_append_path(g, posHarmPath); jgraphics_set_source_jrgba(g, &x->f_colorPositif); jgraphics_stroke(g); if (negPathLen) jgraphics_append_path(g, negHarmPath); jgraphics_set_source_jrgba(g, &x->f_colorNegatif); jgraphics_stroke(g); } } jbox_end_layer((t_object*)x, view, gensym("harmonics_layer")); } jbox_paint_layer((t_object *)x, view, gensym("harmonics_layer"), 0., 0.); }
void draw_vectors(t_meter *x, t_object *view, t_rect *rect) { double pointSize = rect->width*0.02; double maxRadius = (x->f_rayonInt-pointSize-1); if (pointSize > maxRadius) return; double vecX, vecY; t_jmatrix transform; t_jgraphics *g = jbox_start_layer((t_object *)x, view, hoa_sym_vectors_layer, rect->width, rect->height); if (g) { jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); jgraphics_set_matrix(g, &transform); if (x->f_rotation) jgraphics_rotate(g, x->f_meter->getPlanewavesRotationX()); else jgraphics_rotate(g, -x->f_meter->getPlanewavesRotationX()); if (x->f_drawvector == VECTOR_BOTH || x->f_drawvector == VECTOR_ENERGY) { if (x->f_rotation) { vecX = x->f_vector_coords[2] * maxRadius; vecY = x->f_vector_coords[3] * maxRadius; } else { double rad = Math<double>::radius(x->f_vector_coords[2], x->f_vector_coords[3]) * maxRadius; double ang = -Math<double>::azimuth(x->f_vector_coords[2], x->f_vector_coords[3]); vecX = Math<double>::abscissa(rad, ang); vecY = Math<double>::ordinate(rad, ang); } jgraphics_set_source_jrgba(g, &x->f_color_energy); jgraphics_arc(g, vecX, vecY, pointSize, 0., HOA_2PI); jgraphics_fill_preserve(g); jgraphics_set_source_rgba(g, 0.2, 0.2, 0.2, 1.); jgraphics_stroke(g); } if (x->f_drawvector == VECTOR_BOTH || x->f_drawvector == VECTOR_VELOCITY) { if (x->f_rotation) { double rad = min(Math<double>::radius(x->f_vector_coords[0], x->f_vector_coords[1]), 1.) * maxRadius; double ang = Math<double>::azimuth(x->f_vector_coords[0], x->f_vector_coords[1]); vecX = Math<double>::abscissa(rad, ang); vecY = Math<double>::ordinate(rad, ang); } else { double rad = min(Math<double>::radius(x->f_vector_coords[0], x->f_vector_coords[1]), 1.) * maxRadius; double ang = -Math<double>::azimuth(x->f_vector_coords[0], x->f_vector_coords[1]); vecX = Math<double>::abscissa(rad, ang); vecY = Math<double>::ordinate(rad, ang); } jgraphics_set_source_jrgba(g, &x->f_color_velocity); jgraphics_arc(g, vecX, vecY, pointSize, 0., HOA_2PI); jgraphics_fill_preserve(g); jgraphics_set_source_rgba(g, 0.2, 0.2, 0.2, 1.); jgraphics_stroke(g); } jbox_end_layer((t_object*)x, view, hoa_sym_vectors_layer); } jbox_paint_layer((t_object *)x, view, hoa_sym_vectors_layer, 0., 0.); }
void hoa_space_draw_background(t_hoa_space *x, t_object *view, t_rect *rect) { t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("background_layer"), rect->width, rect->height); if (g) { t_jmatrix transform; jgraphics_matrix_init(&transform, 1, 0, 0, 1, x->f_center.x, x->f_center.y); jgraphics_set_matrix(g, &transform); t_jrgba black = jrgba_addContrast(x->f_color_inner_circle, -0.12); t_jrgba white = jrgba_addContrast(x->f_color_inner_circle, 0.08); jgraphics_set_source_jrgba(g, &x->f_color_inner_circle); jgraphics_arc(g, 0., 0., x->f_radius_ext_circle, 0.f, JGRAPHICS_2PI); jgraphics_fill(g); for(int i = NUMBER_OF_CIRCLES; i > 0; i--) { jgraphics_set_line_width(g, 2); jgraphics_set_source_jrgba(g, &white); jgraphics_arc(g, -0.5, -0.5, (double)i * x->f_radius_circle, 0.f, JGRAPHICS_2PI); jgraphics_stroke(g); jgraphics_set_line_width(g, 1); jgraphics_set_source_jrgba(g, &black); jgraphics_arc(g, 0, 0, (double)i * x->f_radius_circle, 0.f, JGRAPHICS_2PI); jgraphics_stroke(g); } double coso, sino, angle, x1, y1, x2, y2, rad1, rad2, offset; offset = CICM_PI / (double)x->f_number_of_microphones; rad1 = 1. / (double)NUMBER_OF_CIRCLES * x->f_radius_ext_circle; rad2 = x->f_radius_ext_circle; for(int i = 0; i < x->f_number_of_microphones; i++) { jgraphics_set_source_jrgba(g, &white); angle = i * CICM_2PI / (double)x->f_number_of_microphones + offset + CICM_PI2; coso = cosf(angle); sino = sinf(angle); x1 = rad1 * coso; y1 = rad1 * sino; x2 = rad2 * coso; y2 = rad2 * sino; if(Tools::isInsideDeg(angle / CICM_2PI * 360., 45, 225)) { jgraphics_move_to(g, x1 - 0.5, y1 - 0.5); jgraphics_line_to(g, x2 - 0.5, y2 - 0.5); } else { jgraphics_move_to(g, x1 + 0.5, y1 + 0.5); jgraphics_line_to(g, x2 + 0.5, y2 + 0.5); } jgraphics_stroke(g); jgraphics_set_source_jrgba(g, &black); jgraphics_move_to(g, x1, y1); jgraphics_line_to(g, x2, y2); jgraphics_stroke(g); } jbox_end_layer((t_object*)x, view, gensym("background_layer")); } jbox_paint_layer((t_object *)x, view, gensym("background_layer"), 0., 0.); }
void draw_background(t_scope *x, t_object *view, t_rect *rect) { int i; double y1, y2, rotateAngle; t_jmatrix transform; t_jrgba black, white; double contrastBlack = 0.12; double contrastWhite = 0.08; black = white = x->f_colorBackground; black.red = Tools::clip_min(black.red -= contrastBlack); black.green = Tools::clip_min(black.green -= contrastBlack); black.blue = Tools::clip_min(black.blue -= contrastBlack); white.red = Tools::clip_max(white.red += contrastWhite, 1.); white.green = Tools::clip_max(white.green += contrastWhite, 1.); white.blue = Tools::clip_max(white.blue += contrastWhite, 1.); t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("background_layer"), rect->width, rect->height); if (g) { /* Background */ /* jgraphics_set_source_jrgba(g, &x->f_colorBackground); jgraphics_rectangle_rounded(g, 0., 0., rect->width, rect->height, 6, 6); jgraphics_fill(g); */ /* Circles */ for(i = 5; i > 0; i--) { //inner shadow jgraphics_set_line_width(g, 2); jgraphics_set_source_jrgba(g, &white); jgraphics_arc(g, x->f_center.x+0.5, x->f_center.y+0.5, (double)i * x->f_rayonCircle, 0., CICM_2PI); jgraphics_stroke(g); jgraphics_set_line_width(g, 1); jgraphics_set_source_jrgba(g, &black); jgraphics_arc(g, x->f_center.x, x->f_center.y, (double)i * x->f_rayonCircle, 0., CICM_2PI); jgraphics_stroke(g); } /* Axes */ jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center.x, x->f_center.y); jgraphics_set_matrix(g, &transform); jgraphics_set_source_jrgba(g, &black); //for(i = 0; i < 12; i++) for(i = 0; i < (x->f_order * 2 + 2) ; i++) { rotateAngle = ( (double)i/(x->f_order * 2 + 2) * CICM_2PI ) - ( 0.5/(x->f_order * 2 + 2) * CICM_2PI ); jgraphics_rotate(g, rotateAngle); y1 = 1. / 6. * x->f_rayonGlobal; y2 = 5. / 6. * x->f_rayonGlobal; if ( (rotateAngle <= CICM_PI && rotateAngle > 0.) ) { jgraphics_move_to(g, -0.5, y1-0.5); jgraphics_line_to(g, -0.5, y2-0.5); } else { jgraphics_move_to(g, 0.5, y1+0.5); jgraphics_line_to(g, 0.5, y2+0.5); } jgraphics_set_line_width(g, 2); jgraphics_set_source_jrgba(g, &white); jgraphics_stroke(g); jgraphics_move_to(g, 0, y1); jgraphics_line_to(g, 0, y2); jgraphics_set_source_jrgba(g, &black); jgraphics_set_line_width(g, 1); jgraphics_stroke(g); jgraphics_rotate(g, -rotateAngle); } jbox_end_layer((t_object*)x, view, gensym("background_layer")); } jbox_paint_layer((t_object *)x, view, gensym("background_layer"), 0., 0.); }
void draw_harmonics(t_hoa_3d_scope *x, t_object *view, t_rect *rect) { t_jgraphics *g = jbox_start_layer((t_object *)x, view, hoa_sym_harmonics_layer, rect->width, rect->height); if (g) { char pathLength; t_jmatrix transform; t_jrgba color_pos; t_jrgba color_neg; t_jrgba black = rgba_addContrast(x->f_color_bg, -contrast_black); t_jrgba white = rgba_addContrast(x->f_color_bg, contrast_white); jgraphics_rotate(g, HOA_PI); jgraphics_set_line_width(g, 1); jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); jgraphics_set_matrix(g, &transform); for(ulong j = 0; j < x->f_scope->getNumberOfRows() * 0.5; j++) { pathLength = 0; double constrast = (j - x->f_scope->getNumberOfRows() * 0.5) / (double)x->f_scope->getNumberOfRows(); color_pos = rgba_addContrast(x->f_color_ph, constrast); color_neg = rgba_addContrast(x->f_color_nh, constrast); jgraphics_set_source_jrgba(g, &color_pos); double elev = x->f_scope->getPointElevation(j); for(int i = 0; i < x->f_scope->getNumberOfColumns(); i++) { double azim = x->f_scope->getPointAzimuth(i); double value = x->f_scope->getPointValue(j, i); if(value >= 0) { value *= x->f_radius; if(!pathLength) { jgraphics_move_to(g, Math<double>::abscissa(value, azim,elev), Math<double>::ordinate(value, azim, elev)); pathLength++; } else { jgraphics_line_to(g, Math<double>::abscissa(value, azim,elev), Math<double>::ordinate(value, azim, elev)); } } } jgraphics_close_path(g); if(pathLength) jgraphics_fill(g); pathLength = 0; jgraphics_set_source_jrgba(g, &color_neg); for(int i = 0; i < x->f_scope->getNumberOfColumns(); i++) { double azim = x->f_scope->getPointAzimuth(i); double value = x->f_scope->getPointValue(j, i); if(value < 0) { value *= -x->f_radius; if(!pathLength) { jgraphics_move_to(g, Math<double>::abscissa(value, azim,elev), Math<double>::ordinate(value, azim, elev)); pathLength++; } else { jgraphics_line_to(g, Math<double>::abscissa(value, azim,elev), Math<double>::ordinate(value, azim, elev)); } } } jgraphics_close_path(g); if(pathLength) jgraphics_fill(g); } 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; jgraphics_move_to(g, x1, y1); jgraphics_line_to(g, x2, y2); jgraphics_set_line_width(g, 3); jgraphics_set_source_jrgba(g, &white); jgraphics_stroke(g); jgraphics_set_source_jrgba(g, &black); jgraphics_set_line_width(g, 1); jgraphics_stroke(g); } for(int i = 5; i > 0; i--) { jgraphics_set_line_width(g, 3); jgraphics_set_source_jrgba(g, &white); jgraphics_arc(g, 0, 0, (double)i * 0.2 * x->f_radius, 0., HOA_2PI); jgraphics_stroke(g); jgraphics_set_line_width(g, 1); jgraphics_set_source_jrgba(g, &black); jgraphics_stroke(g); } for(ulong j = (ulong)(x->f_scope->getNumberOfRows() * 0.5); j < x->f_scope->getNumberOfRows(); j++) { // positive harmonics pathLength = 0; double constrast = (j - x->f_scope->getNumberOfRows() * 0.5) / (double)x->f_scope->getNumberOfRows(); color_pos = rgba_addContrast(x->f_color_ph, constrast); color_neg = rgba_addContrast(x->f_color_nh, constrast); jgraphics_set_source_jrgba(g, &color_pos); double elev = x->f_scope->getPointElevation(j); for(int i = 0; i < x->f_scope->getNumberOfColumns(); i++) { double azim = x->f_scope->getPointAzimuth(i); double value = x->f_scope->getPointValue(j, i); if(value >= 0) { value *= x->f_radius; if(!pathLength) { jgraphics_move_to(g, Math<double>::abscissa(value, azim,elev), Math<double>::ordinate(value, azim, elev)); pathLength++; } else { jgraphics_line_to(g, Math<double>::abscissa(value, azim,elev), Math<double>::ordinate(value, azim, elev)); } } } jgraphics_close_path(g); if(pathLength) jgraphics_fill(g); pathLength = 0; // negative harmonics jgraphics_set_source_jrgba(g, &color_neg); for(int i = 0; i < x->f_scope->getNumberOfColumns(); i++) { double azim = x->f_scope->getPointAzimuth(i); double value = x->f_scope->getPointValue(j, i); if(value < 0) { value *= -x->f_radius; if(!pathLength) { jgraphics_move_to(g, Math<double>::abscissa(value, azim,elev), Math<double>::ordinate(value, azim, elev)); pathLength++; } else { jgraphics_line_to(g, Math<double>::abscissa(value, azim,elev), Math<double>::ordinate(value, azim, elev)); } } } jgraphics_close_path(g); if(pathLength) jgraphics_fill(g); } jbox_end_layer((t_object*)x, view, hoa_sym_harmonics_layer); } jbox_paint_layer((t_object *)x, view, hoa_sym_harmonics_layer, 0., 0.); }
void draw_background(t_hoa_scope *x, t_object *view, t_rect *rect) { int i; double y1, y2, rotateAngle; t_jmatrix transform; t_jrgba 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_jgraphics *g = jbox_start_layer((t_object *)x, view, hoa_sym_background_layer, rect->width, rect->height); if (g) { jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); jgraphics_set_matrix(g, &transform); 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); jgraphics_rotate(g, rotateAngle); y1 = x->f_radius / 5.; y2 = x->f_radius; if(rotateAngle > HOA_PI2 && rotateAngle < HOA_PI + HOA_PI2) { jgraphics_move_to(g, -1, long(y1)); jgraphics_line_to(g, -1, long(y2)); } else { jgraphics_move_to(g, 1, long(y1)); jgraphics_line_to(g, 1, long(y2)); } jgraphics_set_line_width(g, 2); jgraphics_set_source_jrgba(g, &white); jgraphics_stroke(g); jgraphics_move_to(g, 0, y1); jgraphics_line_to(g, 0, y2); jgraphics_set_source_jrgba(g, &black); jgraphics_set_line_width(g, 1); jgraphics_stroke(g); jgraphics_rotate(g, -rotateAngle); } jgraphics_matrix_init(&transform, 1, 0, 0, 1, x->f_center, x->f_center); jgraphics_set_matrix(g, &transform); for(i = 5; i > 0; i--) { jgraphics_set_line_width(g, 2); jgraphics_set_source_jrgba(g, &white); jgraphics_arc(g, 1, 1, (double)i / 5. * x->f_radius, 0., HOA_2PI); jgraphics_stroke(g); jgraphics_set_line_width(g, 1); jgraphics_set_source_jrgba(g, &black); jgraphics_arc(g, 0, 0, (double)i / 5.* x->f_radius, 0., HOA_2PI); jgraphics_stroke(g); } jbox_end_layer((t_object*)x, view, hoa_sym_background_layer); } jbox_paint_layer((t_object *)x, view, hoa_sym_background_layer, 0., 0.); }
void draw_harmonics(t_hoa_scope *x, t_object *view, t_rect *rect) { int pathLength = 0; t_pt beginCoord; t_jpath* posHarmPath = NULL; t_jpath* negHarmPath = NULL; t_jmatrix transform; t_jrgba shadcolor = {0.4, 0.4, 0.4, 1.}; long posPathLen = 0, negPathLen = 0, precIndex = 0; t_jgraphics *g = jbox_start_layer((t_object *)x, view, hoa_sym_harmonics_layer, rect->width, rect->height); if(shadcolor.alpha > x->f_color_nh.alpha) shadcolor.alpha = x->f_color_ph.alpha; if(shadcolor.alpha > x->f_color_nh.alpha) shadcolor.alpha = x->f_color_nh.alpha; shadcolor.alpha -= 0.5; if(shadcolor.alpha < 0.) shadcolor.alpha = 0; if (g) { jgraphics_rotate(g, HOA_PI); jgraphics_set_line_join(g, JGRAPHICS_LINE_JOIN_ROUND); jgraphics_set_line_cap(g, JGRAPHICS_LINE_CAP_ROUND); jgraphics_set_line_width(g, 1); // positiv harmonics for(int i = 0; i < x->f_scope->getNumberOfPoints(); i++) { precIndex = i-1; if(precIndex < 0) precIndex += x->f_scope->getNumberOfPoints(); if(i == x->f_scope->getNumberOfPoints()-1) { jgraphics_line_to(g, beginCoord.x, beginCoord.y ); } else if(x->f_scope->getValue(i) >= 0) { if (pathLength == 0) { beginCoord.x = x->f_scope->getAbscissa(i) * x->f_radius; beginCoord.y = x->f_scope->getOrdinate(i) * x->f_radius; jgraphics_move_to(g, beginCoord.x, beginCoord.y ); pathLength++; } else if(x->f_scope->getValue(i) < 0) { jgraphics_line_to(g, 0, 0); jgraphics_move_to(g, x->f_scope->getAbscissa(i) * x->f_radius, x->f_scope->getOrdinate(i) * x->f_radius); } else { jgraphics_line_to(g, x->f_scope->getAbscissa(i) * x->f_radius, x->f_scope->getOrdinate(i) * x->f_radius); } } } if (pathLength) { posHarmPath = jgraphics_copy_path(g); } posPathLen = pathLength; pathLength = 0; jgraphics_new_path(g); for(int i = 0; i < x->f_scope->getNumberOfPoints(); i++) { precIndex = i-1; if (precIndex < 0) precIndex += x->f_scope->getNumberOfPoints(); if (i == x->f_scope->getNumberOfPoints()-1) { jgraphics_line_to(g, beginCoord.x, beginCoord.y ); } else if(x->f_scope->getValue(i) < 0) { if (!pathLength) { beginCoord.x = x->f_scope->getAbscissa(i) * x->f_radius; beginCoord.y = x->f_scope->getOrdinate(i) * x->f_radius; jgraphics_move_to(g, beginCoord.x, beginCoord.y ); pathLength++; } else if(x->f_scope->getValue(precIndex) >= 0) { jgraphics_line_to(g, 0, 0); jgraphics_move_to(g, x->f_scope->getAbscissa(i) * x->f_radius, x->f_scope->getOrdinate(i) * x->f_radius); } else { jgraphics_line_to(g, x->f_scope->getAbscissa(i) * x->f_radius, x->f_scope->getOrdinate(i) * x->f_radius); } } } if(pathLength) { negHarmPath = jgraphics_copy_path(g); } negPathLen = pathLength; // draw harmonics : if(posPathLen || negPathLen) { jgraphics_new_path(g); jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center); jgraphics_set_matrix(g, &transform); // shadows jgraphics_translate(g, 1, 1); // decalage de l'ombre if (posPathLen) jgraphics_append_path(g, posHarmPath); if (negPathLen) jgraphics_append_path(g, negHarmPath); jgraphics_set_source_jrgba(g, &shadcolor); jgraphics_stroke(g); jgraphics_translate(g, -1, -1); // annulation du decalage // harmocolor if(posPathLen) { jgraphics_append_path(g, posHarmPath); jgraphics_set_source_jrgba(g, &x->f_color_ph); jgraphics_stroke(g); } if(negPathLen) { jgraphics_append_path(g, negHarmPath); jgraphics_set_source_jrgba(g, &x->f_color_nh); jgraphics_stroke(g); } } jbox_end_layer((t_object*)x, view, hoa_sym_harmonics_layer); } jbox_paint_layer((t_object *)x, view, hoa_sym_harmonics_layer, 0., 0.); }