Beispiel #1
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);
}
Beispiel #2
0
void draw_leds(t_meter *x, t_object *view, t_rect *rect)
{
	float i;
	float dB;
	t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("leds_layer"), rect->width, rect->height);
	
	if (g)
	{
        float led_height = rect->height / 13.f;
        float led_width = rect->width / 13.f;
        for(i = 12, dB = -39; i > 0; i--, dB += 3.f)
        {
            if(x->f_peak_value >= dB)
            {
                if(i > 9)
                    egraphics_set_color_rgba(g, &x->f_color_signal_cold);
                else if(i > 6)
                    egraphics_set_color_rgba(g, &x->f_color_signal_tepid);
                else if(i > 3)
                    egraphics_set_color_rgba(g, &x->f_color_signal_warm);
                else if(i > 0)
                    egraphics_set_color_rgba(g, &x->f_color_signal_hot);
                if(!x->f_direction)
                {
                    if(i > 11)
                        egraphics_rectangle_rounded(g, 0, i * led_height + 1, rect->width, led_height, 1.f);
                    else
                        egraphics_rectangle_rounded(g, 0, i * led_height + 1, rect->width, led_height - 1, 1.f);
                }
                else
                {
                    if(i > 11)
                        egraphics_rectangle_rounded(g, 0, 0, led_width, rect->height, 1.);
                    else
                        egraphics_rectangle_rounded(g, (12 - i) * led_width + 1, 0, led_width - 1, rect->height, 1.);
                }
                egraphics_fill(g);
            }
        }
        if(x->f_over_led_preserved)
        {
            egraphics_set_color_rgba(g, &x->f_color_signal_over);
            if(!x->f_direction)
            {
                egraphics_rectangle_rounded(g, 0, 0, rect->width, led_height, 1.f);
            }
            else
            {
                egraphics_rectangle_rounded(g, 12 * led_width + 1, 0, led_width,  rect->height, 1.);

            }
            
            egraphics_fill(g);
        }
		ebox_end_layer((t_ebox *)x, gensym("leds_layer"));
	}
	ebox_paint_layer((t_ebox *)x, gensym("leds_layer"), 0., 0.);
}