Esempio n. 1
0
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.);
}
Esempio n. 2
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);
    
}
Esempio n. 3
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);
}
Esempio n. 4
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_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.);
}
Esempio n. 6
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.);
}
Esempio n. 7
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.);
}
Esempio n. 8
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.);
}
Esempio n. 9
0
void draw_items(t_radio *x, t_object *view, t_rect *rect)
{
	int i;
	t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("items_layer"), rect->width, rect->height);
    
	if (g)
	{
        egraphics_set_color_rgba(g, &x->f_color_item);
        egraphics_set_line_width(g, 2);
        if(x->f_mode)
        {
            if(x->f_direction)
            {
                float ratio = rect->width / x->f_nitems;
                float offset = rect->height * 0.35;
                for(i = 0; i < x->f_nitems; i++)
                {
                    if(x->f_items[i])
                    {
                        egraphics_rectangle(g, (i + 0.5) * ratio - offset, rect->height *0.15, offset * 2., offset * 2.);
                        egraphics_fill(g);
                    }
                }
            }
            else
            {
                float ratio = rect->height / x->f_nitems;
                float offset = rect->width * 0.35;
                for(i = 0; i < x->f_nitems; i++)
                {
                    if(x->f_items[i])
                    {
                        egraphics_rectangle(g, rect->width * 0.15, (i + 0.5) * ratio - offset, offset * 2., offset * 2.);
                        egraphics_fill(g);
                    }
                }
            }
        }
        else
        {
            if(x->f_direction)
            {
                float ratio = rect->width / x->f_nitems;
                for(i = 0; i < x->f_nitems; i++)
                {
                    if(x->f_items[i])
                    {
                        egraphics_circle(g, (i + 0.5) * ratio, rect->height * 0.5, rect->height * 0.35);
                        egraphics_fill(g);
                    }
                }
            }
            else
            {
                float ratio = rect->height / x->f_nitems;
                for(i = 0; i < x->f_nitems; i++)
                {
                    if(x->f_items[i])
                    {
                        egraphics_circle(g, rect->width * 0.5, (i + 0.5) * ratio, rect->width * 0.35);
                        egraphics_fill(g);
                    }
                }
            }
        }
        
        ebox_end_layer((t_ebox*)x, gensym("items_layer"));
	}
	ebox_paint_layer((t_ebox *)x, gensym("items_layer"), 0., 0.);
}