Color palettes in CorelDRAW, Corel DESIGNER and Corel PHOTO-PAINT are implemented using external files that hold all the color information for the palette. Prior to version X5, these files were stored in a proprietary binary file format that ended with a .cpl extension. In X5, they were changed to an XML format in order to make them more readable and extensible. While you can create a palette entirely through the user interface of CorelDRAW, Corel DESIGNER or Corel PHOTO-PAINT, there are scenarios where you may want to create one from existing data from a spreadsheet such as a vendor color swatch book data, thread color data, etc. This article describes the new format and gives some information on how you can create one yourself.
The color palette file is a completely standalone XML file. This allows it to be easily added to the appropriate folder to be used in CorelDRAW, Corel DESIGNER or Corel PHOTO-PAINT without any other changes. The applications look in two main locations for the palettes: the installed subfolder called Color\Palettes and the user's My Palettes folder in their Documents folder.
Palettes from the install folder cannot be changed by the user from within the application and appear under the "Palette Libraries" section in the Color Palette Manager docker. If you wish to place your palette here, you need to have the appropriate rights to modify this folder.
User palettes from the My Palettes folder are modifiable by the user and show up in the "My Palettes" section in the Color Palette Manager docker. To help you get acquainted with the new file format, you may wish to browse through the installed palettes and see how they are structured. Double clicking on the XML file should open in the default application (like Internet Explorer) where you can view it.
The next section describes the new format in detail. If you want to get right to creating your own palette from existing data, you can skip to Creating a Color Palette From Existing Data.
The XML format has a root palette element that contains all the data. On the palette element, there are attributes that describe the palette itself, such as its name, GUID identifier, etc. Under this element there are three main sub elements: colors, colorspaces and localization.
The colors node define the actual color swatches that appear in the palette. The colorspaces node define the various color space models that the colors can use. Supporting translated text names is done through the use of the localization node. The file snipped below gives an example of this structure.
<? version="1.0" ?> <palette name="Example Custom Palette" guid="ec120aef-24cf-42dd-ad25-491ea640e171"> <colors> ... </colors> <colorspaces> ... </colorspaces> <localization> ... </localization> </palette>
The palette element can have the following attributes:
The guid attribute defines the globally unique identifier that identifies this palette. It must be different for each palette. You can create a GUID using a 3rd-party tool, or website like http://www.guidgenerator.com/.
As the name suggests, the name attribute is the display name for the palette. If you want to have this palette display a name in the application's localized language, then you can use the resid attribute instead. This takes a GUID for a value and uses it to lookup in the localization section for the actual text to display. This will be discussed more when we get to the localization section.
The prefix attribute is used if the color names all have a common prefix that you want to allow the user to not have to type in the search color dropdown in the color dialog. For example, if all colors begin with a company name, setting this as the prefix means the user won't need to type it each time they do a search.
Finally, the locked attribute indicates whether or not the palette is locked to user changes. If the palette is stored in the installed folder, then this attribute should be set to true since the palette cannot be changed anyways. If it is in the user folder, then it gives you the flexibility to enable/disable edits.
Here is an example palette element with its attributes:
<palette name="Example Custom Palette" guid="ec120aef-24cf-42dd-ad25-491ea640e171" prefix="ACME" locked="true">
The colors element is the main section that defines all the color swatches that are displayed on the palette. The layout of the colors in the file can be done in two different ways: place all colors in a single page element or group them into multiple page elements. The later would be used to correspond to actual vendor swatch book pages.
If all the colors are listed on one page element you may wish to assign a width which would break up the palette into rows accordingly when the palette is displayed in the color dialog. This can be done by setting the width attribute on the page element. The default width if it is not set is 8 swatches per row.
If the colors are broken up into several pages then each page is displayed as a row in the color dialog. The advantage of doing it this way is that individual pages can have different number of colors to match the same layout of a swatch book of colors.
The example below shows all the colors listed on a single page with default width of eight swatches per row in the color dialog:
<colors> <page> <color cs="CMYK" tints="0,0,0,1" /> <color cs="CMYK" tints="0,0,0,0.9" /> <color cs="CMYK" tints="0,0,0,0.8" /> <color cs="CMYK" tints="0,0,0,0.7" /> <color cs="CMYK" tints="0,0.6,1,0" /> <color cs="CMYK" tints="0,0.4,0.2,0" /> <color cs="CMYK" tints="0,0.2,0.2,0.6" /> <color cs="CMYK" tints="0.2,0.2,0,0" /> <color cs="CMYK" tints="0.4,0.4,0,0" /> ... </page> </colors>
Within the page element is a list of color elements where each element represents a color swatch displayed in the palette. The attributes of the color element are as follows:
The cs attribute defines the color space for the color. This can be any of the predefined color spaces or can refer to a custom color space that is defined in the color spaces section in the file. The predefined color spaces supported are the following: CMYK, CMY, RGB, sRGB, AdobeRGB, HSB, HLS, YIQ, LAB, Gray, Hexachrome or Registration.
In conjunction with the cs attribute is the tints attribute. This is a list of comma separated floating point values from 0.0 to 1.0 where each value represents the tint value for one of the channels in the color space. The number of tints required will vary depending on the color space used. CMYK, for example, needs four tints one for C, M, Y and K, whereas LAB only needs three. If the color space is a custom color space only one tint is required.
For example, the element below defines a CMYK color with tints C=0.2, M=0.4, Y=0.0, K=0.4:
<color cs="CMYK" tints="0.2,0.4,0,0.4"/>
Defining a color from the Gray color space only requires one tint, for example:
<color name="50% Black" cs="Gray" tints="0.50"/>
The next example shows how to define a color that uses a custom spot color space with the tint of that one channel set to 1.0.
<color cs="MySpotColor" tints="1.0"/>
Similar to the palette element, a color element can have a name attribute or resid attribute. The name attribute is the display name that is used for the color. If the resid attribute is defined it will lookup the appropriate name from the localization section for the current user language that the application is using. This will be discussed in more detail in the localization section.
As described above, colors defined in the palette each refer to a color space model that they are using. This can be one of the predefined color spaces (CMYK, CMY, RGB, sRGB, AdobeRGB, HSB, HLS, YIQ, LAB, Gray, Hexachrome or Registration) or a custom color space. If you want to define your own custom color space like a spot color for a particular ink or thread color then you can define it in the color spaces section of the palette. If all the colors in the palette can be described using one of the predefined color spaces then the color spaces element is not needed.
The colorspaces element has no attributes itself but is simply a collection of individual colour space elements. Each colour space element, cs, defines the color space using various predefined color space representations. The snippet below gives an example of a few of these color space elements.
<colorspaces> <cs name="MySpotColor1" fixedID="1"> <color cs="CMYK" tints="0,0,0.58,0"/> <color cs="LAB" tints="0.9227,0.480039215686275,0.714196078431373"/> <color cs="RGB" tints="0.968627450980392,0.92156862745098,0.490196078431373"/> </cs> <cs name="MySpotColor2" fixedID="2"> <color cs="CMYK" tints="0,0,0.7,0"/> <color cs="LAB" tints="0.9168,0.478470588235294,0.757450980392157"/> <color cs="RGB" tints="0.968627450980392,0.913725490196078,0.384313725490196"/> </cs> .... </colorspaces>
A color space element, identified by a unique name, is typically used for spot colors, though can be used for process colors if required. The definition holds all the various ways to describe the color using the predefined color space like RGB, CMYK, LAB, etc. The color space element has attributes that describe the color space as follows:
The name attribute defines the unique name for this color space. This is not a translatable name since it identifies the color space. Typically, it will be the unique spot color name from a particular vendor.
The fixedID is an integer that uniquely identifies this color in this palette. It is used when storing spot color in the CDR file format and is therefore required. Note: if colors are added later to the palette, it is important that the existing fixedIDs do not change as CDR files may still be referencing them.
By default if the process attribute is not set, the color space will be treated as a spot color space definition. If the attribute is set to true it treats it as a process color space.
Each color space will list one or more color definitions. These describe the color space under various color models. For example, the MySpotColor color space defined below is described using CMYK, LAB and RGB color models.
<cs name="MySpotColor" fixedID="1"> <color cs="CMYK" tints="0,0,0.58,0"/> <color cs="LAB" tints="0.9227,0.480039215686275,0.714196078431373"/> <color cs="RGB" tints="0.968627450980392,0.92156862745098,0.490196078431373"/> </cs>
These colors declare a color space model using the cs attribute. This color space must be from one of the predefined color spaces: CMYK, CMY, RGB, sRGB, AdobeRGB, HSB, HLS, YIQ, LAB, Gray, Hexachrome or Registration.
The other attribute for the color element is the tints attribute. As described earlier, this is a comma separated floating point series of 0.0 to 1.0 values representing all the channels for the particular color space. For example, if the color space is RGB, there will be three values one for R, G and B. If CMYK there will be four. The example above illustrates how to represent a spot color using three different color models: CMYK, LAB and RGB.
It may seem unnatural at first to set the channel values in a 0.0 to 1.0 range since we are used to seeing values in other ranges. This approach, however, simplifies all representations to a consistent range without losing any accuracy. We'll discuss this more later when we discuss how to convert your data into this format.
The last main section in the color palette file is the localization element. This element is optional but gives you the ability to localize all text in the file like the palette name and color names that are displayed in your palette. Instead of defining a name attribute for those elements, you define a resid attribute which stands for resource identifier. This is a GUID (globally unique identifier) that will uniquely define the resource text. Just like the palette GUID, you can create one using the http://www.guidgenerator.com/ website.
The example below shows the palette element with the resid attribute defined:
<palette guid="cccd19cb-4675-4a5e-8bda-d0bbbaab8af0" resid="38ab6302-92be-4839-85fa-ca2cff330fa4">
The next example shows how to define the resid attribute for a color element.
<color cs="CMYK" tints="0.2,0.4,0,0.4" resid="d886df8f-3914-46ad-8d99-e03fc2cc8a93" />
The localization element, then declares an entry for each of these resources identified by their matching ID attribute. For example, the palette name and color name referenced above are defined below in different languages are supported.
<localization> <resource id="38ab6302-92be-4839-85fa-ca2cff330fa4"> <EN>CMYK palette</EN> <BR>Paleta CMYK padrão</BR> <CS>默认 CMYK 调色板</CS> <CT>預設 CMYK 色盤</CT> <CZ>Výchozí paleta CMYK</CZ> <DE>Standard-CMYK-Palette</DE> <ES>Paleta CMYK predeterminada</ES> <FR>Palette CMJN par défaut</FR> <IT>Tavolozza CMYK predefinita<IT> <JP>デフォルト CMYK パレット</JP> <KR>기본 CMYK 팔레트</KR> <MA>Alapértelmezett CMYK paletta</MA> <NL>Standaard-CMYK-palet</NL> <PL>Domyślna paleta CMYK</PL> <RU>Палитра CMYK по умолчанию</RU> <SU>CMYK-oletuspaletti</SU> <SV>Förvald CMYK-palett</SV> <TR>Varsayılan CMYK Paleti</TR> </resource> <resource id="d886df8f-3914-46ad-8d99-e03fc2cc8a93"> <EN>Grape</EN> <BR>Uva</BR> <CS>葡萄紫</CS> <CT>葡萄色</CT> <CZ>Tmavě modrá červeň</CZ> <DE>Traube</DE> <ES>Uva</ES> <FR>Raisin</FR> <IT>Vinaccia</IT> <JP>グレープ</JP> <KR>포도색</KR> <MA>Otellókék</MA> <NL>Druif</NL> <PL>Jagodowy</PL> <RU>Виноградный</RU> <SU>Rypäleensininen</SU> <SV>Blåviolett</SV> <TR>Üzüm</TR> </resource> </localization>
The languages that use a two-letter language code are:
Attached to this article is an XML schema file that describes the file format which you can use to validate your palette using an XML validator.
If you have existing color data stored in a spreadsheet, it is relatively easy to use this to generate the color palette using the attached perl script. This script expects the data to be in a particular layout which you will need to do within the spreadsheet program. Then just export the spreadsheet as a tab-separated text file and run the perl script on it to create the XML color palette.
The snippet below shows example color data lined up in the columns expected. Note, this example has been padded with spaces to visually line up for ease of reading, but the perl script expects only one tab per column which is what you will get when exporting a spreadsheet of column data as a tab-separated text file.
Example Custom Palette ACME ec120aef-24cf-42dd-ad25-491ea640e171 Spot Header info Page IndexOnPage ColorSpaceID ColorSpaceName DescriptiveName L* a* b* R G B C M Y K 1 1 1 ACME 111 Light Yellow 92.27 -5.59 54.12 247 235 125 0 0 58 0 1 2 2 ACME 112 Medium Yellow 91.68 -5.99 65.15 247 233 98 0 0 70 0 1 3 3 ACME 113 Yellow 90.63 -6.18 91.38 249 230 0 0 0 95 0 1 4 4 ACME 114 Dark Yellow 89.36 -4.46 98.02 249 225 0 0 1 100 0 1 5 5 ACME 115 Tan 73.26 -1.01 81.58 203 179 0 5 10 100 15 1 6 6 ACME 116 Medium Tan 65.16 -0.51 73.05 179 157 0 7 13 100 28
The first few lines correspond to the attributes of the palette element in the XML file as described earlier.
Page The swatch book page where the color is found. This is used to match vendors actual swatch books. If it is not needed, then all colors can be placed on page 1. IndexOnPage The color's index on the page. Again this corresponds to the swatch book page. If there is only one page then each color just needs to have a unique index. ColorSpaceID Unique integer representing the color space ID. This is a reference number used to look up the color in the palette. Once set, this number cannot be changed from version to version. ColorSpaceName Name of the unique color space. This is typically a vendor's product code representing the unique color. If no descriptive name is given, this is used as the visible name for the color. DescriptiveName Name of the color as it appears in the application in the status bar and tooltips. L* a* b* Three sequential columns of the L*a*b* definition for the color space. L* [0..100] a* [-128..127] bb* [-128..127] R G B Three sequential columns of the RGB definition for the color space. R [0..255] G [0..255] B [0..255] C M Y K Four sequential columns of the CMYK definition for the color space. C [0..100] M [0..100] Y [0..100] K [0..100] sR-255 sG-255 sB-255 Three sequential columns of the sRGB definition for the color space. R [0..255] G [0..255] B [0..255] aR-255 aG-255 aB-255 Three sequential columns of the Adobe RGB definition for the color space. R [0..255] G [0..255] B [0..255]
Note: not all color models per color need to be defined, but if they are it will add them to the color space definition. When creating the color space definitions it will convert values from these ranges to the 0.0 to 1.0 range. This is typically done by dividing by the upper range value. For Lab values a and b, it also offsets the value since these can be negative. You can have a look in the perl script to see how it is done.
The palette xml file is generated using the attached perl script that parses the given palette text file to produce the XML file. Note: the attached file has .txt added to the name so that the blog would accept the file in the post. Just remove this from the name before using. A perl interpreter needs to be installed on the machine in order to use the script. One interpreter that is available on the web is called ActivePerl and can be found at http://www.activestate.com/activeperl.
From the command line run:
perl CreatePaletteXmlFromTxt.pl CustomPalette.txt CustomPalette.xml
This will convert the input text file CustomPalette.txt to the XML palette file CustomPalette.xml.
For the new palette to be part of the installed application, it can be placed anywhere under following folder:
<Install Folder>\Color\Palettes
Under this folder you can organize the palettes into subfolders as needed and this organization will be reflected in the user interface. Once placed, the palette will be available through the Color Palette Browser docker in CorelDRAW, Corel DESIGNER and Corel PHOTO-PAINT. Alternatively, if placed under the user's My Palettes folder in their Documents folder it will appear as a user palette in the applications.
There are several places where a short-list of commonly used palettes is displayed. For example, the Window-->Palettes menu, the interactive fill tool property bar with uniform fill selected, and the convert to paletted dialog. This list is predefined based on the region from which that the user is running. The list is found in the XML file:
<Install Folder>\Config\ColorPalettes.xml
The new palette can be added to this list by adding a new palette entry in the appropriate region with the GUID identifier used in the palette XML file. The palette name will be retrieved from the palette itself.