Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Color representation.
Synopsis
- newtype Color = Color (ManagedPtr Color)
- newZeroColor :: MonadIO m => m Color
- colorAdd :: (HasCallStack, MonadIO m) => Color -> Color -> m Color
- colorAlloc :: (HasCallStack, MonadIO m) => m Color
- colorCopy :: (HasCallStack, MonadIO m) => Color -> m Color
- colorDarken :: (HasCallStack, MonadIO m) => Color -> m Color
- colorEqual :: (HasCallStack, MonadIO m) => Color -> Color -> m Bool
- colorFree :: (HasCallStack, MonadIO m) => Color -> m ()
- colorFromHls :: (HasCallStack, MonadIO m) => Float -> Float -> Float -> m Color
- colorFromPixel :: (HasCallStack, MonadIO m) => Word32 -> m Color
- colorFromString :: (HasCallStack, MonadIO m) => Text -> m (Bool, Color)
- colorGetStatic :: (HasCallStack, MonadIO m) => StaticColor -> m Color
- colorHash :: (HasCallStack, MonadIO m) => Color -> m Word32
- colorInit :: (HasCallStack, MonadIO m) => Color -> Word8 -> Word8 -> Word8 -> Word8 -> m Color
- colorInterpolate :: (HasCallStack, MonadIO m) => Color -> Color -> Double -> m Color
- colorLighten :: (HasCallStack, MonadIO m) => Color -> m Color
- colorNew :: (HasCallStack, MonadIO m) => Word8 -> Word8 -> Word8 -> Word8 -> m Color
- colorShade :: (HasCallStack, MonadIO m) => Color -> Double -> m Color
- colorSubtract :: (HasCallStack, MonadIO m) => Color -> Color -> m Color
- colorToHls :: (HasCallStack, MonadIO m) => Color -> m (Float, Float, Float)
- colorToPixel :: (HasCallStack, MonadIO m) => Color -> m Word32
- colorToString :: (HasCallStack, MonadIO m) => Color -> m Text
- getColorAlpha :: MonadIO m => Color -> m Word8
- setColorAlpha :: MonadIO m => Color -> Word8 -> m ()
- getColorBlue :: MonadIO m => Color -> m Word8
- setColorBlue :: MonadIO m => Color -> Word8 -> m ()
- getColorGreen :: MonadIO m => Color -> m Word8
- setColorGreen :: MonadIO m => Color -> Word8 -> m ()
- getColorRed :: MonadIO m => Color -> m Word8
- setColorRed :: MonadIO m => Color -> Word8 -> m ()
Exported types
Memory-managed wrapper type.
Instances
Eq Color Source # | |
GBoxed Color Source # | |
Defined in GI.Clutter.Structs.Color | |
ManagedPtrNewtype Color Source # | |
Defined in GI.Clutter.Structs.Color toManagedPtr :: Color -> ManagedPtr Color | |
TypedObject Color Source # | |
Defined in GI.Clutter.Structs.Color | |
HasParentTypes Color Source # | |
Defined in GI.Clutter.Structs.Color | |
tag ~ 'AttrSet => Constructible Color tag Source # | |
IsGValue (Maybe Color) Source # | Convert |
Defined in GI.Clutter.Structs.Color gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Color -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Color) | |
type ParentTypes Color Source # | |
Defined in GI.Clutter.Structs.Color |
Methods
Click to display all available methods, including inherited ones
add
Adds a
to b
and saves the resulting color inside result
.
The alpha channel of result
is set as as the maximum value
between the alpha channels of a
and b
.
alloc
:: (HasCallStack, MonadIO m) | |
=> m Color | Returns: the newly allocated |
Allocates a new, transparent black Color
.
Since: 1.12
copy
:: (HasCallStack, MonadIO m) | |
=> Color |
|
-> m Color | Returns: an allocated copy of |
Makes a copy of the color structure. The result must be
freed using colorFree
.
Since: 0.2
darken
:: (HasCallStack, MonadIO m) | |
=> Color |
|
-> m Color |
Darkens color
by a fixed amount, and saves the changed color
in result
.
equal
free
:: (HasCallStack, MonadIO m) | |
=> Color |
|
-> m () |
Frees a color structure created with colorCopy
.
Since: 0.2
fromHls
:: (HasCallStack, MonadIO m) | |
=> Float |
|
-> Float |
|
-> Float |
|
-> m Color |
Converts a color expressed in HLS (hue, luminance and saturation)
values into a Color
.
fromPixel
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Color |
Converts pixel
from the packed representation of a four 8 bit channel
color to a Color
.
fromString
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m (Bool, Color) |
Parses a string definition of a color, filling the Color
.red
,
Color
.green
, Color
.blue
and Color
.alpha
fields
of color
.
The color
is not allocated.
The format of str
can be either one of:
- a standard name (as taken from the X11 rgb.txt file)
- an hexadecimal value in the form:
#rgb
,#rrggbb
,#rgba
, or#rrggbbaa
- a RGB color in the form:
rgb(r, g, b)
- a RGB color in the form:
rgba(r, g, b, a)
- a HSL color in the form:
hsl(h, s, l)
- a HSL color in the form:
hsla(h, s, l, a)
where 'r', 'g', 'b' and 'a' are (respectively) the red, green, blue color intensities and the opacity. The 'h', 's' and 'l' are (respectively) the hue, saturation and luminance values.
In the rgb()
and rgba()
formats, the 'r', 'g', and 'b' values are either
integers between 0 and 255, or percentage values in the range between 0%
and 100%; the percentages require the '%' character. The 'a' value, if
specified, can only be a floating point value between 0.0 and 1.0.
In the hls()
and hlsa()
formats, the 'h' value (hue) is an angle between
0 and 360.0 degrees; the 'l' and 's' values (luminance and saturation) are
percentage values in the range between 0% and 100%. The 'a' value, if specified,
can only be a floating point value between 0.0 and 1.0.
Whitespace inside the definitions is ignored; no leading whitespace is allowed.
If the alpha component is not specified then it is assumed to be set to be fully opaque.
Since: 1.0
getStatic
:: (HasCallStack, MonadIO m) | |
=> StaticColor |
|
-> m Color | Returns: a pointer to a static color; the returned pointer is owned by Clutter and it should never be modified or freed |
Retrieves a static color for the given color
name
Static colors are created by Clutter and are guaranteed to always be available and valid
Since: 1.6
hash
:: (HasCallStack, MonadIO m) | |
=> Color |
|
-> m Word32 | Returns: a hash value corresponding to the color |
init
:: (HasCallStack, MonadIO m) | |
=> Color |
|
-> Word8 |
|
-> Word8 |
|
-> Word8 |
|
-> Word8 |
|
-> m Color | Returns: the initialized |
Initializes color
with the given values.
Since: 1.12
interpolate
:: (HasCallStack, MonadIO m) | |
=> Color |
|
-> Color |
|
-> Double |
|
-> m Color |
Interpolates between initial
and final
Color
s
using progress
Since: 1.6
lighten
:: (HasCallStack, MonadIO m) | |
=> Color |
|
-> m Color |
Lightens color
by a fixed amount, and saves the changed color
in result
.
new
:: (HasCallStack, MonadIO m) | |
=> Word8 |
|
-> Word8 |
|
-> Word8 |
|
-> Word8 |
|
-> m Color | Returns: the newly allocated color.
Use |
Creates a new Color
with the given values.
This function is the equivalent of:
clutter_color_init (clutter_color_alloc (), red, green, blue, alpha);
Since: 0.8
shade
:: (HasCallStack, MonadIO m) | |
=> Color |
|
-> Double |
|
-> m Color |
Shades color
by factor
and saves the modified color into result
.
subtract
Subtracts b
from a
and saves the resulting color inside result
.
This function assumes that the components of a
are greater than the
components of b
; the result is, otherwise, undefined.
The alpha channel of result
is set as the minimum value
between the alpha channels of a
and b
.
toHls
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.
toPixel
:: (HasCallStack, MonadIO m) | |
=> Color |
|
-> m Word32 | Returns: a packed color |
Converts color
into a packed 32 bit integer, containing
all the four 8 bit channels used by Color
.
toString
:: (HasCallStack, MonadIO m) | |
=> Color |
|
-> m Text | Returns: a newly-allocated text string |
Returns a textual specification of color
in the hexadecimal form
<literal>#rrggbbaa</literal>, where <literal>r</literal>,
<literal>g</literal>, <literal>b</literal> and <literal>a</literal> are
hexadecimal digits representing the red, green, blue and alpha components
respectively.
Since: 0.2
Properties
alpha
alpha component, between 0 and 255
getColorAlpha :: MonadIO m => Color -> m Word8 Source #
Get the value of the “alpha
” field.
When overloading is enabled, this is equivalent to
get
color #alpha
setColorAlpha :: MonadIO m => Color -> Word8 -> m () Source #
Set the value of the “alpha
” field.
When overloading is enabled, this is equivalent to
set
color [ #alpha:=
value ]
blue
blue component, between 0 and 255
getColorBlue :: MonadIO m => Color -> m Word8 Source #
Get the value of the “blue
” field.
When overloading is enabled, this is equivalent to
get
color #blue
setColorBlue :: MonadIO m => Color -> Word8 -> m () Source #
Set the value of the “blue
” field.
When overloading is enabled, this is equivalent to
set
color [ #blue:=
value ]
green
green component, between 0 and 255
getColorGreen :: MonadIO m => Color -> m Word8 Source #
Get the value of the “green
” field.
When overloading is enabled, this is equivalent to
get
color #green
setColorGreen :: MonadIO m => Color -> Word8 -> m () Source #
Set the value of the “green
” field.
When overloading is enabled, this is equivalent to
set
color [ #green:=
value ]
red
red component, between 0 and 255
getColorRed :: MonadIO m => Color -> m Word8 Source #
Get the value of the “red
” field.
When overloading is enabled, this is equivalent to
get
color #red
setColorRed :: MonadIO m => Color -> Word8 -> m () Source #
Set the value of the “red
” field.
When overloading is enabled, this is equivalent to
set
color [ #red:=
value ]