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_jbox *)x), gensym("regular"), gensym("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, y1 - i * x->f_rayonCircle, x->f_fontsize * 4, x->f_fontsize, ETEXT_UP, ETEXT_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_jbox *)x), gensym("regular"), gensym("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 - x->f_fontsize / 2.) * cos((double)-i * CICM_2PI / (x->f_order*2+2) - CICM_PI / 2.) + x->f_center.x; y1 = (x->f_rayonAngle - x->f_fontsize / 2.) * sin((double)-i * CICM_2PI / (x->f_order*2+2) - CICM_PI / 2.) + x->f_center.y; sprintf(text,"%i°", (int)( (360*i) / (x->f_order*2+2) ) ); jtextlayout_set(jtl, text, jf, x1, y1, x->f_fontsize * 3., 20, ETEXT_CENTER, ETEXT_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 uisimp_paint(t_uisimp *x, t_object *view) { t_jgraphics *g; t_rect rect; t_jrgba rgba, textcolor; t_jfont *jf; t_jtextlayout *jtl; char text[16]; g = (t_jgraphics*) patcherview_get_jgraphics(view); jbox_get_rect_for_view(&x->j_box.b_ob, view, &rect); if (x->j_mouse_is_down) { jbox_get_color((t_object *)x, &rgba); jgraphics_set_source_jrgba(g, &rgba); } else jgraphics_set_source_rgba(g, 0, 0, 0, 1.0); //jgraphics_fill(g); // draw counter jf = jfont_create(jbox_get_fontname((t_object *)x)->s_name, jbox_get_font_slant((t_object *)x), jbox_get_font_weight((t_object *)x), jbox_get_fontsize((t_object *)x)); jtl = jtextlayout_create(); sprintf(text,"%d",x->j_mouse_counter); jtextlayout_set(jtl, text, jf, 5, 5, rect.width - 10, rect.height- 10, JGRAPHICS_TEXT_JUSTIFICATION_CENTERED, JGRAPHICS_TEXTLAYOUT_NOWRAP); textcolor.red = textcolor.green = textcolor.blue = 1; textcolor.alpha = 1; jtextlayout_settextcolor(jtl, &textcolor); jtextlayout_draw(jtl, g); jtextlayout_destroy(jtl); jfont_destroy(jf); }
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 tralala_paintCurrentText(t_tll *x, t_object *pv, char *string) { t_rect r; t_jgraphics *g = NULL; t_jfont *font = NULL; t_jgraphics_textlayout_flags flags = (t_jgraphics_textlayout_flags) (0); t_jgraphics_text_justification justification = JGRAPHICS_TEXT_JUSTIFICATION_RIGHT; jbox_get_rect_for_view((t_object *)x, pv, &r); g = (t_jgraphics *)patcherview_get_jgraphics(pv); font = jfont_create((jbox_get_fontname(((t_object *)x)))->s_name, (t_jgraphics_font_slant)(jbox_get_font_slant((t_object *)x)), (t_jgraphics_font_weight)(jbox_get_font_weight((t_object *)x)), (jbox_get_fontsize((t_object *)x))); jtextlayout_set(x->layer, string, font, 5., 5., r.width - 10., r.height - 5., justification, flags); if (TLL_FLAG_TRUE(TLL_FLAG_FOCUS)) { jtextlayout_settextcolor(x->layer, &x->text); } else { jtextlayout_settextcolor(x->layer, &x->uText); } jtextlayout_draw(x->layer, g); jfont_destroy(font); }
void uisimp_paint(t_uisimp *x, t_object *view) { t_jgraphics *g; t_rect rect; t_jrgba rgba, textcolor; t_jfont *jf; t_jtextlayout *jtl; char text[16]; long inset = x->j_inset; g = (t_jgraphics*) patcherview_get_jgraphics(view); jbox_get_rect_for_view(&x->j_box.b_ob, view, &rect); if (x->j_shape == EXAMP_SQUARE) jgraphics_rectangle(g, inset, inset, rect.width - (inset * 2), rect.height - (inset * 2)); else if (x->j_shape == EXAMP_CIRCLE) { jgraphics_arc(g, rect.width * .5, rect.height * .5, (rect.width * .5) - (inset * 2), 0, JGRAPHICS_2PI); jgraphics_close_path(g); } else if (x->j_shape == EXAMP_ANGLE) { jgraphics_move_to(g, inset * 2, inset); jgraphics_line_to(g, rect.width - (inset * 2), inset); jgraphics_line_to(g, rect.width - (inset * 2), inset * 2); jgraphics_line_to(g, rect.width - (inset * 2), rect.height - (inset * 2)); jgraphics_line_to(g, rect.width - (inset * 2), rect.height - inset); jgraphics_line_to(g, inset * 2, rect.height - (inset * 2)); jgraphics_line_to(g, inset, rect.height - (inset * 3)); jgraphics_line_to(g, inset, inset * 2); jgraphics_line_to(g, inset * 2, inset); jgraphics_close_path(g); } if (x->j_mouse_is_down) { jbox_get_color((t_object *)x, &rgba); jgraphics_set_source_jrgba(g, &rgba); } else jgraphics_set_source_rgba(g, 0, 0, 0, 1.0); jgraphics_fill(g); // draw counter jf = jfont_create(jbox_get_fontname((t_object *)x)->s_name, jbox_get_font_slant((t_object *)x), jbox_get_font_weight((t_object *)x), jbox_get_fontsize((t_object *)x)); jtl = jtextlayout_create(); sprintf(text,"%d",x->j_mouse_counter); jtextlayout_set(jtl, text, jf, 5, 5, rect.width - 10, rect.height- 10, JGRAPHICS_TEXT_JUSTIFICATION_CENTERED, JGRAPHICS_TEXTLAYOUT_NOWRAP); textcolor.red = textcolor.green = textcolor.blue = 1; textcolor.alpha = 1; jtextlayout_settextcolor(jtl, &textcolor); jtextlayout_draw(jtl, g); jtextlayout_destroy(jtl); jfont_destroy(jf); }