new ColorPt()
ColorPt is an array of colorants (or tint values) representing a color point in an associated color space.
Methods
-
<static> init(x, y, z, w)
-
Constructor
Parameters:
Name Type Description x
number initialized value of first color value (eg. red for rgb colorspace);
y
number initialized value of second color value (eg. green for rgb colorspace);
z
number initialized value of third color value (eg. blue for rgb colorspace);
w
number initialized value of fourth color value (eg. when using CMYK);
Returns:
A promise that resolves to an object of type: "colorpt"
- Type
- PDFNet.ColorPt
-
assign(right)
-
Copy Constructor
Parameters:
Name Type Description right
PDFNet.ColorPt -
destroy()
-
Frees the native memory of the object.
-
get(colorant_index)
-
The number of colorants depends on the associated color space. To find how many colorant are associated with a given color space use color_space.GetComponentNum().
For example, if you have a color point in the RGB color space you can extract its colorants as follows:
UInt8 rgb[3] = { UInt8(c.Get(0)*255), UInt8(c.Get(1)*255), UInt8(c.Get(2)*255) };
Parameters:
Name Type Description colorant_index
number number representing the index of the color space to get the tint from
Returns:
A promise that resolves to the tint value at a given colorant index.
- Type
- number
-
set(x, y, z, w)
-
A utility method to set the first 4 tint values. For example, color.Set(red, green, blue) will initialize the ColorPt to given tint values.
Parameters:
Name Type Description x
number initialized value of first color value (eg. red for rgb colorspace);
y
number initialized value of second color value (eg. green for rgb colorspace);
z
number initialized value of third color value (eg. blue for rgb colorspace);
w
number initialized value of fourth color value (eg. when using CMYK);
-
setByIndex(colorant_index, colorant_value)
-
Sets a tint value at a given colorant index.
Parameters:
Name Type Description colorant_index
number the color index. For example, for a color point associated with a Gray color space the only allowed value for index is 0. For a color point associated with a CMYK color space, the color_index can range from 0 (cyan) to 4 (black).
colorant_value
number The new tint value.
For example, the following snippet will initialize the color point to [red, green, blue]:
color.SetColorantNum(3); color.Set(0, red); color.Set(1, green); color.Set(2, blue);
The above code snippet is equivalent to the following line: color.Set(red, green, blue)
-
setColorantNum(num)
-
Parameters:
Name Type Description num
number