Example #1
0
void Widget_ColorEdit::setHVSColor(synfig::Color color)
{
	Gdk::Color gtkColor;
	float r = hvs_gamma.r_F32_to_F32(CLIP_VALUE(color.get_r(),0.0,1.0));
	float g = hvs_gamma.g_F32_to_F32(CLIP_VALUE(color.get_g(),0.0,1.0));
	float b = hvs_gamma.b_F32_to_F32(CLIP_VALUE(color.get_b(),0.0,1.0));
	gtkColor.set_red((unsigned short)(r * USHRT_MAX));
	gtkColor.set_green((unsigned short)(g * USHRT_MAX));
	gtkColor.set_blue((unsigned short)(b * USHRT_MAX));
	colorHVSChanged = true;
	hvsColorWidget->set_previous_color (gtkColor); //We can't use it there, cause color changes in realtime.
	hvsColorWidget->set_current_color (gtkColor);
	colorHVSChanged = false;
}
Example #2
0
void
Widget_Color::set_value(const synfig::Color &data)
{
	assert(data.is_valid());
	color=data;
	queue_draw();
}
Example #3
0
synfig::Color
studio::colorconv_apply_gamma(const synfig::Color &c_)
{
	const synfig::Color c(c_.clamped());
	return synfig::Color(
		App::gamma.r_F32_to_F32(c.get_r()),
		App::gamma.g_F32_to_F32(c.get_g()),
		App::gamma.b_F32_to_F32(c.get_b()),
		c.get_a() );
}
Example #4
0
void
Widget_ColorEdit::set_value(const synfig::Color &data)
{
	assert(data.is_valid());
	hold_signals=true;
	clamp_=false;

	color=data;

	if(use_colorspace_gamma())
	{
		R_adjustment->set_value(gamma_in(color.get_r())*100);
		G_adjustment->set_value(gamma_in(color.get_g())*100);
		B_adjustment->set_value(gamma_in(color.get_b())*100);
	}
	else
	{
		R_adjustment->set_value(color.get_r()*100);
		G_adjustment->set_value(color.get_g()*100);
		B_adjustment->set_value(color.get_b()*100);
	}
	A_adjustment->set_value(color.get_a()*100);

	slider_R->set_color(color);
	slider_G->set_color(color);
	slider_B->set_color(color);
	slider_Y->set_color(color);
	slider_U->set_color(color);
	slider_V->set_color(color);
	slider_HUE->set_color(color);
	slider_SAT->set_color(color);
	slider_A->set_color(color);
	hex_color->set_text(color.get_hex());
	widget_color.set_value(color);
	setHVSColor(color);

	hold_signals=false;
}
Example #5
0
void
studio::render_color_to_window(const Cairo::RefPtr<Cairo::Context> &cr, const Gdk::Rectangle &ca, const synfig::Color &color)
{
	const int height(ca.get_height());
	const int width(ca.get_width());

	const int square_size(height/2);

	if(color.get_alpha()!=1.0)
	{
		// In this case we need to render the alpha squares

		const Color bg1(
			colorconv_apply_gamma(
				Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped() ));
		const Color bg2(
			colorconv_apply_gamma(
				Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped() ));

		bool toggle(false);
		for(int i=0;i<width;i+=square_size)
		{
			const int square_width(min(square_size,width-i));

			if(toggle)
			{
		        cr->set_source_rgb(bg1.get_r(), bg1.get_g(), bg1.get_b());
		        cr->rectangle(ca.get_x()+i, ca.get_y(), square_width, square_size);
		        cr->fill();

		        cr->set_source_rgb(bg2.get_r(), bg2.get_g(), bg2.get_b());
		        cr->rectangle(ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
		        cr->fill();
				toggle=false;
			}
			else
			{
		        cr->set_source_rgb(bg2.get_r(), bg2.get_g(), bg2.get_b());
		        cr->rectangle(ca.get_x()+i, ca.get_y(), square_width, square_size);
		        cr->fill();

		        cr->set_source_rgb(bg1.get_r(), bg1.get_g(), bg1.get_b());
		        cr->rectangle(ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
		        cr->fill();
				toggle=true;
			}
		}
	}
	else
	{
		synfig::Color c = colorconv_apply_gamma(color);
        cr->set_source_rgb(c.get_r(), c.get_g(), c.get_b());
        cr->rectangle(ca.get_x(), ca.get_y(), width-1, height-1);
        cr->fill();
	}

	cr->set_source_rgb(1.0, 1.0, 1.0);
    cr->rectangle(ca.get_x()+1, ca.get_y()+1, width-3, height-3);
    cr->stroke();

    cr->set_source_rgb(0.0, 0.0, 0.0);
    cr->rectangle(ca.get_x(), ca.get_y(), width-1, height-1);
    cr->stroke();
}
Example #6
0
void
ColorSlider::slider_color_TYPE_V(synfig::Color &color, float amount) { color.set_v(amount-0.5f); }
Example #7
0
void
ColorSlider::slider_color_TYPE_Y(synfig::Color &color, float amount) { color.set_y(amount); }
Example #8
0
void
ColorSlider::slider_color_TYPE_SAT(synfig::Color &color, float amount) { color.set_s(amount*0.5f); }
Example #9
0
void
ColorSlider::slider_color_TYPE_HUE(synfig::Color &color, float amount) { color.set_uv_angle(Angle::rot(amount)); }