Exemplo n.º 1
0
OXPicture FX::gradient(const QPoint c1, int r1, const QPoint c2, int r2,
                             const ColorArray &colors,
                             const PointArray &stops) {
   XRadialGradient rg = {
      { c1.x() << 16, c1.y() << 16, r1 << 16 },
      { c2.x() << 16, c2.y() << 16, r2 << 16 } };
   QVarLengthArray<XRenderColor> cs(colors.size());
   for (int i = 0; i < colors.size(); ++i)
      setColor(cs[i], colors.at(i));
   XFixed *stps;
   if (stops.size() < 2) {
      stps = new XFixed[2];
      stps[0] = 0; stps[1] = (1<<16);
   }
   else {
      int d = ((int)(sqrt(pow(c2.x()-c1.x(),2)+pow(c2.y()-c1.y(),2)))) << 16;
      stps = new XFixed[stops.size()];
      for (int i = 0; i < stops.size(); ++i)
      {
         if (stops.at(i) < 0) continue;
         if (stops.at(i) > 1) break;
         stps[i] = stops.at(i)*d;
      }
   }
   XFlush (dpy);
   OXPicture lgp = XRenderCreateRadialGradient(dpy, &rg, stps, &cs[0],
                                               qMin(qMax(stops.size(),2),
                                                  colors.size()));
   delete[] stps;
   return lgp;
}
//----------------------------------------------------------------------------------------
// ConvertCMYKToRGBHex
//----------------------------------------------------------------------------------------
void
CZExpXMLExport_Colors::ConvertCMYKToRGBHex(
	const ColorArray &			inColorComponents,
	char *						oColorStr)
{
	ASSERT( inColorComponents.size() == 4 );

	if( inColorComponents.size() == 4 )
	{
		const PMReal & colorC = inColorComponents[0];
		const PMReal & colorM = inColorComponents[1];
		const PMReal & colorY = inColorComponents[2];
		const PMReal & colorK = inColorComponents[3];

		float colorR = ToFloat((1 - (colorC * (1 - colorK) + colorK)) * 255);
		float colorG = ToFloat((1 - (colorM * (1 - colorK) + colorK)) * 255);
		float colorB = ToFloat((1 - (colorY * (1 - colorK) + colorK)) * 255);

		unsigned char rInt = colorR;
		unsigned char gInt = colorG;
		unsigned char bInt = colorB;

		sprintf( oColorStr, "#%02x%02x%02x", rInt, gInt, bInt );
	}
}
Exemplo n.º 3
0
OXPicture FX::gradient(const QPoint start, const QPoint stop,
                             const ColorArray &colors,
                             const PointArray &stops) {
   XLinearGradient lg = {
      { start.x() << 16, start.y() << 16 },
      { stop.x() << 16, stop.y() << 16} };
   QVarLengthArray<XRenderColor> cs(colors.size());
   for (int i = 0; i < colors.size(); ++i)
      setColor(cs[i], colors.at(i));
   XFixed *stps;
   if (stops.size() < 2) {
      stps = new XFixed[2];
      stps[0] = 0; stps[1] = (1<<16);
   }
   else {
      int d = (1<<16);
      stps = new XFixed[stops.size()];
      for (int i = 0; i < stops.size(); ++i) {
         if (stops.at(i) < 0) continue;
         if (stops.at(i) > 1) break;
         stps[i] = stops.at(i)*d;
      }
   }
   XFlush (dpy);
   OXPicture lgp = XRenderCreateLinearGradient(dpy, &lg, stps, &cs[0],
                                               qMin(qMax(stops.size(),2),
                                                  colors.size()));
   delete[] stps;
   return lgp;
}
//----------------------------------------------------------------------------------------
// ConvertToRGBHex
//----------------------------------------------------------------------------------------
void
CZExpXMLExport_Colors::ConvertToCMYKHex(
	const ColorArray &			inColorComponents,
	char *						oColorStr)
{
	ASSERT( inColorComponents.size() == 4 );

	if( inColorComponents.size() == 4 )
	{
		const PMReal & cValue = inColorComponents[0];
		const PMReal & mValue = inColorComponents[1];
		const PMReal & yValue = inColorComponents[2];
		const PMReal & kValue = inColorComponents[3];

		unsigned char cInt = ToInt16(cValue * 100);
		unsigned char mInt = ToInt16(mValue * 100);
		unsigned char yInt = ToInt16(yValue * 100);
		unsigned char kInt = ToInt16(kValue * 100);

		sprintf( oColorStr, "#%02x%02x%02x%02x", cInt, mInt, yInt, kInt );
	}
}
//----------------------------------------------------------------------------------------
// ConvertToRGBHex
//----------------------------------------------------------------------------------------
void
CZExpXMLExport_Colors::ConvertToRGBHex(
	const ColorArray &			inColorComponents,
	char *						oColorStr)
{
	ASSERT( inColorComponents.size() == 3 );

	const PMReal & rValue = inColorComponents[0];
	const PMReal & gValue = inColorComponents[1];
	const PMReal & bValue = inColorComponents[2];

	unsigned char rInt = ToInt16(rValue * 255);
	unsigned char gInt = ToInt16(gValue * 255);
	unsigned char bInt = ToInt16(bValue * 255);

	sprintf( oColorStr, "#%02x%02x%02x", rInt, gInt, bInt );
}
Exemplo n.º 6
0
Arquivo: Main.cpp Projeto: copyliu/gac
	IniColorizer()
	{
		text::ColorEntry entry=win7::Win7GetTextBoxTextColor();
		colors.Resize(5);
		
		// text color
		colors[NORMAL_COLOR]=entry;

		// section color
		entry.normal.text=Color(163, 21, 21);
		colors[SECTION_COLOR]=entry;

		// attribute color
		entry.normal.text=Color(255, 0, 0);
		colors[ATTRIBUTE_COLOR]=entry;

		// operator color
		entry.normal.text=Color(0, 0, 255);
		colors[OPERATOR_COLOR]=entry;

		// operator color
		entry.normal.text=Color(24, 128, 24);
		colors[COMMENT_COLOR]=entry;
	}
//----------------------------------------------------------------------------------------
// AddColorInfo
//----------------------------------------------------------------------------------------
void
CZExpXMLExport_Colors::AddColorInfo(
	IXMLOutStream *				ioStream,
	const IColorData *			inColorInfo,
	IUIColorUtils *				inColorUtils)
{
	LogFunctionEnterExit;

	WideString elementStr( STRXMLTag_ColorInfo );

	IXMLOutStream::Attribute attr;
	IXMLOutStream::AttributeList attrList;

	InterfacePtr<const IRenderingObject> renderingObject( inColorInfo, UseDefaultIID() );
	ASSERT( renderingObject );

	attr.fName.SetX16String( TOWSTRING(STRXMLAttr_ID) );
	CZExpXMLAttrUtils::SetValue_UID( attr, ::GetUID(inColorInfo) );
	attrList.push_back( attr );

	const PMString & swatchName = renderingObject->GetSwatchName();
	attr.fName.SetX16String( TOWSTRING(STRXMLAttr_Name) );
	attr.fValue = WideString( swatchName );

	attrList.push_back( attr );

	int32 colorSpace = inColorInfo->GetColorSpace();
	
	ColorArray rgbValues = inColorInfo->GetColorData();//inColorUtils->GetRGBColorValue( ::GetDataBase( inColorInfo), ::GetUID( inColorInfo ) );

	int32 colorCmpCount = rgbValues.size();
	char colorStr[12] = {0};
	if( colorSpace == kPMCsCalRGB || colorSpace == kPMCsLab )
		ConvertToRGBHex( rgbValues, colorStr );
	else if( colorSpace == kPMCsCalCMYK )
	{
		colorSpace = kPMCsCalRGB;
		ConvertCMYKToRGBHex( rgbValues, colorStr );//ConvertToCMYKHex( rgbValues, colorStr );
	}

	attr.fName.SetX16String( TOWSTRING("colorSpace") );
	if( colorSpace == kPMCsCalRGB )
		attr.fValue.SetX16String( TOWSTRING("RGB") );
	else if( colorSpace == kPMCsCalCMYK )
		attr.fValue.SetX16String( TOWSTRING("CMYK") );
	else if( colorSpace == kPMCsLab )
		attr.fValue.SetX16String( TOWSTRING("LAB") );
	else if( colorSpace == kPMCsDeviceN )
		attr.fValue.SetX16String( TOWSTRING("DeviceN") );
	else
		attr.fValue.SetX16String( TOWSTRING("Unknown") );

	//CZExpXMLAttrUtils::SetValue_Int( attr, colorSpace );
	attrList.push_back( attr );
	
	IZPLog_Str( thisFileLA, enLT_DebugInfo, "Color Swatch Name: %s, color space :%d, colorValue :%s", swatchName.GrabCString(), colorSpace, colorStr );
	if( colorStr[0] )
	{
		attr.fName.SetX16String( TOWSTRING(STRXMLAttr_Value) );
		attr.fValue = WideString( colorStr );
		attrList.push_back( attr );
	}
	
	ioStream->IndentLevel(kTrue);
	ioStream->PushWithAttributes( elementStr, attrList, kTrue );
	StXMLPopper autoPopParaStyle( ioStream );
}
Exemplo n.º 8
0
		// Helper method to render using the provided display
		inline void Draw(IDisplay& display)
		{
			display.DrawModel(Positions.GetElements(), Normals.GetElements(), Colors.GetElements(), TexCoords.GetElements(), Indices, true);
		}