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.
-
Untyped pointer to the underlying
CoglColor
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
color_ptr
Default implementationTyped 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)
-
copy()
Extension methodCreates a copy of
color
Declaration
Swift
@inlinable func copy() -> ColorRef!
-
free()
Extension methodFrees the resources allocated by
cogl_color_new()
andcogl_color_copy()
Declaration
Swift
@inlinable func free()
-
getAlpha()
Extension methodRetrieves the alpha channel of
color
as a fixed point value between 0 and 1.0.Declaration
Swift
@inlinable func getAlpha() -> CFloat
-
getAlphaByte()
Extension methodRetrieves the alpha channel of
color
as a byte value between 0 and 255Declaration
Swift
@inlinable func getAlphaByte() -> CUnsignedChar
-
getAlphaFloat()
Extension methodRetrieves the alpha channel of
color
as a floating point value between 0.0 and 1.0Declaration
Swift
@inlinable func getAlphaFloat() -> CFloat
-
getBlue()
Extension methodRetrieves the blue channel of
color
as a fixed point value between 0 and 1.0.Declaration
Swift
@inlinable func getBlue() -> CFloat
-
getBlueByte()
Extension methodRetrieves the blue channel of
color
as a byte value between 0 and 255Declaration
Swift
@inlinable func getBlueByte() -> CUnsignedChar
-
getBlueFloat()
Extension methodRetrieves the blue channel of
color
as a floating point value between 0.0 and 1.0Declaration
Swift
@inlinable func getBlueFloat() -> CFloat
-
getGreen()
Extension methodRetrieves the green channel of
color
as a fixed point value between 0 and 1.0.Declaration
Swift
@inlinable func getGreen() -> CFloat
-
getGreenByte()
Extension methodRetrieves the green channel of
color
as a byte value between 0 and 255Declaration
Swift
@inlinable func getGreenByte() -> CUnsignedChar
-
getGreenFloat()
Extension methodRetrieves the green channel of
color
as a floating point value between 0.0 and 1.0Declaration
Swift
@inlinable func getGreenFloat() -> CFloat
-
getRed()
Extension methodRetrieves the red channel of
color
as a fixed point value between 0 and 1.0.Declaration
Swift
@inlinable func getRed() -> CFloat
-
getRedByte()
Extension methodRetrieves the red channel of
color
as a byte value between 0 and 255Declaration
Swift
@inlinable func getRedByte() -> CUnsignedChar
-
getRedFloat()
Extension methodRetrieves the red channel of
color
as a floating point value between 0.0 and 1.0Declaration
Swift
@inlinable func getRedFloat() -> CFloat
-
initFrom4f(red:
Extension methodgreen: blue: alpha: ) 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>!)
-
initFrom4ub(red:
Extension methodgreen: blue: alpha: ) 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 methodConverts 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
toalpha
.Declaration
Swift
@inlinable func set(alpha: CFloat)
-
setAlphaByte(alpha:
Extension method) Sets the alpha channel of
color
toalpha
.Declaration
Swift
@inlinable func setAlphaByte(alpha: CUnsignedChar)
-
setAlphaFloat(alpha:
Extension method) Sets the alpha channel of
color
toalpha
.Declaration
Swift
@inlinable func setAlphaFloat(alpha: CFloat)
-
set(blue:
Extension method) Sets the blue channel of
color
toblue
.Declaration
Swift
@inlinable func set(blue: CFloat)
-
setBlueByte(blue:
Extension method) Sets the blue channel of
color
toblue
.Declaration
Swift
@inlinable func setBlueByte(blue: CUnsignedChar)
-
setBlueFloat(blue:
Extension method) Sets the blue channel of
color
toblue
.Declaration
Swift
@inlinable func setBlueFloat(blue: CFloat)
-
setFrom4f(red:
Extension methodgreen: blue: alpha: ) 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)
-
setFrom4ub(red:
Extension methodgreen: blue: alpha: ) 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
togreen
.Declaration
Swift
@inlinable func set(green: CFloat)
-
setGreenByte(green:
Extension method) Sets the green channel of
color
togreen
.Declaration
Swift
@inlinable func setGreenByte(green: CUnsignedChar)
-
setGreenFloat(green:
Extension method) Sets the green channel of
color
togreen
.Declaration
Swift
@inlinable func setGreenFloat(green: CFloat)
-
set(red:
Extension method) Sets the red channel of
color
tored
.Declaration
Swift
@inlinable func set(red: CFloat)
-
setRedByte(red:
Extension method) Sets the red channel of
color
tored
.Declaration
Swift
@inlinable func setRedByte(red: CUnsignedChar)
-
setRedFloat(red:
Extension method) Sets the red channel of
color
tored
.Declaration
Swift
@inlinable func setRedFloat(red: CFloat)
-
toHsl(hue:
Extension methodsaturation: luminance: ) Converts
color
to the HLS format.The
hue
value is in the 0 .. 360 range. Theluminance
andsaturation
values are in the 0 .. 1 range.Declaration
Swift
@inlinable func toHsl(hue: UnsafeMutablePointer<CFloat>!, saturation: UnsafeMutablePointer<CFloat>!, luminance: UnsafeMutablePointer<CFloat>!)
-
unpremultiply()
Extension methodConverts 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()
-
initFromHsl(hue:
Extension methodsaturation: luminance: ) 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 specifiedcolor
is used.clear is deprecated: Use cogl_framebuffer_clear() api instead
Declaration
Swift
@available(*, deprecated) @inlinable func clear(buffers: Int)
-
colorInitFromHsl(hue:
Extension methodsaturation: luminance: ) 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)
-
setFog(mode:
Extension methoddensity: zNear: zFar: ) 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 atz_far
are drawn fully withfog_color
. Fogging will remain enabled until you callcogl_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 usecogl_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 methodThis 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()
andcogl_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 methodRetrieves 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 methodRetrieves the alpha channel of
color
as a byte value between 0 and 255Declaration
Swift
@inlinable var alphaByte: CUnsignedChar { get nonmutating set }
-
alphaFloat
Extension methodRetrieves the alpha channel of
color
as a floating point value between 0.0 and 1.0Declaration
Swift
@inlinable var alphaFloat: CFloat { get nonmutating set }
-
blue
Extension methodRetrieves 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 methodRetrieves the blue channel of
color
as a byte value between 0 and 255Declaration
Swift
@inlinable var blueByte: CUnsignedChar { get nonmutating set }
-
blueFloat
Extension methodRetrieves the blue channel of
color
as a floating point value between 0.0 and 1.0Declaration
Swift
@inlinable var blueFloat: CFloat { get nonmutating set }
-
green
Extension methodRetrieves 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 methodRetrieves the green channel of
color
as a byte value between 0 and 255Declaration
Swift
@inlinable var greenByte: CUnsignedChar { get nonmutating set }
-
greenFloat
Extension methodRetrieves the green channel of
color
as a floating point value between 0.0 and 1.0Declaration
Swift
@inlinable var greenFloat: CFloat { get nonmutating set }
-
red
Extension methodRetrieves 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 methodRetrieves the red channel of
color
as a byte value between 0 and 255Declaration
Swift
@inlinable var redByte: CUnsignedChar { get nonmutating set }
-
redFloat
Extension methodRetrieves the red channel of
color
as a floating point value between 0.0 and 1.0Declaration
Swift
@inlinable var redFloat: CFloat { get nonmutating set }