2006-05-29 08:59:36 +00:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 OpenedHand
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2010-03-01 12:56:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2006-05-29 08:59:36 +00:00
|
|
|
*/
|
|
|
|
|
2006-06-21 22:34:25 +00:00
|
|
|
/**
|
|
|
|
* SECTION:clutter-color
|
|
|
|
* @short_description: Color management and manipulation.
|
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* #ClutterColor is a simple type for representing colors in Clutter.
|
|
|
|
*
|
|
|
|
* A #ClutterColor is expressed as a 4-tuple of values ranging from
|
|
|
|
* zero to 255, one for each color channel plus one for the alpha.
|
2009-10-07 10:40:41 +00:00
|
|
|
*
|
|
|
|
* The alpha channel is fully opaque at 255 and fully transparent at 0.
|
2006-06-21 22:34:25 +00:00
|
|
|
*/
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-10-26 16:29:31 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 14:03:28 +00:00
|
|
|
#include <pango/pango-attributes.h>
|
|
|
|
|
2010-10-11 14:04:54 +00:00
|
|
|
#include "clutter-interval.h"
|
2006-12-05 04:56:24 +00:00
|
|
|
#include "clutter-main.h"
|
2006-05-29 08:59:36 +00:00
|
|
|
#include "clutter-color.h"
|
2006-12-05 04:56:24 +00:00
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-debug.h"
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2010-04-06 09:54:20 +00:00
|
|
|
/* XXX - keep in sync with the ClutterStaticColor enumeration order */
|
|
|
|
static const ClutterColor const static_colors[] = {
|
|
|
|
/* CGA/EGA color palette */
|
|
|
|
{ 0xff, 0xff, 0xff, 0xff }, /* white */
|
|
|
|
{ 0x00, 0x00, 0x00, 0xff }, /* black */
|
|
|
|
{ 0xff, 0x00, 0x00, 0xff }, /* red */
|
|
|
|
{ 0x80, 0x00, 0x00, 0xff }, /* dark red */
|
|
|
|
{ 0x00, 0xff, 0x00, 0xff }, /* green */
|
|
|
|
{ 0x00, 0x80, 0x00, 0xff }, /* dark green */
|
|
|
|
{ 0x00, 0x00, 0xff, 0xff }, /* blue */
|
|
|
|
{ 0x00, 0x00, 0x80, 0xff }, /* dark blue */
|
|
|
|
{ 0x00, 0xff, 0xff, 0xff }, /* cyan */
|
|
|
|
{ 0x00, 0x80, 0x80, 0xff }, /* dark cyan */
|
|
|
|
{ 0xff, 0x00, 0xff, 0xff }, /* magenta */
|
|
|
|
{ 0x80, 0x00, 0x80, 0xff }, /* dark magenta */
|
|
|
|
{ 0xff, 0xff, 0x00, 0xff }, /* yellow */
|
|
|
|
{ 0x80, 0x80, 0x00, 0xff }, /* dark yellow */
|
|
|
|
{ 0xa0, 0xa0, 0xa4, 0xff }, /* gray */
|
|
|
|
{ 0x80, 0x80, 0x80, 0xff }, /* dark gray */
|
|
|
|
{ 0xc0, 0xc0, 0xc0, 0xff }, /* light gray */
|
|
|
|
|
|
|
|
/* Tango Icon color palette */
|
|
|
|
{ 0xed, 0xd4, 0x00, 0xff }, /* butter */
|
|
|
|
{ 0xfc, 0xe9, 0x4f, 0xff }, /* butter light */
|
|
|
|
{ 0xc4, 0xa0, 0x00, 0xff }, /* butter dark */
|
|
|
|
{ 0xf5, 0x79, 0x00, 0xff }, /* orange */
|
|
|
|
{ 0xfc, 0xaf, 0x3e, 0xff }, /* orange light */
|
|
|
|
{ 0xce, 0x5c, 0x00, 0xff }, /* orange dark */
|
|
|
|
{ 0xc1, 0x7d, 0x11, 0xff }, /* chocolate */
|
|
|
|
{ 0xe9, 0xb9, 0x6e, 0xff }, /* chocolate light */
|
|
|
|
{ 0x8f, 0x59, 0x02, 0xff }, /* chocolate dark */
|
|
|
|
{ 0x73, 0xd2, 0x16, 0xff }, /* chameleon */
|
|
|
|
{ 0x8a, 0xe2, 0x34, 0xff }, /* chameleon light */
|
|
|
|
{ 0x4e, 0x9a, 0x06, 0xff }, /* chameleon dark */
|
|
|
|
{ 0x34, 0x65, 0xa4, 0xff }, /* sky blue */
|
|
|
|
{ 0x72, 0x9f, 0xcf, 0xff }, /* sky blue light */
|
|
|
|
{ 0x20, 0x4a, 0x87, 0xff }, /* sky blue dark */
|
|
|
|
{ 0x75, 0x50, 0x7b, 0xff }, /* plum */
|
|
|
|
{ 0xad, 0x7f, 0xa8, 0xff }, /* plum light */
|
|
|
|
{ 0x5c, 0x35, 0x66, 0xff }, /* plum dark */
|
|
|
|
{ 0xcc, 0x00, 0x00, 0xff }, /* scarlet red */
|
|
|
|
{ 0xef, 0x29, 0x29, 0xff }, /* scarlet red light */
|
|
|
|
{ 0xa4, 0x00, 0x00, 0xff }, /* scarlet red dark */
|
|
|
|
{ 0xee, 0xee, 0xec, 0xff }, /* aluminium 1 */
|
|
|
|
{ 0xd3, 0xd7, 0xcf, 0xff }, /* aluminium 2 */
|
|
|
|
{ 0xba, 0xbd, 0xb6, 0xff }, /* aluminium 3 */
|
|
|
|
{ 0x88, 0x8a, 0x85, 0xff }, /* aluminium 4 */
|
|
|
|
{ 0x55, 0x57, 0x53, 0xff }, /* aluminium 5 */
|
|
|
|
{ 0x2e, 0x34, 0x36, 0xff }, /* aluminium 6 */
|
|
|
|
|
|
|
|
/* last color */
|
|
|
|
{ 0x00, 0x00, 0x00, 0x00 } /* transparent */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_color_get_static:
|
|
|
|
* @color: the named global color
|
|
|
|
*
|
|
|
|
* Retrieves a static color for the given @color name
|
|
|
|
*
|
|
|
|
* Static colors are created by Clutter and are guaranteed to always be
|
|
|
|
* available and valid
|
|
|
|
*
|
|
|
|
* Return value: a pointer to a static color; the returned pointer
|
|
|
|
* is owned by Clutter and it should never be modified or freed
|
|
|
|
*
|
2011-01-17 15:22:48 +00:00
|
|
|
* Since: 1.6
|
2010-04-06 09:54:20 +00:00
|
|
|
*/
|
Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.
We always used it to conform to the platform, at least for public-facing
API.
At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.
Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:
https://bugzilla.gnome.org/show_bug.cgi?id=644611
Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 14:49:20 +00:00
|
|
|
const ClutterColor *
|
2010-04-06 09:54:20 +00:00
|
|
|
clutter_color_get_static (ClutterStaticColor color)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (color >= CLUTTER_COLOR_WHITE &&
|
|
|
|
color <= CLUTTER_COLOR_TRANSPARENT, NULL);
|
|
|
|
|
|
|
|
return &static_colors[color];
|
|
|
|
}
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_add:
|
2009-02-28 16:16:09 +00:00
|
|
|
* @a: a #ClutterColor
|
|
|
|
* @b: a #ClutterColor
|
2010-09-08 16:04:21 +00:00
|
|
|
* @result: (out caller-allocates): return location for the result
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* Adds @a to @b and saves the resulting color inside @result.
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* The alpha channel of @result is set as as the maximum value
|
|
|
|
* between the alpha channels of @a and @b.
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*/
|
|
|
|
void
|
2009-02-28 16:16:09 +00:00
|
|
|
clutter_color_add (const ClutterColor *a,
|
|
|
|
const ClutterColor *b,
|
|
|
|
ClutterColor *result)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
g_return_if_fail (a != NULL);
|
|
|
|
g_return_if_fail (b != NULL);
|
|
|
|
g_return_if_fail (result != NULL);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
result->red = CLAMP (a->red + b->red, 0, 255);
|
|
|
|
result->green = CLAMP (a->green + b->green, 0, 255);
|
|
|
|
result->blue = CLAMP (a->blue + b->blue, 0, 255);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
result->alpha = MAX (a->alpha, b->alpha);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_color_subtract:
|
2009-02-28 16:16:09 +00:00
|
|
|
* @a: a #ClutterColor
|
|
|
|
* @b: a #ClutterColor
|
2010-09-08 16:04:21 +00:00
|
|
|
* @result: (out caller-allocates): return location for the result
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* Subtracts @b from @a and saves the resulting color inside @result.
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* 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.
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*/
|
|
|
|
void
|
2009-02-28 16:16:09 +00:00
|
|
|
clutter_color_subtract (const ClutterColor *a,
|
|
|
|
const ClutterColor *b,
|
|
|
|
ClutterColor *result)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
g_return_if_fail (a != NULL);
|
|
|
|
g_return_if_fail (b != NULL);
|
|
|
|
g_return_if_fail (result != NULL);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
result->red = CLAMP (a->red - b->red, 0, 255);
|
|
|
|
result->green = CLAMP (a->green - b->green, 0, 255);
|
|
|
|
result->blue = CLAMP (a->blue - b->blue, 0, 255);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
result->alpha = MIN (a->alpha, b->alpha);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_color_lighten:
|
2009-02-28 16:16:09 +00:00
|
|
|
* @color: a #ClutterColor
|
2010-09-08 16:04:21 +00:00
|
|
|
* @result: (out caller-allocates): return location for the lighter color
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* Lightens @color by a fixed amount, and saves the changed color
|
|
|
|
* in @result.
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*/
|
|
|
|
void
|
2009-02-28 16:16:09 +00:00
|
|
|
clutter_color_lighten (const ClutterColor *color,
|
|
|
|
ClutterColor *result)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
clutter_color_shade (color, 1.3, result);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_color_darken:
|
2009-02-28 16:16:09 +00:00
|
|
|
* @color: a #ClutterColor
|
2010-09-08 16:04:21 +00:00
|
|
|
* @result: (out caller-allocates): return location for the darker color
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* Darkens @color by a fixed amount, and saves the changed color
|
|
|
|
* in @result.
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*/
|
|
|
|
void
|
2009-02-28 16:16:09 +00:00
|
|
|
clutter_color_darken (const ClutterColor *color,
|
|
|
|
ClutterColor *result)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
clutter_color_shade (color, 0.7, result);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
}
|
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_to_hls:
|
2009-02-28 16:16:09 +00:00
|
|
|
* @color: a #ClutterColor
|
2010-09-08 14:37:58 +00:00
|
|
|
* @hue: (out): return location for the hue value or %NULL
|
|
|
|
* @luminance: (out): return location for the luminance value or %NULL
|
|
|
|
* @saturation: (out): return location for the saturation value or %NULL
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*
|
2009-03-17 00:01:56 +00:00
|
|
|
* Converts @color to the HLS format.
|
2009-02-28 16:16:09 +00:00
|
|
|
*
|
2009-03-17 00:01:56 +00:00
|
|
|
* The @hue value is in the 0 .. 360 range. The @luminance and
|
|
|
|
* @saturation values are in the 0 .. 1 range.
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*/
|
2009-03-17 00:01:56 +00:00
|
|
|
void
|
|
|
|
clutter_color_to_hls (const ClutterColor *color,
|
|
|
|
float *hue,
|
|
|
|
float *luminance,
|
|
|
|
float *saturation)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
{
|
2009-03-17 00:01:56 +00:00
|
|
|
float red, green, blue;
|
|
|
|
float min, max, delta;
|
|
|
|
float h, l, s;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
g_return_if_fail (color != NULL);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
red = color->red / 255.0;
|
|
|
|
green = color->green / 255.0;
|
|
|
|
blue = color->blue / 255.0;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
|
|
if (red > green)
|
|
|
|
{
|
|
|
|
if (red > blue)
|
|
|
|
max = red;
|
|
|
|
else
|
|
|
|
max = blue;
|
|
|
|
|
|
|
|
if (green < blue)
|
|
|
|
min = green;
|
|
|
|
else
|
|
|
|
min = blue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (green > blue)
|
|
|
|
max = green;
|
|
|
|
else
|
|
|
|
max = blue;
|
|
|
|
|
|
|
|
if (red < blue)
|
|
|
|
min = red;
|
|
|
|
else
|
|
|
|
min = blue;
|
|
|
|
}
|
|
|
|
|
|
|
|
l = (max + min) / 2;
|
|
|
|
s = 0;
|
|
|
|
h = 0;
|
|
|
|
|
|
|
|
if (max != min)
|
|
|
|
{
|
2009-03-17 00:01:56 +00:00
|
|
|
if (l <= 0.5)
|
|
|
|
s = (max - min) / (max + min);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
else
|
2009-03-17 00:01:56 +00:00
|
|
|
s = (max - min) / (2.0 - max - min);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
|
|
delta = max - min;
|
2008-10-30 16:37:55 +00:00
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
if (red == max)
|
2009-03-17 00:01:56 +00:00
|
|
|
h = (green - blue) / delta;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
else if (green == max)
|
2009-03-17 00:01:56 +00:00
|
|
|
h = 2.0 + (blue - red) / delta;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
else if (blue == max)
|
2009-03-17 00:01:56 +00:00
|
|
|
h = 4.0 + (red - green) / delta;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
|
|
h *= 60;
|
2008-10-30 16:37:55 +00:00
|
|
|
|
2007-01-16 10:39:18 +00:00
|
|
|
if (h < 0)
|
2009-03-17 00:01:56 +00:00
|
|
|
h += 360.0;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hue)
|
2007-05-10 11:37:45 +00:00
|
|
|
*hue = h;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
|
|
if (luminance)
|
2007-05-10 11:37:45 +00:00
|
|
|
*luminance = l;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
|
|
if (saturation)
|
2007-05-10 11:37:45 +00:00
|
|
|
*saturation = s;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
}
|
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_from_hls:
|
|
|
|
* @color: (out): return location for a #ClutterColor
|
|
|
|
* @hue: hue value, in the 0 .. 360 range
|
|
|
|
* @luminance: luminance value, in the 0 .. 1 range
|
|
|
|
* @saturation: saturation value, in the 0 .. 1 range
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*
|
|
|
|
* Converts a color expressed in HLS (hue, luminance and saturation)
|
|
|
|
* values into a #ClutterColor.
|
|
|
|
*/
|
|
|
|
void
|
2009-03-17 00:01:56 +00:00
|
|
|
clutter_color_from_hls (ClutterColor *color,
|
|
|
|
float hue,
|
|
|
|
float luminance,
|
|
|
|
float saturation)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2009-03-17 00:01:56 +00:00
|
|
|
float tmp1, tmp2;
|
|
|
|
float tmp3[3];
|
|
|
|
float clr[3];
|
|
|
|
int i;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
hue /= 360.0;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
if (saturation == 0)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
{
|
2009-07-27 11:04:40 +00:00
|
|
|
color->red = color->green = color->blue = (luminance * 255);
|
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
return;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
}
|
2007-05-10 11:37:45 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
if (luminance <= 0.5)
|
|
|
|
tmp2 = luminance * (1.0 + saturation);
|
|
|
|
else
|
|
|
|
tmp2 = luminance + saturation - (luminance * saturation);
|
2007-05-10 11:37:45 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
tmp1 = 2.0 * luminance - tmp2;
|
2007-05-10 11:37:45 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
tmp3[0] = hue + 1.0 / 3.0;
|
|
|
|
tmp3[1] = hue;
|
|
|
|
tmp3[2] = hue - 1.0 / 3.0;
|
2007-05-10 11:37:45 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
if (tmp3[i] < 0)
|
|
|
|
tmp3[i] += 1.0;
|
2009-07-27 11:04:40 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
if (tmp3[i] > 1)
|
|
|
|
tmp3[i] -= 1.0;
|
|
|
|
|
|
|
|
if (6.0 * tmp3[i] < 1.0)
|
|
|
|
clr[i] = tmp1 + (tmp2 - tmp1) * tmp3[i] * 6.0;
|
|
|
|
else if (2.0 * tmp3[i] < 1.0)
|
|
|
|
clr[i] = tmp2;
|
|
|
|
else if (3.0 * tmp3[i] < 2.0)
|
|
|
|
clr[i] = (tmp1 + (tmp2 - tmp1) * ((2.0 / 3.0) - tmp3[i]) * 6.0);
|
|
|
|
else
|
|
|
|
clr[i] = tmp1;
|
|
|
|
}
|
2007-05-10 11:37:45 +00:00
|
|
|
|
2009-10-26 16:29:31 +00:00
|
|
|
color->red = floorf (clr[0] * 255.0 + 0.5);
|
|
|
|
color->green = floorf (clr[1] * 255.0 + 0.5);
|
|
|
|
color->blue = floorf (clr[2] * 255.0 + 0.5);
|
2007-05-10 11:37:45 +00:00
|
|
|
}
|
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_shade:
|
2009-02-28 16:16:09 +00:00
|
|
|
* @color: a #ClutterColor
|
2009-03-17 00:01:56 +00:00
|
|
|
* @factor: the shade factor to apply
|
2010-09-08 16:04:21 +00:00
|
|
|
* @result: (out caller-allocates): return location for the shaded color
|
2009-03-17 00:01:56 +00:00
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* Shades @color by @factor and saves the modified color into @result.
|
2007-01-16 10:39:18 +00:00
|
|
|
*/
|
2009-03-17 00:01:56 +00:00
|
|
|
void
|
|
|
|
clutter_color_shade (const ClutterColor *color,
|
|
|
|
gdouble factor,
|
|
|
|
ClutterColor *result)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
{
|
2009-03-17 00:01:56 +00:00
|
|
|
float h, l, s;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
g_return_if_fail (result != NULL);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
clutter_color_to_hls (color, &h, &l, &s);
|
2007-05-10 11:37:45 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
l *= factor;
|
|
|
|
if (l > 1.0)
|
|
|
|
l = 1.0;
|
2007-05-10 11:37:45 +00:00
|
|
|
else if (l < 0)
|
|
|
|
l = 0;
|
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
s *= factor;
|
|
|
|
if (s > 1.0)
|
|
|
|
s = 1.0;
|
2007-05-10 11:37:45 +00:00
|
|
|
else if (s < 0)
|
|
|
|
s = 0;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-03-17 00:01:56 +00:00
|
|
|
clutter_color_from_hls (result, h, l, s);
|
2009-02-28 16:16:09 +00:00
|
|
|
|
|
|
|
result->alpha = color->alpha;
|
|
|
|
}
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_to_pixel:
|
2009-02-28 16:16:09 +00:00
|
|
|
* @color: a #ClutterColor
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* Converts @color into a packed 32 bit integer, containing
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
* all the four 8 bit channels used by #ClutterColor.
|
|
|
|
*
|
|
|
|
* Return value: a packed color
|
|
|
|
*/
|
|
|
|
guint32
|
2009-02-28 16:16:09 +00:00
|
|
|
clutter_color_to_pixel (const ClutterColor *color)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
g_return_val_if_fail (color != NULL, 0);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
return (color->alpha |
|
|
|
|
color->blue << 8 |
|
|
|
|
color->green << 16 |
|
|
|
|
color->red << 24);
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_from_pixel:
|
2010-09-08 16:04:21 +00:00
|
|
|
* @color: (out caller-allocates): return location for a #ClutterColor
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
* @pixel: a 32 bit packed integer containing a color
|
|
|
|
*
|
|
|
|
* Converts @pixel from the packed representation of a four 8 bit channel
|
|
|
|
* color to a #ClutterColor.
|
|
|
|
*/
|
2006-05-29 08:59:36 +00:00
|
|
|
void
|
2009-02-28 16:16:09 +00:00
|
|
|
clutter_color_from_pixel (ClutterColor *color,
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
guint32 pixel)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
g_return_if_fail (color != NULL);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
color->red = pixel >> 24;
|
|
|
|
color->green = (pixel >> 16) & 0xff;
|
|
|
|
color->blue = (pixel >> 8) & 0xff;
|
|
|
|
color->alpha = pixel & 0xff;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
color: Support CSS color definitions
The CSS Color Module 3, available at:
http://www.w3.org/TR/css3-color/
allows defining colors as:
rgb ( r, g, b )
rgba ( r, g, b, a)
along with the usual hexadecimal and named notations.
The r, g, and b channels can be:
• integers between 0 and 255
• percentages, between 0% and 100%
The alpha channel, if included using the rgba() modifier, can be a
floating point value between 0.0 and 1.0.
The ClutterColor parser should support this notation.
2010-11-22 14:22:56 +00:00
|
|
|
static inline void
|
|
|
|
skip_whitespace (gchar **str)
|
|
|
|
{
|
|
|
|
while (g_ascii_isspace (**str))
|
|
|
|
*str += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
parse_rgb_value (gchar *str,
|
|
|
|
guint8 *color,
|
|
|
|
gchar **endp)
|
|
|
|
{
|
|
|
|
gdouble number;
|
|
|
|
gchar *p;
|
|
|
|
|
|
|
|
skip_whitespace (&str);
|
|
|
|
|
|
|
|
number = g_ascii_strtod (str, endp);
|
|
|
|
|
|
|
|
p = *endp;
|
|
|
|
|
|
|
|
skip_whitespace (&p);
|
|
|
|
|
|
|
|
if (*p == '%')
|
|
|
|
{
|
|
|
|
*endp = (gchar *) (p + 1);
|
|
|
|
|
|
|
|
*color = CLAMP (number / 100.0, 0.0, 1.0) * 255;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*color = CLAMP (number, 0, 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
parse_rgba (ClutterColor *color,
|
|
|
|
gchar *str,
|
|
|
|
gboolean has_alpha)
|
|
|
|
{
|
|
|
|
skip_whitespace (&str);
|
|
|
|
|
|
|
|
if (*str != '(')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
str += 1;
|
|
|
|
|
|
|
|
/* red */
|
|
|
|
parse_rgb_value (str, &color->red, &str);
|
|
|
|
skip_whitespace (&str);
|
|
|
|
if (*str != ',')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
str += 1;
|
|
|
|
|
|
|
|
/* green */
|
|
|
|
parse_rgb_value (str, &color->green, &str);
|
|
|
|
skip_whitespace (&str);
|
|
|
|
if (*str != ',')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
str += 1;
|
|
|
|
|
|
|
|
/* blue */
|
|
|
|
parse_rgb_value (str, &color->blue, &str);
|
|
|
|
skip_whitespace (&str);
|
|
|
|
|
|
|
|
/* alpha (optional); since the alpha channel value can only
|
|
|
|
* be between 0 and 1 we don't use the parse_rgb_value()
|
|
|
|
* function
|
|
|
|
*/
|
|
|
|
if (has_alpha)
|
|
|
|
{
|
|
|
|
gdouble number;
|
|
|
|
|
|
|
|
if (*str != ',')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
str += 1;
|
|
|
|
|
|
|
|
skip_whitespace (&str);
|
|
|
|
number = g_ascii_strtod (str, &str);
|
|
|
|
|
|
|
|
color->alpha = CLAMP (number * 255.0, 0, 255);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
color->alpha = 255;
|
|
|
|
|
|
|
|
skip_whitespace (&str);
|
|
|
|
if (*str != ')')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-11-22 15:02:47 +00:00
|
|
|
static gboolean
|
2010-11-22 15:07:01 +00:00
|
|
|
parse_hsla (ClutterColor *color,
|
|
|
|
gchar *str,
|
|
|
|
gboolean has_alpha)
|
2010-11-22 15:02:47 +00:00
|
|
|
{
|
|
|
|
gdouble number;
|
|
|
|
gdouble h, l, s;
|
|
|
|
|
|
|
|
skip_whitespace (&str);
|
|
|
|
|
|
|
|
if (*str != '(')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
str += 1;
|
|
|
|
|
|
|
|
/* hue */
|
|
|
|
skip_whitespace (&str);
|
|
|
|
/* we don't do any angle normalization here because
|
|
|
|
* clutter_color_from_hls() will do it for us
|
|
|
|
*/
|
|
|
|
number = g_ascii_strtod (str, &str);
|
|
|
|
skip_whitespace (&str);
|
|
|
|
if (*str != ',')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
h = number;
|
|
|
|
|
|
|
|
str += 1;
|
|
|
|
|
|
|
|
/* saturation */
|
|
|
|
skip_whitespace (&str);
|
|
|
|
number = g_ascii_strtod (str, &str);
|
|
|
|
skip_whitespace (&str);
|
|
|
|
if (*str != '%')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
str += 1;
|
|
|
|
|
|
|
|
s = CLAMP (number / 100.0, 0.0, 1.0);
|
|
|
|
skip_whitespace (&str);
|
|
|
|
if (*str != ',')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
str += 1;
|
|
|
|
|
|
|
|
/* luminance */
|
|
|
|
skip_whitespace (&str);
|
|
|
|
number = g_ascii_strtod (str, &str);
|
|
|
|
skip_whitespace (&str);
|
|
|
|
if (*str != '%')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
str += 1;
|
|
|
|
|
|
|
|
l = CLAMP (number / 100.0, 0.0, 1.0);
|
2011-11-08 01:00:45 +00:00
|
|
|
skip_whitespace (&str);
|
2010-11-22 15:07:01 +00:00
|
|
|
|
|
|
|
/* alpha (optional); since the alpha channel value can only
|
|
|
|
* be between 0 and 1 we don't use the parse_rgb_value()
|
|
|
|
* function
|
|
|
|
*/
|
|
|
|
if (has_alpha)
|
|
|
|
{
|
|
|
|
if (*str != ',')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
str += 1;
|
|
|
|
|
|
|
|
skip_whitespace (&str);
|
|
|
|
number = g_ascii_strtod (str, &str);
|
|
|
|
|
|
|
|
color->alpha = CLAMP (number * 255.0, 0, 255);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
color->alpha = 255;
|
|
|
|
|
2010-11-22 15:02:47 +00:00
|
|
|
skip_whitespace (&str);
|
|
|
|
if (*str != ')')
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
clutter_color_from_hls (color, h, l, s);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-12-05 04:56:24 +00:00
|
|
|
/**
|
2009-02-28 16:16:09 +00:00
|
|
|
* clutter_color_from_string:
|
2010-09-08 16:04:21 +00:00
|
|
|
* @color: (out caller-allocates): return location for a #ClutterColor
|
2010-12-08 13:59:53 +00:00
|
|
|
* @str: a string specifiying a color
|
2006-12-05 04:56:24 +00:00
|
|
|
*
|
|
|
|
* Parses a string definition of a color, filling the
|
2007-05-25 16:35:57 +00:00
|
|
|
* <structfield>red</structfield>, <structfield>green</structfield>,
|
|
|
|
* <structfield>blue</structfield> and <structfield>alpha</structfield>
|
2010-12-08 13:59:53 +00:00
|
|
|
* channels of @color.
|
2009-02-28 16:16:09 +00:00
|
|
|
*
|
|
|
|
* The @color is not allocated.
|
2006-12-05 04:56:24 +00:00
|
|
|
*
|
color: Support CSS color definitions
The CSS Color Module 3, available at:
http://www.w3.org/TR/css3-color/
allows defining colors as:
rgb ( r, g, b )
rgba ( r, g, b, a)
along with the usual hexadecimal and named notations.
The r, g, and b channels can be:
• integers between 0 and 255
• percentages, between 0% and 100%
The alpha channel, if included using the rgba() modifier, can be a
floating point value between 0.0 and 1.0.
The ClutterColor parser should support this notation.
2010-11-22 14:22:56 +00:00
|
|
|
* The format of @str can be either one of:
|
2010-11-29 12:23:14 +00:00
|
|
|
*
|
color: Support CSS color definitions
The CSS Color Module 3, available at:
http://www.w3.org/TR/css3-color/
allows defining colors as:
rgb ( r, g, b )
rgba ( r, g, b, a)
along with the usual hexadecimal and named notations.
The r, g, and b channels can be:
• integers between 0 and 255
• percentages, between 0% and 100%
The alpha channel, if included using the rgba() modifier, can be a
floating point value between 0.0 and 1.0.
The ClutterColor parser should support this notation.
2010-11-22 14:22:56 +00:00
|
|
|
* <itemizedlist>
|
2010-12-08 13:59:53 +00:00
|
|
|
* <listitem>
|
|
|
|
* <para>a standard name (as taken from the X11 rgb.txt file)</para>
|
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
|
|
|
* <para>an hexadecimal value in the form: <literal>#rgb</literal>,
|
|
|
|
* <literal>#rrggbb</literal>, <literal>#rgba</literal> or
|
|
|
|
* <literal>#rrggbbaa</literal></para>
|
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
|
|
|
* <para>a RGB color in the form: <literal>rgb(r, g, b)</literal></para>
|
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
|
|
|
* <para>a RGB color in the form: <literal>rgba(r, g, b, a)</literal></para>
|
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
|
|
|
* <para>a HSL color in the form: <literal>hsl(h, s, l)</literal></para>
|
|
|
|
* </listitem>
|
2010-12-08 14:26:27 +00:00
|
|
|
* <listitem>
|
2010-12-08 13:59:53 +00:00
|
|
|
* <para>a HSL color in the form: <literal>hsla(h, s, l, a)</literal></para>
|
|
|
|
* </listitem>
|
2010-11-29 12:23:14 +00:00
|
|
|
* </itemizedlist>
|
color: Support CSS color definitions
The CSS Color Module 3, available at:
http://www.w3.org/TR/css3-color/
allows defining colors as:
rgb ( r, g, b )
rgba ( r, g, b, a)
along with the usual hexadecimal and named notations.
The r, g, and b channels can be:
• integers between 0 and 255
• percentages, between 0% and 100%
The alpha channel, if included using the rgba() modifier, can be a
floating point value between 0.0 and 1.0.
The ClutterColor parser should support this notation.
2010-11-22 14:22:56 +00:00
|
|
|
*
|
2010-12-08 13:59:53 +00:00
|
|
|
* 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.
|
color: Support CSS color definitions
The CSS Color Module 3, available at:
http://www.w3.org/TR/css3-color/
allows defining colors as:
rgb ( r, g, b )
rgba ( r, g, b, a)
along with the usual hexadecimal and named notations.
The r, g, and b channels can be:
• integers between 0 and 255
• percentages, between 0% and 100%
The alpha channel, if included using the rgba() modifier, can be a
floating point value between 0.0 and 1.0.
The ClutterColor parser should support this notation.
2010-11-22 14:22:56 +00:00
|
|
|
*
|
2010-12-08 13:59:53 +00:00
|
|
|
* 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) it's an angle between
|
|
|
|
* 0 and 360.0 degrees; the 'l' and 's' values (luminance and saturation) are
|
|
|
|
* a floating point value between 0.0 and 1.0. The 'a' value, if specified,
|
color: Support CSS color definitions
The CSS Color Module 3, available at:
http://www.w3.org/TR/css3-color/
allows defining colors as:
rgb ( r, g, b )
rgba ( r, g, b, a)
along with the usual hexadecimal and named notations.
The r, g, and b channels can be:
• integers between 0 and 255
• percentages, between 0% and 100%
The alpha channel, if included using the rgba() modifier, can be a
floating point value between 0.0 and 1.0.
The ClutterColor parser should support this notation.
2010-11-22 14:22:56 +00:00
|
|
|
* can only be a floating point value between 0.0 and 1.0.
|
|
|
|
*
|
2010-12-08 13:59:53 +00:00
|
|
|
* Whitespace inside the definitions is ignored; no leading whitespace
|
|
|
|
* is allowed.
|
color: Support CSS color definitions
The CSS Color Module 3, available at:
http://www.w3.org/TR/css3-color/
allows defining colors as:
rgb ( r, g, b )
rgba ( r, g, b, a)
along with the usual hexadecimal and named notations.
The r, g, and b channels can be:
• integers between 0 and 255
• percentages, between 0% and 100%
The alpha channel, if included using the rgba() modifier, can be a
floating point value between 0.0 and 1.0.
The ClutterColor parser should support this notation.
2010-11-22 14:22:56 +00:00
|
|
|
*
|
|
|
|
* If the alpha component is not specified then it is assumed to be set to
|
|
|
|
* be fully opaque.
|
2006-12-05 04:56:24 +00:00
|
|
|
*
|
2010-12-08 13:59:53 +00:00
|
|
|
* Return value: %TRUE if parsing succeeded, and %FALSE otherwise
|
2006-12-05 04:56:24 +00:00
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* Since: 1.0
|
2006-12-05 04:56:24 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2009-02-28 16:16:09 +00:00
|
|
|
clutter_color_from_string (ClutterColor *color,
|
|
|
|
const gchar *str)
|
2006-12-05 04:56:24 +00:00
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
PangoColor pango_color = { 0, };
|
2006-12-05 04:56:24 +00:00
|
|
|
|
2008-10-17 08:04:03 +00:00
|
|
|
g_return_val_if_fail (color != NULL, FALSE);
|
2009-02-28 16:16:09 +00:00
|
|
|
g_return_val_if_fail (str != NULL, FALSE);
|
|
|
|
|
color: Support CSS color definitions
The CSS Color Module 3, available at:
http://www.w3.org/TR/css3-color/
allows defining colors as:
rgb ( r, g, b )
rgba ( r, g, b, a)
along with the usual hexadecimal and named notations.
The r, g, and b channels can be:
• integers between 0 and 255
• percentages, between 0% and 100%
The alpha channel, if included using the rgba() modifier, can be a
floating point value between 0.0 and 1.0.
The ClutterColor parser should support this notation.
2010-11-22 14:22:56 +00:00
|
|
|
if (strncmp (str, "rgb", 3) == 0)
|
|
|
|
{
|
|
|
|
gchar *s = (gchar *) str;
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
if (strncmp (str, "rgba", 4) == 0)
|
|
|
|
res = parse_rgba (color, s + 4, TRUE);
|
|
|
|
else
|
|
|
|
res = parse_rgba (color, s + 3, FALSE);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-11-22 15:02:47 +00:00
|
|
|
if (strncmp (str, "hsl", 3) == 0)
|
|
|
|
{
|
|
|
|
gchar *s = (gchar *) str;
|
2010-11-22 15:07:01 +00:00
|
|
|
gboolean res;
|
2010-11-22 15:02:47 +00:00
|
|
|
|
2010-11-22 15:07:01 +00:00
|
|
|
if (strncmp (str, "hsla", 4) == 0)
|
|
|
|
res = parse_hsla (color, s + 4, TRUE);
|
|
|
|
else
|
|
|
|
res = parse_hsla (color, s + 3, FALSE);
|
|
|
|
|
|
|
|
return res;
|
2010-11-22 15:02:47 +00:00
|
|
|
}
|
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
/* if the string contains a color encoded using the hexadecimal
|
2009-06-01 16:54:46 +00:00
|
|
|
* notations (#rrggbbaa or #rgba) we attempt a rough pass at
|
2009-02-28 16:16:09 +00:00
|
|
|
* parsing the color ourselves, as we need the alpha channel that
|
|
|
|
* Pango can't retrieve.
|
|
|
|
*/
|
2011-11-10 14:13:45 +00:00
|
|
|
if (str[0] == '#' && str[1] != '\0')
|
2007-05-25 16:35:57 +00:00
|
|
|
{
|
2011-11-10 14:13:45 +00:00
|
|
|
gsize length = strlen (str + 1);
|
2007-05-25 16:35:57 +00:00
|
|
|
gint32 result;
|
|
|
|
|
2011-11-10 14:13:45 +00:00
|
|
|
if (sscanf (str + 1, "%x", &result) == 1)
|
2009-06-01 16:54:46 +00:00
|
|
|
{
|
2009-10-07 12:00:57 +00:00
|
|
|
switch (length)
|
2009-06-01 16:54:46 +00:00
|
|
|
{
|
2011-11-10 14:13:45 +00:00
|
|
|
case 8: /* rrggbbaa */
|
2009-06-01 16:54:46 +00:00
|
|
|
color->red = (result >> 24) & 0xff;
|
|
|
|
color->green = (result >> 16) & 0xff;
|
|
|
|
color->blue = (result >> 8) & 0xff;
|
|
|
|
|
|
|
|
color->alpha = result & 0xff;
|
|
|
|
|
|
|
|
return TRUE;
|
2009-10-07 12:00:57 +00:00
|
|
|
|
2011-11-10 14:13:45 +00:00
|
|
|
case 6: /* #rrggbb */
|
2009-10-07 12:00:57 +00:00
|
|
|
color->red = (result >> 16) & 0xff;
|
|
|
|
color->green = (result >> 8) & 0xff;
|
|
|
|
color->blue = result & 0xff;
|
|
|
|
|
|
|
|
color->alpha = 0xff;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
2011-11-10 14:13:45 +00:00
|
|
|
case 4: /* #rgba */
|
2009-06-01 16:54:46 +00:00
|
|
|
color->red = ((result >> 12) & 0xf);
|
|
|
|
color->green = ((result >> 8) & 0xf);
|
|
|
|
color->blue = ((result >> 4) & 0xf);
|
|
|
|
color->alpha = result & 0xf;
|
|
|
|
|
|
|
|
color->red = (color->red << 4) | color->red;
|
|
|
|
color->green = (color->green << 4) | color->green;
|
|
|
|
color->blue = (color->blue << 4) | color->blue;
|
|
|
|
color->alpha = (color->alpha << 4) | color->alpha;
|
|
|
|
|
|
|
|
return TRUE;
|
2009-10-07 11:27:38 +00:00
|
|
|
|
2011-11-10 14:13:45 +00:00
|
|
|
case 3: /* #rgb */
|
2009-10-07 11:27:38 +00:00
|
|
|
color->red = ((result >> 8) & 0xf);
|
|
|
|
color->green = ((result >> 4) & 0xf);
|
|
|
|
color->blue = result & 0xf;
|
|
|
|
|
|
|
|
color->red = (color->red << 4) | color->red;
|
|
|
|
color->green = (color->green << 4) | color->green;
|
|
|
|
color->blue = (color->blue << 4) | color->blue;
|
|
|
|
|
|
|
|
color->alpha = 0xff;
|
2009-10-07 12:00:57 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
default:
|
2011-11-10 14:13:45 +00:00
|
|
|
return FALSE;
|
2009-10-07 11:27:38 +00:00
|
|
|
}
|
2009-06-01 16:54:46 +00:00
|
|
|
}
|
2007-05-25 16:35:57 +00:00
|
|
|
}
|
color: Support CSS color definitions
The CSS Color Module 3, available at:
http://www.w3.org/TR/css3-color/
allows defining colors as:
rgb ( r, g, b )
rgba ( r, g, b, a)
along with the usual hexadecimal and named notations.
The r, g, and b channels can be:
• integers between 0 and 255
• percentages, between 0% and 100%
The alpha channel, if included using the rgba() modifier, can be a
floating point value between 0.0 and 1.0.
The ClutterColor parser should support this notation.
2010-11-22 14:22:56 +00:00
|
|
|
|
2011-11-10 14:13:45 +00:00
|
|
|
/* fall back to pango for X11-style named colors; see:
|
|
|
|
*
|
|
|
|
* http://en.wikipedia.org/wiki/X11_color_names
|
|
|
|
*
|
|
|
|
* for a list. at some point we might even ship with our own list generated
|
|
|
|
* from X11/rgb.txt, like we generate the key symbols.
|
|
|
|
*/
|
2009-02-28 16:16:09 +00:00
|
|
|
if (pango_color_parse (&pango_color, str))
|
2006-12-05 04:56:24 +00:00
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
color->red = pango_color.red;
|
|
|
|
color->green = pango_color.green;
|
|
|
|
color->blue = pango_color.blue;
|
|
|
|
|
|
|
|
color->alpha = 0xff;
|
2007-10-27 12:14:18 +00:00
|
|
|
|
2006-12-05 04:56:24 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2007-05-25 16:35:57 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2006-12-05 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
2006-12-27 18:19:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_to_string:
|
|
|
|
* @color: a #ClutterColor
|
|
|
|
*
|
|
|
|
* Returns a textual specification of @color in the hexadecimal form
|
2007-10-27 12:14:18 +00:00
|
|
|
* <literal>#rrggbbaa</literal>, where <literal>r</literal>,
|
2006-12-27 18:19:34 +00:00
|
|
|
* <literal>g</literal>, <literal>b</literal> and <literal>a</literal> are
|
2010-12-08 13:59:53 +00:00
|
|
|
* hexadecimal digits representing the red, green, blue and alpha components
|
2006-12-27 18:19:34 +00:00
|
|
|
* respectively.
|
|
|
|
*
|
2010-09-08 15:41:47 +00:00
|
|
|
* Return value: (transfer full): a newly-allocated text string
|
2006-12-27 18:19:34 +00:00
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
clutter_color_to_string (const ClutterColor *color)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (color != NULL, NULL);
|
|
|
|
|
2007-10-22 15:46:56 +00:00
|
|
|
return g_strdup_printf ("#%02x%02x%02x%02x",
|
2006-12-27 18:19:34 +00:00
|
|
|
color->red,
|
|
|
|
color->green,
|
|
|
|
color->blue,
|
|
|
|
color->alpha);
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:19:08 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_equal:
|
2012-06-12 22:41:39 +00:00
|
|
|
* @v1: (type Clutter.Color): a #ClutterColor
|
|
|
|
* @v2: (type Clutter.Color): a #ClutterColor
|
2006-12-14 22:19:08 +00:00
|
|
|
*
|
|
|
|
* Compares two #ClutterColor<!-- -->s and checks if they are the same.
|
|
|
|
*
|
2009-02-28 16:16:09 +00:00
|
|
|
* This function can be passed to g_hash_table_new() as the @key_equal_func
|
|
|
|
* parameter, when using #ClutterColor<!-- -->s as keys in a #GHashTable.
|
|
|
|
*
|
2007-01-17 13:51:14 +00:00
|
|
|
* Return value: %TRUE if the two colors are the same.
|
2006-12-14 22:19:08 +00:00
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
gboolean
|
2009-02-28 16:16:09 +00:00
|
|
|
clutter_color_equal (gconstpointer v1,
|
|
|
|
gconstpointer v2)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
const ClutterColor *a, *b;
|
2006-12-14 22:19:08 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
g_return_val_if_fail (v1 != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (v2 != NULL, FALSE);
|
|
|
|
|
|
|
|
if (v1 == v2)
|
2006-12-14 22:19:08 +00:00
|
|
|
return TRUE;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
a = v1;
|
|
|
|
b = v2;
|
|
|
|
|
|
|
|
return (a->red == b->red &&
|
2006-12-14 22:19:08 +00:00
|
|
|
a->green == b->green &&
|
2009-02-28 16:16:09 +00:00
|
|
|
a->blue == b->blue &&
|
2006-12-14 22:19:08 +00:00
|
|
|
a->alpha == b->alpha);
|
|
|
|
}
|
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_hash:
|
2012-06-12 22:41:39 +00:00
|
|
|
* @v: (type Clutter.Color): a #ClutterColor
|
2009-02-28 16:16:09 +00:00
|
|
|
*
|
|
|
|
* Converts a #ClutterColor to a hash value.
|
|
|
|
*
|
|
|
|
* This function can be passed to g_hash_table_new() as the @hash_func
|
|
|
|
* parameter, when using #ClutterColor<!-- -->s as keys in a #GHashTable.
|
|
|
|
*
|
|
|
|
* Return value: a hash value corresponding to the color
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
clutter_color_hash (gconstpointer v)
|
|
|
|
{
|
|
|
|
return clutter_color_to_pixel ((const ClutterColor *) v);
|
|
|
|
}
|
|
|
|
|
2010-10-11 14:04:54 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_interpolate:
|
|
|
|
* @initial: the initial #ClutterColor
|
|
|
|
* @final: the final #ClutterColor
|
|
|
|
* @progress: the interpolation progress
|
|
|
|
* @result: (out): return location for the interpolation
|
|
|
|
*
|
|
|
|
* Interpolates between @initial and @final #ClutterColor<!-- -->s
|
|
|
|
* using @progress
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_color_interpolate (const ClutterColor *initial,
|
|
|
|
const ClutterColor *final,
|
|
|
|
gdouble progress,
|
|
|
|
ClutterColor *result)
|
|
|
|
{
|
|
|
|
g_return_if_fail (initial != NULL);
|
|
|
|
g_return_if_fail (final != NULL);
|
|
|
|
g_return_if_fail (result != NULL);
|
|
|
|
|
|
|
|
result->red = initial->red + (final->red - initial->red) * progress;
|
|
|
|
result->green = initial->green + (final->green - initial->green) * progress;
|
|
|
|
result->blue = initial->blue + (final->blue - initial->blue) * progress;
|
|
|
|
result->alpha = initial->alpha + (final->alpha - initial->alpha) * progress;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_color_progress (const GValue *a,
|
|
|
|
const GValue *b,
|
|
|
|
gdouble progress,
|
|
|
|
GValue *retval)
|
|
|
|
{
|
|
|
|
const ClutterColor *a_color = clutter_value_get_color (a);
|
|
|
|
const ClutterColor *b_color = clutter_value_get_color (b);
|
|
|
|
ClutterColor res = { 0, };
|
|
|
|
|
|
|
|
clutter_color_interpolate (a_color, b_color, progress, &res);
|
|
|
|
clutter_value_set_color (retval, &res);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:19:08 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_copy:
|
|
|
|
* @color: a #ClutterColor
|
|
|
|
*
|
|
|
|
* Makes a copy of the color structure. The result must be
|
|
|
|
* freed using clutter_color_free().
|
|
|
|
*
|
2010-09-08 16:04:21 +00:00
|
|
|
* Return value: (transfer full): an allocated copy of @color.
|
2006-12-14 22:19:08 +00:00
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
ClutterColor *
|
|
|
|
clutter_color_copy (const ClutterColor *color)
|
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
if (G_LIKELY (color != NULL))
|
|
|
|
return g_slice_dup (ClutterColor, color);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2009-02-28 16:16:09 +00:00
|
|
|
return NULL;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2006-12-14 22:19:08 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_free:
|
|
|
|
* @color: a #ClutterColor
|
|
|
|
*
|
|
|
|
* Frees a color structure created with clutter_color_copy().
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_color_free (ClutterColor *color)
|
|
|
|
{
|
2009-02-28 16:16:09 +00:00
|
|
|
if (G_LIKELY (color != NULL))
|
2008-10-17 16:23:46 +00:00
|
|
|
g_slice_free (ClutterColor, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_color_new:
|
|
|
|
* @red: red component of the color, between 0 and 255
|
|
|
|
* @green: green component of the color, between 0 and 255
|
|
|
|
* @blue: blue component of the color, between 0 and 255
|
|
|
|
* @alpha: alpha component of the color, between 0 and 255
|
|
|
|
*
|
|
|
|
* Creates a new #ClutterColor with the given values.
|
|
|
|
*
|
2012-04-13 10:26:38 +00:00
|
|
|
* This function is the equivalent of:
|
|
|
|
*
|
|
|
|
* |[
|
|
|
|
* clutter_color_init (clutter_color_alloc (), red, green, blue, alpha);
|
|
|
|
* ]|
|
|
|
|
*
|
2010-09-08 15:41:47 +00:00
|
|
|
* Return value: (transfer full): the newly allocated color.
|
|
|
|
* Use clutter_color_free() when done
|
2008-10-17 16:23:46 +00:00
|
|
|
*
|
2008-11-04 17:52:29 +00:00
|
|
|
* Since: 0.8.4
|
2008-10-17 16:23:46 +00:00
|
|
|
*/
|
|
|
|
ClutterColor *
|
|
|
|
clutter_color_new (guint8 red,
|
|
|
|
guint8 green,
|
|
|
|
guint8 blue,
|
|
|
|
guint8 alpha)
|
|
|
|
{
|
2012-04-13 10:26:38 +00:00
|
|
|
return clutter_color_init (clutter_color_alloc (),
|
|
|
|
red,
|
|
|
|
green,
|
|
|
|
blue,
|
|
|
|
alpha);
|
|
|
|
}
|
2008-10-17 16:23:46 +00:00
|
|
|
|
2012-04-13 10:26:38 +00:00
|
|
|
/**
|
|
|
|
* clutter_color_alloc:
|
|
|
|
*
|
|
|
|
* Allocates a new, transparent black #ClutterColor.
|
|
|
|
*
|
|
|
|
* Return value: (transfer full): the newly allocated #ClutterColor; use
|
|
|
|
* clutter_color_free() to free its resources
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
ClutterColor *
|
|
|
|
clutter_color_alloc (void)
|
|
|
|
{
|
|
|
|
return g_slice_new0 (ClutterColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_color_init:
|
|
|
|
* @color: a #ClutterColor
|
|
|
|
* @red: red component of the color, between 0 and 255
|
|
|
|
* @green: green component of the color, between 0 and 255
|
|
|
|
* @blue: blue component of the color, between 0 and 255
|
|
|
|
* @alpha: alpha component of the color, between 0 and 255
|
|
|
|
*
|
|
|
|
* Initializes @color with the given values.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): the initialized #ClutterColor
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
ClutterColor *
|
|
|
|
clutter_color_init (ClutterColor *color,
|
|
|
|
guint8 red,
|
|
|
|
guint8 green,
|
|
|
|
guint8 blue,
|
|
|
|
guint8 alpha)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (color != NULL, NULL);
|
2008-10-17 16:23:46 +00:00
|
|
|
|
2012-04-13 10:26:38 +00:00
|
|
|
color->red = red;
|
2008-11-05 12:16:15 +00:00
|
|
|
color->green = green;
|
2012-04-13 10:26:38 +00:00
|
|
|
color->blue = blue;
|
2008-11-05 12:16:15 +00:00
|
|
|
color->alpha = alpha;
|
2006-12-14 22:19:08 +00:00
|
|
|
|
2008-10-17 16:23:46 +00:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_value_transform_color_string (const GValue *src,
|
|
|
|
GValue *dest)
|
|
|
|
{
|
2010-04-07 23:20:18 +00:00
|
|
|
const ClutterColor *color = g_value_get_boxed (src);
|
2008-10-17 16:23:46 +00:00
|
|
|
|
2010-04-07 23:20:18 +00:00
|
|
|
if (color)
|
|
|
|
{
|
|
|
|
gchar *string = clutter_color_to_string (color);
|
|
|
|
|
|
|
|
g_value_take_string (dest, string);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_value_set_string (dest, NULL);
|
2008-10-17 16:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_value_transform_string_color (const GValue *src,
|
|
|
|
GValue *dest)
|
|
|
|
{
|
2010-04-07 23:20:18 +00:00
|
|
|
const char *str = g_value_get_string (src);
|
2008-10-17 16:23:46 +00:00
|
|
|
|
2010-04-07 23:20:18 +00:00
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
ClutterColor color = { 0, };
|
2008-10-17 16:23:46 +00:00
|
|
|
|
2010-04-07 23:20:18 +00:00
|
|
|
clutter_color_from_string (&color, str);
|
|
|
|
|
|
|
|
clutter_value_set_color (dest, &color);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
clutter_value_set_color (dest, NULL);
|
2006-12-14 22:19:08 +00:00
|
|
|
}
|
|
|
|
|
2010-10-08 14:21:57 +00:00
|
|
|
G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterColor, clutter_color,
|
|
|
|
clutter_color_copy,
|
|
|
|
clutter_color_free,
|
|
|
|
CLUTTER_REGISTER_VALUE_TRANSFORM_TO (G_TYPE_STRING, clutter_value_transform_color_string)
|
|
|
|
CLUTTER_REGISTER_VALUE_TRANSFORM_FROM (G_TYPE_STRING, clutter_value_transform_string_color)
|
|
|
|
CLUTTER_REGISTER_INTERVAL_PROGRESS (clutter_color_progress));
|
2008-10-17 16:23:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_value_set_color:
|
|
|
|
* @value: a #GValue initialized to #CLUTTER_TYPE_COLOR
|
|
|
|
* @color: the color to set
|
|
|
|
*
|
|
|
|
* Sets @value to @color.
|
|
|
|
*
|
2008-11-04 17:52:29 +00:00
|
|
|
* Since: 0.8.4
|
2008-10-17 16:23:46 +00:00
|
|
|
*/
|
|
|
|
void
|
2008-10-21 18:50:44 +00:00
|
|
|
clutter_value_set_color (GValue *value,
|
|
|
|
const ClutterColor *color)
|
2008-10-17 16:23:46 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_VALUE_HOLDS_COLOR (value));
|
|
|
|
|
2010-04-07 23:20:18 +00:00
|
|
|
g_value_set_boxed (value, color);
|
2008-10-17 16:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_value_get_color:
|
|
|
|
* @value: a #GValue initialized to #CLUTTER_TYPE_COLOR
|
|
|
|
*
|
|
|
|
* Gets the #ClutterColor contained in @value.
|
|
|
|
*
|
2010-09-08 15:41:47 +00:00
|
|
|
* Return value: (transfer none): the color inside the passed #GValue
|
2008-10-17 16:23:46 +00:00
|
|
|
*
|
2008-11-04 17:52:29 +00:00
|
|
|
* Since: 0.8.4
|
2008-10-17 16:23:46 +00:00
|
|
|
*/
|
Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.
We always used it to conform to the platform, at least for public-facing
API.
At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.
Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:
https://bugzilla.gnome.org/show_bug.cgi?id=644611
Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 14:49:20 +00:00
|
|
|
const ClutterColor *
|
2008-10-17 16:23:46 +00:00
|
|
|
clutter_value_get_color (const GValue *value)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_VALUE_HOLDS_COLOR (value), NULL);
|
|
|
|
|
2010-04-07 23:20:18 +00:00
|
|
|
return g_value_get_boxed (value);
|
2008-10-17 16:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
param_color_init (GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterParamSpecColor *cspec = CLUTTER_PARAM_SPEC_COLOR (pspec);
|
|
|
|
|
|
|
|
cspec->default_value = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
param_color_finalize (GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterParamSpecColor *cspec = CLUTTER_PARAM_SPEC_COLOR (pspec);
|
|
|
|
|
|
|
|
clutter_color_free (cspec->default_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
param_color_set_default (GParamSpec *pspec,
|
2010-04-07 23:20:18 +00:00
|
|
|
GValue *value)
|
2008-10-17 16:23:46 +00:00
|
|
|
{
|
2010-04-07 23:20:18 +00:00
|
|
|
const ClutterColor *default_value =
|
|
|
|
CLUTTER_PARAM_SPEC_COLOR (pspec)->default_value;
|
|
|
|
clutter_value_set_color (value, default_value);
|
2008-10-17 16:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
param_color_values_cmp (GParamSpec *pspec,
|
|
|
|
const GValue *value1,
|
|
|
|
const GValue *value2)
|
|
|
|
{
|
2010-04-07 23:20:18 +00:00
|
|
|
const ClutterColor *color1 = g_value_get_boxed (value1);
|
|
|
|
const ClutterColor *color2 = g_value_get_boxed (value2);
|
|
|
|
int pixel1, pixel2;
|
|
|
|
|
|
|
|
if (color1 == NULL)
|
|
|
|
return color2 == NULL ? 0 : -1;
|
2008-10-17 16:23:46 +00:00
|
|
|
|
2010-04-07 23:20:18 +00:00
|
|
|
pixel1 = clutter_color_to_pixel (color1);
|
|
|
|
pixel2 = clutter_color_to_pixel (color2);
|
2008-10-17 16:23:46 +00:00
|
|
|
|
2010-04-07 23:20:18 +00:00
|
|
|
if (pixel1 < pixel2)
|
2008-10-17 16:23:46 +00:00
|
|
|
return -1;
|
2010-04-07 23:20:18 +00:00
|
|
|
else if (pixel1 == pixel2)
|
2008-10-17 16:23:46 +00:00
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
|
|
|
clutter_param_color_get_type (void)
|
|
|
|
{
|
|
|
|
static GType pspec_type = 0;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (pspec_type == 0))
|
|
|
|
{
|
|
|
|
const GParamSpecTypeInfo pspec_info = {
|
|
|
|
sizeof (ClutterParamSpecColor),
|
|
|
|
16,
|
|
|
|
param_color_init,
|
|
|
|
CLUTTER_TYPE_COLOR,
|
|
|
|
param_color_finalize,
|
|
|
|
param_color_set_default,
|
|
|
|
NULL,
|
|
|
|
param_color_values_cmp,
|
|
|
|
};
|
|
|
|
|
|
|
|
pspec_type = g_param_type_register_static (I_("ClutterParamSpecColor"),
|
|
|
|
&pspec_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pspec_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-09-08 16:04:21 +00:00
|
|
|
* clutter_param_spec_color: (skip)
|
2008-10-17 16:23:46 +00:00
|
|
|
* @name: name of the property
|
|
|
|
* @nick: short name
|
|
|
|
* @blurb: description (can be translatable)
|
|
|
|
* @default_value: default value
|
|
|
|
* @flags: flags for the param spec
|
|
|
|
*
|
|
|
|
* Creates a #GParamSpec for properties using #ClutterColor.
|
|
|
|
*
|
|
|
|
* Return value: the newly created #GParamSpec
|
|
|
|
*
|
2008-11-04 17:52:29 +00:00
|
|
|
* Since: 0.8.4
|
2008-10-17 16:23:46 +00:00
|
|
|
*/
|
|
|
|
GParamSpec *
|
|
|
|
clutter_param_spec_color (const gchar *name,
|
|
|
|
const gchar *nick,
|
|
|
|
const gchar *blurb,
|
|
|
|
const ClutterColor *default_value,
|
|
|
|
GParamFlags flags)
|
|
|
|
{
|
|
|
|
ClutterParamSpecColor *cspec;
|
|
|
|
|
|
|
|
cspec = g_param_spec_internal (CLUTTER_TYPE_PARAM_COLOR,
|
|
|
|
name, nick, blurb, flags);
|
|
|
|
|
|
|
|
cspec->default_value = clutter_color_copy (default_value);
|
|
|
|
|
|
|
|
return G_PARAM_SPEC (cspec);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
}
|