Skip navigation
Currently Being Moderated

How to create a custom color?

Apr 16, 2012 12:21 PM

Hi,

 

I know how to create a custom color in CMYK mode and in RGB mode but not in gray level mode.

 

If tried this without any success.

 

AICustomColor MyColor;

AICustomColorHandle MyColorHandle;

AISwatchRef MyColorRef;

AIColor MyAIColor;

 

//Name of the swatch color.

const char *SwatchColorName="MYCOLOR";

ai::UnicodeString SwatchUnicodeColorName=ai::UnicodeString(SwatchColorName);

 

//For a CMYK custom color.

//MyColor.kind=kCustomFourColor;

//MyColor.c.f.cyan=0.3;

//MyColor.c.f.magenta=0.2;

//MyColor.c.f.yellow=0.4;

//MyColor.c.f.black=0.2;

 

//For a RGB custom color.

//MyColor.kind=kCustomThreeColor;

//MyColor.c.rgb.red=220;

//MyColor.c.rgb.green=104;

//MyColor.c.rgb.blue=200;

 

//For a gray level custom color.

MyColor.c.gray.gray=0.5;

 

//To create the custom color.

error=sAICustomColor->NewCustomColor(&MyColor, NomCouleurTraitsUnicode, & MyColorHandle);

 

//NULL to insert the new swatch in the current document's swatch list

//-1 to insert the new swatch at the end of the general swatches group

MyColorRef =sAISwatchList->InsertNthSwatch(NULL, -1);

 

//To set the color definition for the swatch.

MyAIColor.kind=kCustomColor;

MyAIColor.c.c.color=HandleMaCouleurPersoTraits;

MyAIColor.c.c.tint=0.0;

error=sAISwatchList->SetAIColor(MyColorRef, &CouleurTraits);

 

//To set the name of the swatch.

error=sAISwatchList->SetSwatchName(MyColorRef, SwatchUnicodeColorName);

 

 

If somebody knows how to create a gray level custom color, it would be great.

 

Any help would be appreciated, thank you in advance.

 

JLG.

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points