Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSColorMBS class.

Next items

NSColorMBS.alternateSelectedControlColor as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 8.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Returns the system color used for the face of a selected control.
Example:
dim c as NSColorMBS = NSColorMBS.alternateSelectedControlColor

window1.Title=c.description
window1.HasBackColor=true
window1.backcolor=c.colorValue
Notes: The system color used for the face of a selected control—a control being clicked or dragged. This color can be used where iApp-like highlighting is desired.
NSColorMBS.alternateSelectedControlTextColor as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 8.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Returns the system color used for text in a selected control.
Example:
dim c as NSColorMBS = NSColorMBS.alternateSelectedControlTextColor

window1.Title=c.description
window1.HasBackColor=true
window1.backcolor=c.colorValue
Notes: The system color used for text in a selected control—a control being clicked or dragged. This color can be used where iApp-like highlighting is desired.
NSColorMBS.alternatingContentBackgroundColors as NSColorMBS()
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 18.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: The background colors for alternating content items: such as table view rows, collection view items.
Notes:
Available on MacOS 10.14 or newer.
This function calls controlAlternatingRowBackgroundColors when alternatingContentBackgroundColors is not available.

Some examples using this method:

NSColorMBS.blackColor as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 8.6 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Returns an NSColor object whose grayscale value is 0.0 and whose alpha value is 1.0.
Example:
dim c as NSColorMBS = NSColorMBS.blackColor

window1.Title=c.description
window1.HasBackColor=true
window1.backcolor=c.colorValue
NSColorMBS.blueColor as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 8.6 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Returns an NSColor object whose RGB value is 0.0, 0.0, 1.0 and whose alpha value is 1.0.
Example:
dim c as NSColorMBS = NSColorMBS.blueColor

window1.Title=c.description
window1.HasBackColor=true
window1.backcolor=c.colorValue
NSColorMBS.brownColor as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 8.6 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Returns an NSColor object whose RGB value is 0.6, 0.4, 0.2 and whose alpha value is 1.0.
Notes:
dim c as NSColorMBS = NSColorMBS.brownColor

window1.Title=c.description
window1.HasBackColor=true
window1.backcolor=c.colorValue

Some examples using this method:

NSColorMBS.clearColor as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 8.6 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Returns an NSColor object whose grayscale and alpha values are both 0.0.
Example:
dim c as NSColorMBS = NSColorMBS.clearColor

window1.Title=c.description
window1.HasBackColor=true
window1.backcolor=c.colorValue
NSColorMBS.colorFromPasteboard as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Returns the NSColor currently on the given pasteboard.
Notes: The color currently on the pasteboard or nil if pasteBoard doesn't contain color data.
NSColorMBS.colorNamed(colorName as String) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 18.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Create catalog colors from values stored with the given name in the Asset Catalog of the main app bundle.
NSColorMBS.colorWithCalibratedHSV(hue as Double, saturation as Double, brightness as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Creates and returns an NSColor object using the given opacity and HSB color space components.
Example:
dim b as NSColorMBS = NSColorMBS.colorWithCalibratedHSV(1.0, 0.5, 0.2, 1.0)
MsgBox b.description // shows "NSCalibratedRGBColorSpace 0.2 0.1 0.1 1"
Notes:
hue: The hue component of the color object in the HSB color space.
saturation: The saturation component of the color object in the HSB color space.
brightness: The brightness (or value) component of the color object in the HSB color space.
alpha: The opacity value of the color object,

Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.
NSColorMBS.colorWithCalibratedRGB(red as Double, green as Double, blue as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates and returns an NSColor object using the given opacity and RGB components.
Example:
dim b as NSColorMBS = NSColorMBS.colorWithCalibratedRGB(1.0, 0.5, 0.2, 1.0)
MsgBox b.description // shows "NSCalibratedRGBColorSpace 1 0.5 0.2 1"
Notes:
red: The red component of the color object.
green: The green component of the color object.
blue: The blue component of the color object.
alpha: The opacity value of the color object.

Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.

Some examples using this method:

NSColorMBS.colorWithCalibratedWhite(white as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates and returns an NSColor object using the given opacity and grayscale value.
Example:
dim b as NSColorMBS = NSColorMBS.colorWithCalibratedWhite(1.0, 1.0)
MsgBox b.description // shows "NSCalibratedWhiteColorSpace 1 1"
Notes:
white: The grayscale value of the color object.
alpha: The opacity value of the color object.

Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.
NSColorMBS.colorWithCatalogName(listName as String, colorName as String) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 18.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Look up and return catalog colors from standard color catalogs, or from NSColorList whose name matches the specified catalog name.
NSColorMBS.colorWithCGColor(CGColorHandle as Integer) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 12.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Converts CGColor to NSColor.
Notes:
Return value may be an approximation in some cases, so there isn't guaranteed round-trip fidelity.
Available on Mac OS X 10.8.
NSColorMBS.colorWithColorSpace(ColorSpace as NSColorSpaceMBS, components() as Double) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Returns an NSColor object created from the specified components of the given color space.
Example:
dim n as NSColorSpaceMBS = NSColorSpaceMBS.genericRGBColorSpace
MsgBox n.localizedName

dim co as NSColorMBS = NSColorMBS.colorWithColorSpace(n, 1.0, 0, 0, 1.0)
MsgBox co.description
Notes:
space: An NSColorSpace object representing a color space. The method raises an exception if this is nil.
components: An array of the components in the specified color space to use to create the NSColor object. The order of these components is determined by the color-space profile, with the alpha component always last. (If you want the created color to be opaque, specify 1.0 for the alpha component.)

Returns the color object. If space represents a color space that cannot cannot be used with NSColor objects (for example, a "pattern" color space) the method returns nil.
Raises an NSExceptionMBS if the number of components does not match.

See also:

Some examples using this method:

NSColorMBS.colorWithColorSpace(ColorSpace as NSColorSpaceMBS, paramarray components as Double) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Returns an NSColor object created from the specified components of the given color space.
Example:
dim n as NSColorSpaceMBS = NSColorSpaceMBS.genericRGBColorSpace
MsgBox n.localizedName

dim co as NSColorMBS = NSColorMBS.colorWithColorSpace(n, 1.0, 0, 0, 1.0)
MsgBox co.description
Notes:
space: An NSColorSpace object representing a color space. The method raises an exception if this is nil.
components: An array of the components in the specified color space to use to create the NSColor object. The order of these components is determined by the color-space profile, with the alpha component always last. (If you want the created color to be opaque, specify 1.0 for the alpha component.)

Returns the color object. If space represents a color space that cannot cannot be used with NSColor objects (for example, a "pattern" color space) the method returns nil.
Raises an NSExceptionMBS if the number of components does not match.

See also:

NSColorMBS.colorWithColorSpaceHSV(ColorSpace as NSColorSpaceMBS, hue as Double, saturation as Double, brightness as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 16.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Creates and returns an NSColor object with the specified color space, hue, saturation, brightness, and alpha channel values.
Notes:
ColorSpace: An NSColorSpace object representing a color space. An exception is raised if the color model of the provided color space is not RGB.
hue: The hue (color) component, expressed as a floating-point value in the range 0–1.0.
saturation: The color saturation component, expressed as a floating-point value in the range 0–1.0.
brightness: The brightness component, expressed as a floating-point value in the range 0–1.0.
alpha: The alpha (opacity), expressed as a floating-point value in the range 0 (transparent) to 1.0 (opaque).

Returns the color object.
NSColorMBS.colorWithDeviceCMYK(cyan as Double, magenta as Double, yellow as Double, black as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Creates and returns an NSColor object using the given opacity value and CMYK components.
Example:
dim b as NSColorMBS = NSColorMBS.colorWithDeviceCMYK(0.5, 1.0, 0.5, 0.2, 1.0)
MsgBox b.description // shows "NSDeviceCMYKColorSpace 0.5 1 0.5 0.2 1"
Notes:
cyan: The cyan component of the color object.
magenta: The magenta component of the color object.
yellow: The yellow component of the color object.
black: The black component of the color object.
alpha: The opacity value of the color object.

Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. In PostScript, this color space corresponds directly to the device-dependent operator setcmykcolor.
NSColorMBS.colorWithDeviceHSV(hue as Double, saturation as Double, brightness as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Creates and returns an NSColor object using the given opacity value and HSB color space components.
Example:
dim b as NSColorMBS = NSColorMBS.colorWithDeviceHSV(1.0, 0.5, 0.2, 1.0)
MsgBox b.description // shows "NSDeviceRGBColorSpace 0.2 0.1 0.1 1"
Notes:
hue: The hue component of the color object.
saturation: The saturation component of the color object.
brightness: The brightness component of the color object.
alpha: The opacity value of the color object.

Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. In PostScript, this color space corresponds directly to the device-dependent operator setrgbcolor.

Some examples using this method:

NSColorMBS.colorWithDeviceRGB(red as Double, green as Double, blue as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates and returns an NSColor object using the given opacity value and RGB components.
Example:
dim b as NSColorMBS = NSColorMBS.colorWithDeviceRGB(1.0, 0.5, 0.2, 1.0)
MsgBox b.description // shows "NSDeviceRGBColorSpace 1 0.5 0.2 1"
Notes:
red: The red component of the color object.
green: The green component of the color object.
blue: The blue component of the color object.
alpha: The opacity value of the color object.

Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. In PostScript, this color space corresponds directly to the device-dependent operator setrgbcolor.

Some examples using this method:

NSColorMBS.colorWithDeviceWhite(white as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates and returns an NSColor object using the given opacity and grayscale values.
Example:
dim b as NSColorMBS = NSColorMBS.colorWithDeviceWhite(1.0, 1.0)
MsgBox b.description // shows "NSDeviceWhiteColorSpace 1 1"
Notes:
white: The grayscale value of the color object.
alpha: The opacity value of the color object.

Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. In PostScript, this color space corresponds directly to the device-dependent operator setgray.
NSColorMBS.colorWithDisplayP3(red as Double, green as Double, blue as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 16.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Returns a color created from the specified components in the Display P3 colorspace.
Notes:
red: The red component of the color object.
green: The green component of the color object.
blue: The blue component of the color object.
alpha: The opacity value of the color object.

Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.
NSColorMBS.colorWithGenericGamma22White(white as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 13.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Returns an color created with the specified white and alpha values in the GenericGamma22 colorspace.
Notes:
white: The white value of the color object.
alpha: The opacity value of the color object.

Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.
Available in OS X v10.7 and later.
NSColorMBS.colorWithHSV(hue as double, saturation as double, brightness as double, alpha as double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 18.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Create component-based colors that are compatible with sRGB colorspace.
Notes: These methods are effectively same as colorWithSRGBHSV:, but provided for easier reuse of code that uses UIColor on iOS. If red, green, blue, or saturation, brightness, or white values are outside of the 0..1 range, these will create colors in the extended sRGB (or for colorWithWhite:alpha:, extendedGenericGamma22GrayColorSpace) color spaces. This behavior is compatible with iOS UIColor.

Some examples using this method:

NSColorMBS.colorWithPatternImage(image as Variant) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates and returns an NSColor object that uses the specified image pattern.
Example:
dim p as Picture = LogoMBS(100)
dim n as new NSImageMBS(p)
dim c as NSColorMBS = NSColorMBS.colorWithPatternImage(n)
dim x as NSImageMBS = c.patternImage

Backdrop=x.CopyPictureWithMask
Notes:
The image is tiled starting at the bottom of the window. The image is not scaled.

Parameter is a NSImageMBS object. We declare it as a variant to reduce plugin dependencies.

Some examples using this method:

NSColorMBS.colorWithRGB(red as double, green as double, blue as double, alpha as double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 18.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Create component-based colors that are compatible with sRGB colorspace.
Notes: These methods are effectively same as colorWithSRGBHSV:, but provided for easier reuse of code that uses UIColor on iOS. If red, green, blue, or saturation, brightness, or white values are outside of the 0..1 range, these will create colors in the extended sRGB (or for colorWithWhite:alpha:, extendedGenericGamma22GrayColorSpace) color spaces. This behavior is compatible with iOS UIColor.
NSColorMBS.colorWithSRGB(red as Double, green as Double, blue as Double, alpha as Double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 13.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: Returns a color created from the specified components in the sRGB colorspace.
Notes:
red: The red component of the color object.
green: The green component of the color object.
blue: The blue component of the color object.
alpha: The opacity value of the color object.

Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.
Available in OS X v10.7 and later.

Some examples using this method:

NSColorMBS.colorWithWhite(white as double, alpha as double=1.0) as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 18.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Create component-based colors that are compatible with sRGB colorspace.
Notes: These methods are effectively same as colorWithSRGBHSV:, but provided for easier reuse of code that uses UIColor on iOS. If red, green, blue, or saturation, brightness, or white values are outside of the 0..1 range, these will create colors in the extended sRGB (or for colorWithWhite:alpha:, extendedGenericGamma22GrayColorSpace) color spaces. This behavior is compatible with iOS UIColor.

Some examples using this method:

NSColorMBS.controlAccentColor as NSColorMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Drawing MBS MacBase Plugin 18.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Function: A dynamic color that reflects the user's current preferred accent color.
Notes:
This color automatically updates when the accent color preference changes. Do not make assumptions about the color space of this color, which may change across releases.
Available on MacOS 10.14 or newer.

Next items

The items on this page are in the following plugins: MBS MacBase Plugin.


💬 Ask a question or report a problem
The biggest plugin in space...


Start Chat