picofuse-objc

Instance Methods | Class Methods | List of all members
NXColor Class Reference

A color: red, green and blue, with an opacity. More...

#import <Foundation/Foundation.h>

Inheritance diagram for NXColor:
Inheritance graph
[legend]
Collaboration diagram for NXColor:
Collaboration graph
[legend]

Instance Methods

(float) - red
 Returns the red, from 0 to 1.
 
(float) - green
 Returns the green, from 0 to 1.
 
(float) - blue
 Returns the blue, from 0 to 1.
 
(float) - opacity
 Returns the opacity, from 0, which is transparent, to 1, which is opaque.
 
(pix_color_t) - rgbaValue
 Returns the color as a pix_color_t of picofuse, 0xRRGGBBAA.
 
(NXColor *) - colorWithOpacity:
 Returns the same color with another opacity, from 0 to 1.
 
(BOOL) - isEqual:
 Returns YES if the other is a color with the same parts.
 
(NXString *) - description
 Returns the color in hexadecimal, as "#RRGGBB", or "#RRGGBBAA" unless it's opaque, in capitals.
 
- Instance Methods inherited from NXObject
(void) - dealloc
 Frees the instance. More...
 
(NXZone *) - zone
 Returns the zone in which the instance was allocated. More...
 
(id) - retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id) - autorelease
 Releases the receiver later, when the current autorelease pool of the thread is drained. More...
 
(id) - copy
 Returns a copy which can't be changed by anything else, which the caller owns and has to release. More...
 
(uintptr_t) - hash
 Returns a number for the object, which is the same for objects which are equal by isEqual:. More...
 
- Instance Methods inherited from Object
(id) - init
 Initialize the instance, after allocation. More...
 
(Class) - class
 Returns the class of the instance. More...
 
(Class) - superclass
 Returns the superclass of the instance. More...
 
(BOOL) - isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL) - conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL) - respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(NXColor *) + colorWithRed:green:blue:
 Returns an opaque color from its red, green and blue, from 0 to 1.
 
(NXColor *) + colorWithRed:green:blue:opacity:
 Returns a color from its red, green, blue and opacity, from 0 to 1, where an opacity of 0 is transparent.
 
(NXColor *) + colorWithHex:
 Returns a color from hexadecimal, as in CSS. More...
 
(NXColor *) + colorWithRGBA:
 Returns a color from a pix_color_t of picofuse, 0xRRGGBBAA.
 
(NXColor *) + blackColor
 Returns opaque black.
 
(NXColor *) + whiteColor
 Returns opaque white.
 
(NXColor *) + redColor
 Returns opaque red.
 
(NXColor *) + greenColor
 Returns opaque green.
 
(NXColor *) + blueColor
 Returns opaque blue.
 
(NXColor *) + clearColor
 Returns transparent black, which is no color.
 
- Class Methods inherited from NXObject
(id) + alloc
 Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More...
 
(id) + allocWithZone:
 Allocates a new instance in a specific zone. More...
 
(id) + new
 Allocates and initializes a new instance, as [[cls alloc] init] does. More...
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(Class) + class
 Returns the class object. More...
 
(Class) + superclass
 Returns the superclass of the class. More...
 
(const char *) + name
 Returns the name of the class. More...
 
(BOOL) + conformsTo:
 Checks if the class conforms to a protocol. More...
 

Additional Inherited Members

- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

A color: red, green and blue, with an opacity.

A color is a pix_color_t of picofuse, 0xRRGGBBAA, so each part is one of 256 levels. Parts given as floats are from 0 to 1, and are clamped to that.

NXColor *orange = [NXColor colorWithRed:1 green:0.5f blue:0 opacity:1];
NXColor *same = [NXColor colorWithHex:@"#FF8000"];
NXColor *faint = [orange colorWithOpacity:0.25f];

A color can't change, so any number of threads can use it at once. See Threads and mutable objects.

Definition at line 27 of file NXColor.h.

Method Documentation

◆ colorWithHex:()

+ (NXColor *) colorWithHex: (NXString *)  hex

Returns a color from hexadecimal, as in CSS.

Parameters
hex"#RGB", "#RRGGBB", or "#RRGGBBAA" with the opacity last, where the "#" is optional, and letters can be either case. The first is "#RRGGBB" with each digit repeated, so "#F80" is "#FF8800".
Returns
The color, which is opaque unless its opacity is given, or nil if it isn't one of these.

The documentation for this class was generated from the following file: