PTColorPt
@interface PTColorPt : NSObject
ColorPt is an array of colorants (or tint values) representing a color point in an associated color space.
-
Constructor
Note
All colorants should be in the range [0..1], so colors in the range [0..255] should be divided by 255.0 first.Declaration
Objective-C
- (instancetype)initWithX:(double)x y:(double)y z:(double)z w:(double)w;Swift
init!(x: Double, y: Double, z: Double, w: Double)Parameters
xinitialized value of first color value (eg. red for rgb colorspace);
yinitialized value of second color value (eg. green for rgb colorspace);
zinitialized value of third color value (eg. blue for rgb colorspace);
winitialized value of fourth color value (eg. when using CMYK);
-
Undocumented
Declaration
Objective-C
- (BOOL)isEqualTo: (PTColorPt*)co;Swift
func isEqual(to co: PTColorPt!) -> Bool -
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.
Note
color.Set(gray) is equivalent to Set(0, gray);Note
All colorants should be in the range [0..1], so colors in the range [0..255] should be divided by 255.0 first.Declaration
Objective-C
- (void)Set:(double)x y:(double)y z:(double)z w:(double)w;Swift
func set(_ x: Double, y: Double, z: Double, w: Double)Parameters
xinitialized value of first color value (eg. red for rgb colorspace);
yinitialized value of second color value (eg. green for rgb colorspace);
zinitialized value of third color value (eg. blue for rgb colorspace);
winitialized value of fourth color value (eg. when using CMYK);
-
Sets a tint value at a given colorant index.
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)
Note
If a color point has more than 4 colorants, SetColorantNum(num_colorants) must be called before getting or setting tint values.Note
All colorants should be in the range [0..1], so colors in the range [0..255] should be divided by 255.0 first.Declaration
Objective-C
- (void)SetTintWithIndex:(int)colorant_index colorant_value:(double)colorant_value;Swift
func setTintWith(_ colorant_index: Int32, colorant_value: Double)Parameters
colorant_indexthe 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_valueThe new tint value.
-
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] = ;;Declaration
Objective-C
- (double)Get:(int)colorant_index;Swift
func get(_ colorant_index: Int32) -> DoubleParameters
colorant_indexnumber representing the index of the color space to get the tint from
Return Value
the tint value at a given colorant index.
-
If a color point has more than 4 colorants, SetColorantNum(num_colorants) must be called before getting or setting tint values. 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().
Declaration
Objective-C
- (void)SetColorantNum:(int)num;Swift
func setColorantNum(_ num: Int32)
-
Returns the
UIColorvalue for thisPTColorPtwith the specified color component count.Declaration
Objective-C
- (nullable UIColor *)UIColorValueWithComponentCount:(int)componentCount;Swift
func uiColorValue(withComponentCount componentCount: Int32) -> UIColor?Parameters
componentCountThe number of color components in this
PTColorPtReturn Value
the
UIColorvalue for thisPTColorPt, ornilif the color could not be converted -
Returns the equivalent
UIColorvalue for the givenPTColorPtand color component count.Declaration
Objective-C
+ (nullable UIColor *)UIColorForColorPt:(nonnull PTColorPt *)colorPt withComponentCount:(int)componentCount;Swift
class func uiColor(for colorPt: PTColorPt, withComponentCount componentCount: Int32) -> UIColor?Parameters
colorPtThe
PTColorPtto be convertedcomponentCountThe number of color components in the
colorPtparameterReturn Value
the
UIColorvalue for thePTColorPt, ornilif the color could not be converted -
Creates a new
PTColorPtinstance from the givenUIColor.Declaration
Objective-C
+ (nullable instancetype)colorFromUIColor:(nonnull UIColor *)uiColor componentCount:(nonnull int *)componentCount;Swift
class func color(from uiColor: UIColor, componentCount: UnsafeMutablePointer<Int32>) -> Self?Parameters
uiColorThe
UIColorfrom which to create aPTColorPtrepresentationcomponentCountOn output, this parameter contains the number of color components in the returned
PTColorPt. On error, this parameter is invalid.Return Value
a new
PTColorPtinstance from the givenUIColor. ThecomponentCountparameter contains the number of color components in the returnedPTColorPt. If an error occurred during the conversion or theUIColorcould not be represented as aPTColorPt, then the returned value isniland thecomponentCountparameter is invalid.
PTColorPt Class Reference