ColorProtocol

public protocol ColorProtocol

A structure for holding a color definition. The contents of the CoglColor structure are private and should never by accessed directly.

The ColorProtocol protocol exposes the methods and properties of an underlying CoglColor instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see Color. Alternatively, use ColorRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying CoglColor instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • color_ptr Default implementation

    Typed pointer to the underlying CoglColor instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the CoglColor instance.

    Declaration

    Swift

    var color_ptr: UnsafeMutablePointer<CoglColor>! { get }
  • Required Initialiser for types conforming to ColorProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Color Record: ColorProtocol extension (methods and fields)

  • copy() Extension method

    Creates a copy of color

    Declaration

    Swift

    @inlinable
    func copy() -> ColorRef!
  • free() Extension method

    Frees the resources allocated by cogl_color_new() and cogl_color_copy()

    Declaration

    Swift

    @inlinable
    func free()
  • getAlpha() Extension method

    Retrieves the alpha channel of color as a fixed point value between 0 and 1.0.

    Declaration

    Swift

    @inlinable
    func getAlpha() -> CFloat
  • getAlphaByte() Extension method

    Retrieves the alpha channel of color as a byte value between 0 and 255

    Declaration

    Swift

    @inlinable
    func getAlphaByte() -> CUnsignedChar
  • getAlphaFloat() Extension method

    Retrieves the alpha channel of color as a floating point value between 0.0 and 1.0

    Declaration

    Swift

    @inlinable
    func getAlphaFloat() -> CFloat
  • getBlue() Extension method

    Retrieves the blue channel of color as a fixed point value between 0 and 1.0.

    Declaration

    Swift

    @inlinable
    func getBlue() -> CFloat
  • getBlueByte() Extension method

    Retrieves the blue channel of color as a byte value between 0 and 255

    Declaration

    Swift

    @inlinable
    func getBlueByte() -> CUnsignedChar
  • getBlueFloat() Extension method

    Retrieves the blue channel of color as a floating point value between 0.0 and 1.0

    Declaration

    Swift

    @inlinable
    func getBlueFloat() -> CFloat
  • getGreen() Extension method

    Retrieves the green channel of color as a fixed point value between 0 and 1.0.

    Declaration

    Swift

    @inlinable
    func getGreen() -> CFloat
  • getGreenByte() Extension method

    Retrieves the green channel of color as a byte value between 0 and 255

    Declaration

    Swift

    @inlinable
    func getGreenByte() -> CUnsignedChar
  • getGreenFloat() Extension method

    Retrieves the green channel of color as a floating point value between 0.0 and 1.0

    Declaration

    Swift

    @inlinable
    func getGreenFloat() -> CFloat
  • getRed() Extension method

    Retrieves the red channel of color as a fixed point value between 0 and 1.0.

    Declaration

    Swift

    @inlinable
    func getRed() -> CFloat
  • getRedByte() Extension method

    Retrieves the red channel of color as a byte value between 0 and 255

    Declaration

    Swift

    @inlinable
    func getRedByte() -> CUnsignedChar
  • getRedFloat() Extension method

    Retrieves the red channel of color as a floating point value between 0.0 and 1.0

    Declaration

    Swift

    @inlinable
    func getRedFloat() -> CFloat
  • Sets the values of the passed channels into a CoglColor

    Declaration

    Swift

    @inlinable
    func initFrom4f(red: CFloat, green: CFloat, blue: CFloat, alpha: CFloat)
  • initFrom4fv(colorArray:) Extension method

    Sets the values of the passed channels into a CoglColor

    Declaration

    Swift

    @inlinable
    func initFrom4fv(colorArray: UnsafePointer<CFloat>!)
  • Sets the values of the passed channels into a CoglColor.

    Declaration

    Swift

    @inlinable
    func initFrom4ub(red: UInt8, green: UInt8, blue: UInt8, alpha: UInt8)
  • premultiply() Extension method

    Converts a non-premultiplied color to a pre-multiplied color. For example, semi-transparent red is (1.0, 0, 0, 0.5) when non-premultiplied and (0.5, 0, 0, 0.5) when premultiplied.

    Declaration

    Swift

    @inlinable
    func premultiply()
  • set(alpha:) Extension method

    Sets the alpha channel of color to alpha.

    Declaration

    Swift

    @inlinable
    func set(alpha: CFloat)
  • setAlphaByte(alpha:) Extension method

    Sets the alpha channel of color to alpha.

    Declaration

    Swift

    @inlinable
    func setAlphaByte(alpha: CUnsignedChar)
  • setAlphaFloat(alpha:) Extension method

    Sets the alpha channel of color to alpha.

    Declaration

    Swift

    @inlinable
    func setAlphaFloat(alpha: CFloat)
  • set(blue:) Extension method

    Sets the blue channel of color to blue.

    Declaration

    Swift

    @inlinable
    func set(blue: CFloat)
  • setBlueByte(blue:) Extension method

    Sets the blue channel of color to blue.

    Declaration

    Swift

    @inlinable
    func setBlueByte(blue: CUnsignedChar)
  • setBlueFloat(blue:) Extension method

    Sets the blue channel of color to blue.

    Declaration

    Swift

    @inlinable
    func setBlueFloat(blue: CFloat)
  • Sets the values of the passed channels into a CoglColor

    set_from_4f is deprecated: Use cogl_color_init_from_4f instead.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func setFrom4f(red: CFloat, green: CFloat, blue: CFloat, alpha: CFloat)
  • Sets the values of the passed channels into a CoglColor.

    set_from_4ub is deprecated: Use cogl_color_init_from_4ub instead.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func setFrom4ub(red: UInt8, green: UInt8, blue: UInt8, alpha: UInt8)
  • set(green:) Extension method

    Sets the green channel of color to green.

    Declaration

    Swift

    @inlinable
    func set(green: CFloat)
  • setGreenByte(green:) Extension method

    Sets the green channel of color to green.

    Declaration

    Swift

    @inlinable
    func setGreenByte(green: CUnsignedChar)
  • setGreenFloat(green:) Extension method

    Sets the green channel of color to green.

    Declaration

    Swift

    @inlinable
    func setGreenFloat(green: CFloat)
  • set(red:) Extension method

    Sets the red channel of color to red.

    Declaration

    Swift

    @inlinable
    func set(red: CFloat)
  • setRedByte(red:) Extension method

    Sets the red channel of color to red.

    Declaration

    Swift

    @inlinable
    func setRedByte(red: CUnsignedChar)
  • setRedFloat(red:) Extension method

    Sets the red channel of color to red.

    Declaration

    Swift

    @inlinable
    func setRedFloat(red: CFloat)
  • Converts color to the HLS format.

    The hue value is in the 0 .. 360 range. The luminance and saturation values are in the 0 .. 1 range.

    Declaration

    Swift

    @inlinable
    func toHsl(hue: UnsafeMutablePointer<CFloat>!, saturation: UnsafeMutablePointer<CFloat>!, luminance: UnsafeMutablePointer<CFloat>!)
  • unpremultiply() Extension method

    Converts a pre-multiplied color to a non-premultiplied color. For example, semi-transparent red is (0.5, 0, 0, 0.5) when premultiplied and (1.0, 0, 0, 0.5) when non-premultiplied.

    Declaration

    Swift

    @inlinable
    func unpremultiply()
  • Converts a color expressed in HLS (hue, luminance and saturation) values into a CoglColor.

    Declaration

    Swift

    @inlinable
    func initFromHsl(hue: CFloat, saturation: CFloat, luminance: CFloat)
  • clear(buffers:) Extension method

    Clears all the auxiliary buffers identified in the buffers mask, and if that includes the color buffer then the specified color is used.

    clear is deprecated: Use cogl_framebuffer_clear() api instead

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func clear(buffers: Int)
  • Converts a color expressed in HLS (hue, luminance and saturation) values into a CoglColor.

    Declaration

    Swift

    @inlinable
    func colorInitFromHsl(hue: CFloat, saturation: CFloat, luminance: CFloat)
  • Enables fogging. Fogging causes vertices that are further away from the eye to be rendered with a different color. The color is determined according to the chosen fog mode; at it’s simplest the color is linearly interpolated so that vertices at z_near are drawn fully with their original color and vertices at z_far are drawn fully with fog_color. Fogging will remain enabled until you call cogl_disable_fog().

    <note>The fogging functions only work correctly when primitives use unmultiplied alpha colors. By default Cogl will premultiply textures and cogl_set_source_color() will premultiply colors, so unless you explicitly load your textures requesting an unmultiplied internal format and use cogl_material_set_color() you can only use fogging with fully opaque primitives. This might improve in the future when we can depend on fragment shaders.</note>

    set_fog is deprecated: Use #CoglSnippet shader api for fog

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func setFog(mode: CoglFogMode, density: CFloat, zNear: CFloat, zFar: CFloat)
  • setSourceColor() Extension method

    This is a convenience function for creating a solid fill source material from the given color. This color will be used for any subsequent drawing operation.

    The color will be premultiplied by Cogl, so the color should be non-premultiplied. For example: use (1.0, 0.0, 0.0, 0.5) for semi-transparent red.

    See also cogl_set_source_color4ub() and cogl_set_source_color4f() if you already have the color components.

    set_source_color is deprecated: Latest drawing apis all take an explicit #CoglPipeline argument so this stack of #CoglMaterial<!– –>s shouldn’t be used.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func setSourceColor()
  • alpha Extension method

    Retrieves the alpha channel of color as a fixed point value between 0 and 1.0.

    Declaration

    Swift

    @inlinable
    var alpha: CFloat { get nonmutating set }
  • alphaByte Extension method

    Retrieves the alpha channel of color as a byte value between 0 and 255

    Declaration

    Swift

    @inlinable
    var alphaByte: CUnsignedChar { get nonmutating set }
  • alphaFloat Extension method

    Retrieves the alpha channel of color as a floating point value between 0.0 and 1.0

    Declaration

    Swift

    @inlinable
    var alphaFloat: CFloat { get nonmutating set }
  • blue Extension method

    Retrieves the blue channel of color as a fixed point value between 0 and 1.0.

    Declaration

    Swift

    @inlinable
    var blue: CFloat { get nonmutating set }
  • blueByte Extension method

    Retrieves the blue channel of color as a byte value between 0 and 255

    Declaration

    Swift

    @inlinable
    var blueByte: CUnsignedChar { get nonmutating set }
  • blueFloat Extension method

    Retrieves the blue channel of color as a floating point value between 0.0 and 1.0

    Declaration

    Swift

    @inlinable
    var blueFloat: CFloat { get nonmutating set }
  • green Extension method

    Retrieves the green channel of color as a fixed point value between 0 and 1.0.

    Declaration

    Swift

    @inlinable
    var green: CFloat { get nonmutating set }
  • greenByte Extension method

    Retrieves the green channel of color as a byte value between 0 and 255

    Declaration

    Swift

    @inlinable
    var greenByte: CUnsignedChar { get nonmutating set }
  • greenFloat Extension method

    Retrieves the green channel of color as a floating point value between 0.0 and 1.0

    Declaration

    Swift

    @inlinable
    var greenFloat: CFloat { get nonmutating set }
  • red Extension method

    Retrieves the red channel of color as a fixed point value between 0 and 1.0.

    Declaration

    Swift

    @inlinable
    var red: CFloat { get nonmutating set }
  • redByte Extension method

    Retrieves the red channel of color as a byte value between 0 and 255

    Declaration

    Swift

    @inlinable
    var redByte: CUnsignedChar { get nonmutating set }
  • redFloat Extension method

    Retrieves the red channel of color as a floating point value between 0.0 and 1.0

    Declaration

    Swift

    @inlinable
    var redFloat: CFloat { get nonmutating set }