Пример #1
0
//----------------------------------------------------------------------------------------------------
void UISearchTextField::drawClearMark (CDrawContext* context) const
{
	if (getText ().empty ())
		return;

	SharedPointer<CGraphicsPath> path = owned (context->createGraphicsPath ());
	if (path == 0)
		return;

	CRect r = getClearMarkRect ();
	CColor color (fontColor);
	color.alpha /= 2;
	context->setFillColor (color);
	context->setDrawMode (kAntiAliasing);
	context->drawEllipse (r, kDrawFilled);
	double h,s,v;
	color.toHSV (h, s, v);
	v = 1. - v;
	color.fromHSV (h, s, v);
	context->setFrameColor (color);
	context->setLineWidth (2.);
	r.inset (r.getWidth () / (M_PI * 2.) + 1, r.getHeight () / (M_PI * 2.) + 1);
	path->beginSubpath (r.getTopLeft ());
	path->addLine (r.getBottomRight ());
	path->beginSubpath (r.getBottomLeft ());
	path->addLine (r.getTopRight ());
	context->setDrawMode (kAntiAliasing|kNonIntegralMode);
	context->drawGraphicsPath (path, CDrawContext::kPathStroked);
}
Пример #2
0
__attribute__((__constructor__)) void testHSVtoRGBAndBack ()
{
	CColor color (10, 10, 255, 255);
	CColor color2 = color;
	double h,s,v;
	color.toHSV (h,s,v);
	double th,ts,tv;
	for (double i = 0; i < 360; i+= 0.01)
	{
		color.fromHSV (i, s, v);
		color.toHSV (th, ts, tv);
		color2.fromHSV (th, ts, tv);
		if (color != color2)
		{
			DebugPrint ("issue\n");
		}
		color.toHSL (th, ts, tv);
		color2.fromHSL (th, ts, tv);
		if (color != color2)
		{
			DebugPrint ("issue\n");
		}
	}
	for (double i = 0.; i < 1.; i += 0.0001)
	{
		color.fromHSV (h, i, v);
		color.toHSV (th, ts, tv);
		color2.fromHSV (th, ts, tv);
		if (color != color2)
		{
			DebugPrint ("issue\n");
		}
		color.fromHSV (h, s, i);
		color.toHSV (th, ts, tv);
		color2.fromHSV (th, ts, tv);
		if (color != color2)
		{
			DebugPrint ("issue\n");
		}
	}
}