void draw_background(t_hoa_scope *x, t_object *view, t_rect *rect)
{
    t_matrix transform;
    t_rgba black = rgba_addContrast(x->f_color_bg, -contrast_black);
    t_rgba white = rgba_addContrast(x->f_color_bg, contrast_white);

    t_elayer *g = ebox_start_layer((t_ebox *)x, hoa_sym_background_layer, rect->width, rect->height);

    if (g)
    {
        egraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center);
        egraphics_set_matrix(g, &transform);

        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;

            egraphics_move_to(g, x1, y1);
            egraphics_line_to(g, x2, y2);
            egraphics_set_line_width(g, 3);
            egraphics_set_color_rgba(g, &white);
            egraphics_stroke(g);
            egraphics_set_color_rgba(g, &black);
            egraphics_set_line_width(g, 1);
            egraphics_stroke(g);
        }

        for(int i = 5; i > 0; i--)
        {
            egraphics_set_line_width(g, 3);
            egraphics_set_color_rgba(g, &white);
            egraphics_arc(g, 0, 0, (double)i * 0.2 * x->f_radius,  0., HOA_2PI);
            egraphics_stroke(g);
            egraphics_set_line_width(g, 1);
            egraphics_set_color_rgba(g, &black);
            egraphics_stroke(g);
        }

        ebox_end_layer((t_ebox*)x, hoa_sym_background_layer);
    }
    ebox_paint_layer((t_ebox *)x, hoa_sym_background_layer, 0., 0.);
}
Esempio n. 2
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. 3
0
void hoa_space_draw_center(t_hoa_space *x, t_object *view, t_rect *rect)
{
    t_rgba black, white;
    
    black = rgba_addContrast(x->f_color_background, -0.14);
    white = rgba_addContrast(x->f_color_background, 0.06);
    
    t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("center_layer"), rect->width, rect->height);
	
    if (g)
	{
        egraphics_set_line_width(g, 1);
        egraphics_set_color_rgba(g, &black);
        egraphics_arc(g, long(x->f_center)-0.5, long(x->f_center)-0.5, x->f_radius_circle,  0., CICM_2PI);
        egraphics_stroke(g);
        egraphics_arc(g, long(x->f_center), long(x->f_center), x->f_radius_circle,  0., CICM_2PI);
        egraphics_stroke(g);
        egraphics_set_color_rgba(g, &x->f_color_background);
        egraphics_arc(g, long(x->f_center)+0.5, long(x->f_center)+0.5, x->f_radius_circle,  0., CICM_2PI);
        egraphics_fill(g);
        ebox_end_layer((t_ebox*)x, gensym("center_layer"));
	}
	ebox_paint_layer((t_ebox *)x, gensym("center_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 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_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.);
}
void draw_background(t_hoa_meter *x,  t_object *view, t_rect *rect)
{
	int i;
    float coso, sino, angle, x1, y1, x2, y2;
    t_rgba black, white;
	t_matrix transform;
	t_elayer *g = ebox_start_layer((t_ebox *)x, hoa_sym_background_layer, rect->width, rect->height);
    
    black = rgba_addContrast(x->f_color_bg, -0.14);
    white = rgba_addContrast(x->f_color_bg, 0.06);
    
	if (g)
	{
        egraphics_matrix_init(&transform, 1, 0, 0, -1, rect->width * .5, rect->width * .5);
        egraphics_set_matrix(g, &transform);
       
        egraphics_rotate(g, -HOA_PI2);
        
		egraphics_set_line_width(g, 1.);

		egraphics_set_color_rgba(g, &x->f_color_bg);
		egraphics_arc(g, 0.f, 0.f, x->f_radius, 0., HOA_2PI);
		egraphics_fill(g);

		egraphics_set_color_rgba(g, &x->f_color_bg);
		egraphics_arc(g, 0.f, 0.f, x->f_radius_center, 0., HOA_2PI);
		egraphics_fill(g);
		
        egraphics_set_color_rgba(g, &white);
        egraphics_set_line_width(g, 1.f);
        egraphics_arc(g, 1, 1, x->f_radius,  0., HOA_2PI);
        egraphics_stroke(g);
        egraphics_arc(g, 1, 1, x->f_radius_center,  0., HOA_2PI);
        egraphics_stroke(g);
        
        egraphics_set_color_rgba(g, &black);
        egraphics_set_line_width(g, 1.f);
        egraphics_arc(g, 0.f, 0.f, x->f_radius,  0., HOA_2PI);
        egraphics_stroke(g);
        egraphics_arc(g, 0.f, 0.f, x->f_radius_center,  0., HOA_2PI);
        egraphics_stroke(g);
        
        if(x->f_meter->getNumberOfChannels() != 1)
        {
            for(i = 0; i < x->f_meter->getNumberOfChannels(); i++)
            {
                angle = x->f_meter->getChannelAzimuthMapped(i) - x->f_meter->getChannelWidth(i) * 0.5f;
                if(x->f_clockwise == hoa_sym_clockwise)
                    angle = -angle;
                egraphics_set_line_width(g, 1.f);
               
                coso = cosf(angle);
                sino = sinf(angle);
                x1 = x->f_radius_center * coso;
                y1 = x->f_radius_center * sino;
                x2 = x->f_radius * coso;
                y2 = x->f_radius * sino;
                if(isInsideRad(angle, HOA_PI4, HOA_PI + HOA_PI4))
                {
                    egraphics_move_to(g, x1 - 0.5, y1 - 0.5);
                    egraphics_line_to(g, x2 - 0.5, y2 - 0.5);
                }
                else
                {
                    egraphics_move_to(g, x1 + 0.5, y1 + 0.5);
                    egraphics_line_to(g, x2 + 0.5, y2 + 0.5);
                }
                
                egraphics_set_color_rgba(g, &white);
                egraphics_stroke(g);
                
                
				egraphics_move_to(g, x1, y1);
				egraphics_line_to(g, x2, y2);
                
                egraphics_set_color_rgba(g, &black);
				egraphics_stroke(g);
			}
        }
		ebox_end_layer((t_ebox*)x, hoa_sym_background_layer);
	}
	ebox_paint_layer((t_ebox *)x, hoa_sym_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_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.);
}
Esempio n. 10
0
void hoa_space_draw_background(t_hoa_space *x, t_object *view, t_rect *rect)
{
    t_matrix transform;
    t_rgba black, white;
    
    black = rgba_addContrast(x->f_color_background, -0.14);
    white = rgba_addContrast(x->f_color_background, 0.06);

    t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height);
	
    if (g)
	{
        egraphics_set_line_width(g, 1);
        egraphics_set_color_rgba(g, &white);
        egraphics_arc(g, long(x->f_center)-0.5, long(x->f_center)-0.5, x->f_radius_global,  0., CICM_2PI);
        egraphics_fill(g);
        
        /* Circles */
		for(int i = 5; i > 0; i--)
		{
            //inner shadow
            egraphics_set_color_rgba(g, &black);
            egraphics_arc(g, long(x->f_center)-0.5, long(x->f_center)-0.5, (double)i * x->f_radius_circle,  0., CICM_2PI);
            egraphics_stroke(g);

            egraphics_set_color_rgba(g, &x->f_color_background);
            egraphics_arc(g, long(x->f_center)+0.5, long(x->f_center)+0.5, (double)i * x->f_radius_circle,  0., CICM_2PI);
            egraphics_stroke(g);
		}
        
        egraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center);
		egraphics_set_matrix(g, &transform);
		double coso, sino, angle, x1, y1, x2, y2;
        
		for(int i = 0; i < x->f_number_of_microphones; i++)
		{
            egraphics_set_color_rgba(g, &black);
            angle = ((double)i / x->f_number_of_microphones * CICM_2PI ) - (0.5 / x->f_number_of_microphones * CICM_2PI);
            coso = cos(angle);
            sino = sin(angle);
            x1 = x->f_radius_circle * coso;
            y1 = x->f_radius_circle * sino;
            x2 = x->f_radius_global * coso;
            y2 = x->f_radius_global * sino;
            
            if(!Tools::isInsideDeg(angle / CICM_2PI * 360., 45, 225))
            {
                egraphics_move_to(g, x1 - 0.5, y1 - 0.5);
                egraphics_line_to(g, x2 - 0.5, y2 - 0.5);
            }
            else
            {
                egraphics_move_to(g, x1 + 0.5, y1 + 0.5);
                egraphics_line_to(g, x2 + 0.5, y2 + 0.5);
            }
            egraphics_stroke(g);
            
            egraphics_set_color_rgba(g, &x->f_color_background);
            egraphics_move_to(g, x1, y1);
            egraphics_line_to(g, x2, y2);
            egraphics_stroke(g);
			
		}
        
		ebox_end_layer((t_ebox*)x,  gensym("background_layer"));
	}
	ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.);
}