コード例 #1
0
ファイル: egraphics.c プロジェクト: CICM/CicmWrapper
void egraphics_arc_oval(t_elayer *g, float xc, float yc, float radiusx, float radiusy, float angle1, float angle2)
{
    if(g->e_state == EGRAPHICS_OPEN)
    {
        if(g->e_new_objects.e_points == NULL)
            g->e_new_objects.e_points   = (t_pt *)malloc(3 * sizeof(t_pt));
        else
            g->e_new_objects.e_points   = (t_pt *)realloc(g->e_new_objects.e_points , 3 * sizeof(t_pt));
        if(g->e_new_objects.e_points)
        {
            g->e_new_objects.e_type         = E_GOBJ_ARC;
            g->e_new_objects.e_points[0].x  = xc;
            g->e_new_objects.e_points[0].y  = yc;
            g->e_new_objects.e_points[1].x  = xc + (float)pd_abscissa(radiusx, angle1);
            g->e_new_objects.e_points[1].y  = yc + (float)pd_ordinate(radiusy, angle1);
            g->e_new_objects.e_points[2].x  = angle2 - angle1;
            g->e_new_objects.e_points[2].y  = angle2 - angle1;
            g->e_new_objects.e_npoints      = 3;
        }
        else
        {
            g->e_new_objects.e_type         = E_GOBJ_INVALID;
        }
    }
}
コード例 #2
0
ファイル: c.knob.cpp プロジェクト: EQ4/CreamLibrary
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.);

}
コード例 #3
0
ファイル: c.knob.cpp プロジェクト: rvega/CicmWrapper
void draw_needle(t_knob *x, t_object *view, t_rect *rect)
{
    float size, abs, ord, pimul, pimin;
    t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("needle_layer"), rect->width, rect->height);
    
    if (g)
	{
        size = rect->width * 0.5;
        if(x->f_endless)
        {
            pimul = EPD_2PI;
            pimin = EPD_PI2;
        }
        else
        {
            pimul = 1.5 * EPD_PI;
            if (x->f_min < x->f_max)
                pimin = 1.5 * EPD_PI2;
            else
                pimin = 0.5 * EPD_PI2;
        }
        if(x->f_min < x->f_max)
        {
            abs =  pd_abscissa(size * 0.9 - 1, (x->f_value - x->f_min) / (x->f_max - x->f_min) * pimul + pimin);
            ord =  pd_ordinate(size * 0.9 - 1, (x->f_value - x->f_min) / (x->f_max - x->f_min) * pimul + pimin);
        }
        else
        {
            abs =  pd_abscissa(size * 0.9 - 1, -(x->f_value - x->f_max) / (x->f_min - x->f_max) * pimul + pimin);
            ord =  pd_ordinate(size * 0.9 - 1, -(x->f_value - x->f_max) / (x->f_min - x->f_max) * pimul + pimin);
            
        }
        egraphics_set_line_width(g, 2);
        egraphics_set_color_rgba(g, &x->f_color_needle);
        egraphics_line_fast(g, rect->width * 0.5, rect->height * 0.5, abs + rect->width * 0.5, ord + rect->height * 0.5);
        ebox_end_layer((t_ebox*)x, gensym("needle_layer"));
    }
   
    ebox_paint_layer((t_ebox *)x, gensym("needle_layer"), 0., 0.);

}
コード例 #4
0
void draw_leds(t_hoa_meter *x, t_object *view, t_rect *rect)
{
    int i;
    float j, h, dB;
    float angle_start, angle, angle_end, radius, center_x, center_y;
    float led_width = 0.49 * rect->width / 18.;
    
    t_rgba black = rgba_addContrast(x->f_color_bg, -0.14);
	t_elayer *g = ebox_start_layer((t_ebox *)x,  hoa_sym_leds_layer, rect->width, rect->height);
    
	if (g)
	{
        h = led_width * 17.;
        for(i = 0; i < x->f_meter->getNumberOfChannels(); i++)
        {
            if(x->f_clockwise != hoa_sym_clockwise)
                angle   = x->f_meter->getChannelAzimuthMapped(i) + HOA_PI2;
            else
                angle   = -x->f_meter->getChannelAzimuthMapped(i) + HOA_PI2;
            
            center_x    = pd_abscissa(x->f_radius - h, angle);
            center_y    = -pd_ordinate(x->f_radius - h, angle);
            
            angle_start = angle - x->f_meter->getChannelWidth(i) * 0.5f;
            angle_end   = angle + x->f_meter->getChannelWidth(i) * 0.5f;
            for(j = 11, dB = -34.5; j > -1; j--, dB += 3.)
            {
                radius    = (j + 5.) * led_width;
                
                if(x->f_meter->getChannelEnergy(i) > dB)
                {
                    if(j > 8)
                        egraphics_set_color_rgba(g, &x->f_color_cold_signal);
                    else if(j > 5)
                        egraphics_set_color_rgba(g, &x->f_color_tepid_signal);
                    else if(j > 2)
                        egraphics_set_color_rgba(g, &x->f_color_warm_signal);
                    else
                        egraphics_set_color_rgba(g, &x->f_color_hot_signal);
                    
                    egraphics_set_line_width(g, led_width - pd_clip_min(360. / rect->width, 2.));
                    egraphics_arc(g, center_x + rect->width * 0.5f, center_y + rect->width * 0.5f, radius, angle_start, angle_end);
                    egraphics_stroke(g);
                }
                else if(j != -1)
                {
                    egraphics_set_color_rgba(g, &black);
                    egraphics_set_line_width(g, led_width - pd_clip_min(360. / rect->width, 2.));
                    egraphics_arc(g, center_x + rect->width * 0.5f, center_y + rect->width * 0.5f, radius,  angle_start, angle_end);
                    egraphics_stroke(g);
                }
            }
            if(x->f_over_leds[i])
            {
                radius    = (4.) * led_width;
                egraphics_set_color_rgba(g, &x->f_color_over_signal);
                egraphics_set_line_width(g, led_width - pd_clip_min(360. / rect->width, 2.));
                egraphics_arc(g, center_x + rect->width * 0.5f, center_y + rect->width * 0.5f, radius, angle_start, angle_end);
                egraphics_stroke(g);
            }
        }
		ebox_end_layer((t_ebox*)x,  hoa_sym_leds_layer);
	}
	ebox_paint_layer((t_ebox *)x, hoa_sym_leds_layer, 0., 0.);
}