GwyPaletteDef

GwyPaletteDef — Palette definitions

Synopsis




#define     GWY_PALETTE_BLUE
#define     GWY_PALETTE_BLUE_CYAN
#define     GWY_PALETTE_BLUE_VIOLET
#define     GWY_PALETTE_BLUE_YELLOW
#define     GWY_PALETTE_BW1
#define     GWY_PALETTE_BW2
#define     GWY_PALETTE_COLD
#define     GWY_PALETTE_DFIT
#define     GWY_PALETTE_GOLD
#define     GWY_PALETTE_GRAY
#define     GWY_PALETTE_GREEN
#define     GWY_PALETTE_GREEN_CYAN
#define     GWY_PALETTE_GREEN_VIOLET
#define     GWY_PALETTE_GREEN_YELLOW
#define     GWY_PALETTE_OLIVE
#define     GWY_PALETTE_PINK
#define     GWY_PALETTE_PM3D
#define     GWY_PALETTE_RAINBOW1
#define     GWY_PALETTE_RAINBOW2
#define     GWY_PALETTE_RED
#define     GWY_PALETTE_RED_CYAN
#define     GWY_PALETTE_RED_VIOLET
#define     GWY_PALETTE_RED_YELLOW
#define     GWY_PALETTE_SPECTRAL
#define     GWY_PALETTE_WARM
#define     GWY_PALETTE_YELLOW
struct      GwyPaletteDefEntry;
struct      GwyPaletteDef;
struct      GwyPaletteDefClass;
void        (*GwyPaletteDefFunc)            (const gchar *name,
                                             GwyPaletteDef *palette_def,
                                             gpointer user_data);
GObject*    gwy_palette_def_new             (const gchar *name);
GObject*    gwy_palette_def_new_as_copy     (GwyPaletteDef *src_palette_def);
gchar*      gwy_palette_def_get_name        (GwyPaletteDef *palette_def);
gboolean    gwy_palette_def_set_name        (GwyPaletteDef *palette_def,
                                             const gchar *name);
gboolean    gwy_palette_def_exists          (const gchar *name);
void        gwy_palette_def_foreach         (GwyPaletteDefFunc callback,
                                             gpointer user_data);
GwyRGBA     gwy_palette_def_get_color       (GwyPaletteDef *palette_def,
                                             gdouble x,
                                             GwyInterpolationType interpolation);
void        gwy_palette_def_set_color       (GwyPaletteDef *palette_def,
                                             GwyPaletteDefEntry *val);
void        gwy_palette_def_set_from_samples
                                            (GwyPaletteDef *palette_def,
                                             GwyRGBA *samples,
                                             gint nsamples,
                                             gint istep);
void        gwy_palette_def_setup_presets   (void);
GString*    gwy_palette_def_dump            (GwyPaletteDef *palette_def);
GwyPaletteDef* gwy_palette_def_parse        (const gchar *text,
                                             gboolean rename_on_clash);
#define     gwy_palette_def_is_set          (pd)

Object Hierarchy


  GObject
   +----GwyPaletteDef

Implemented Interfaces

GwyPaletteDef implements GwySerializable and GwyWatchable.

Description

A palette definition consists of defining points, between them the colors are interpolated to get a palette.

Details

GWY_PALETTE_BLUE

#define GWY_PALETTE_BLUE         "Blue"

A blue palette.


GWY_PALETTE_BLUE_CYAN

#define GWY_PALETTE_BLUE_CYAN    "Blue-Cyan"

A black-blue-cyan-white palette.


GWY_PALETTE_BLUE_VIOLET

#define GWY_PALETTE_BLUE_VIOLET  "Blue-Violet"

A black-blue-violet-white palette.


GWY_PALETTE_BLUE_YELLOW

#define GWY_PALETTE_BLUE_YELLOW  "Blue-Yellow"

A black-blue-yellow-white palette.


GWY_PALETTE_BW1

#define GWY_PALETTE_BW1          "BW1"

A striped black-and-white palette with blended stripes.


GWY_PALETTE_BW2

#define GWY_PALETTE_BW2          "BW2"

A striped black-and-white palette with sharp stripes.


GWY_PALETTE_COLD

#define GWY_PALETTE_COLD         "Cold"

A blue, cold palette.


GWY_PALETTE_DFIT

#define GWY_PALETTE_DFIT         "DFit"

A light black-violet-red-yellow-green-blue-white palette resembling a dendrofit palette.


GWY_PALETTE_GOLD

#define GWY_PALETTE_GOLD         "Gold"

A gold palette.


GWY_PALETTE_GRAY

#define GWY_PALETTE_GRAY         "Gray"

A gray palette.

This is the default palette.


GWY_PALETTE_GREEN

#define GWY_PALETTE_GREEN        "Green"

A green palette.


GWY_PALETTE_GREEN_CYAN

#define GWY_PALETTE_GREEN_CYAN   "Green-Cyan"

A black-green-cyan-white palette.


GWY_PALETTE_GREEN_VIOLET

#define GWY_PALETTE_GREEN_VIOLET "Green-Violet"

A black-green-violet-white palette.


GWY_PALETTE_GREEN_YELLOW

#define GWY_PALETTE_GREEN_YELLOW "Green-Yellow"

A black-green-yellow-white palette.


GWY_PALETTE_OLIVE

#define GWY_PALETTE_OLIVE        "Olive"

A plive palette.


GWY_PALETTE_PINK

#define GWY_PALETTE_PINK         "Pink"

A pink palette.


GWY_PALETTE_PM3D

#define GWY_PALETTE_PM3D         "Pm3d"

A black-blue-red-gold palette strongly resembling default pm3d palette.


GWY_PALETTE_RAINBOW1

#define GWY_PALETTE_RAINBOW1     "Rainbow1"

A colorful rainbow palette.


GWY_PALETTE_RAINBOW2

#define GWY_PALETTE_RAINBOW2     "Rainbow2"

A black-red-green-blue-white palette.


GWY_PALETTE_RED

#define GWY_PALETTE_RED          "Red"

A red palette.


GWY_PALETTE_RED_CYAN

#define GWY_PALETTE_RED_CYAN     "Red-Cyan"

A black-red-cyan-white palette.


GWY_PALETTE_RED_VIOLET

#define GWY_PALETTE_RED_VIOLET   "Red-Violet"

A black-red-violet-white palette.


GWY_PALETTE_RED_YELLOW

#define GWY_PALETTE_RED_YELLOW   "Red-Yellow"

A black-red-yellow-white palette.


GWY_PALETTE_SPECTRAL

#define GWY_PALETTE_SPECTRAL     "Spectral"

A palette resembling spectral colors (starting and ending with black).


GWY_PALETTE_WARM

#define GWY_PALETTE_WARM         "Warm"

A red-yellow, warm palette.


GWY_PALETTE_YELLOW

#define GWY_PALETTE_YELLOW       "Yellow"

A yellowish palette.


struct GwyPaletteDefEntry

struct GwyPaletteDefEntry {

    gdouble x;
    GwyRGBA color;
};

Palette definition entry type.

The x coordinate is from the range [0,1].

gdouble x Position of color in the palette definition.
GwyRGBA color The color at position x.

struct GwyPaletteDef

struct GwyPaletteDef;

The GwyPaletteDef struct contains private data only and should be accessed using the functions below.


struct GwyPaletteDefClass

struct GwyPaletteDefClass {

    GObjectClass parent_class;

    GHashTable *palettes;
};


GwyPaletteDefFunc ()

void        (*GwyPaletteDefFunc)            (const gchar *name,
                                             GwyPaletteDef *palette_def,
                                             gpointer user_data);

Callback function type for gwy_palette_def_foreach().

name : Palette definition name.
palette_def : Palette definition.
user_data : A user-specified pointer.

gwy_palette_def_new ()

GObject*    gwy_palette_def_new             (const gchar *name);

Returns a palette definition called name.

Palette definitions of the same name are singletons, thus if a palette definitions called name already exists, it is returned instead (with reference count incremented).

name can be NULL, a new unique name is invented then.

A newly created palette definition is completely empty.

name : Palette name.
Returns : The new palette definition as a GObject.

gwy_palette_def_new_as_copy ()

GObject*    gwy_palette_def_new_as_copy     (GwyPaletteDef *src_palette_def);

Creates a new palette definition as a copy of an existing one.

A new name is invented based on the existing one.

src_palette_def : An existing GwyPaletteDef.
Returns : The new palette definition as a GObject.

gwy_palette_def_get_name ()

gchar*      gwy_palette_def_get_name        (GwyPaletteDef *palette_def);

Returns the name of palette definition palette_def.

palette_def : A GwyPaletteDef.
Returns : The name. It should be considered constant and not modifier or freed.

gwy_palette_def_set_name ()

gboolean    gwy_palette_def_set_name        (GwyPaletteDef *palette_def,
                                             const gchar *name);

Sets the name of a palette definition.

This function fails when a palette definition of given name already exists.

palette_def : A GwyPaletteDef.
name : A new name of the palette definition.
Returns : Whether the rename was successfull.

gwy_palette_def_exists ()

gboolean    gwy_palette_def_exists          (const gchar *name);

Tests whether a palette definition of given name exists.

name : A palette definition name.
Returns : TRUE if such a palette definition exists, FALSE otherwise.

gwy_palette_def_foreach ()

void        gwy_palette_def_foreach         (GwyPaletteDefFunc callback,
                                             gpointer user_data);

Runs callback for each existing palette definition.

callback : A callback.
user_data : User data passed to the callback.

gwy_palette_def_get_color ()

GwyRGBA     gwy_palette_def_get_color       (GwyPaletteDef *palette_def,
                                             gdouble x,
                                             GwyInterpolationType interpolation);

Finds the color at position x between 0 and gwy_palette_def_get_n().

Interpolates between palette definition entries closest to x and returns the resulting color.

palette_def : palette definition of interest
x : position (0-N)
interpolation : interpolation method
Returns : the color sample.

Since 1.7


gwy_palette_def_set_color ()

void        gwy_palette_def_set_color       (GwyPaletteDef *palette_def,
                                             GwyPaletteDefEntry *val);

Adds an entry to palette definition.

palette_def : A palette definition to be changed.
val : An entry to be added.

gwy_palette_def_set_from_samples ()

void        gwy_palette_def_set_from_samples
                                            (GwyPaletteDef *palette_def,
                                             GwyRGBA *samples,
                                             gint nsamples,
                                             gint istep);

Fits the palette definition to given color samples.

It finds the extrema points inside palette color tables and tries to setup the palette definition to fit the color tables. This fucntion should be used only when there is a reason for doing this, for example after some graphical entry of palette color table values. Parameter istep controls the precision of the linear fit.

However, the precise algorithm may change in the future.

palette_def : A GwyPaletteDef to be computed.
samples : Color data to ctreate the definition from.
nsamples : The number of samples in samples.
istep : Maximum distance of definition entries, 0 means unlimited.

gwy_palette_def_setup_presets ()

void        gwy_palette_def_setup_presets   (void);

Set up built-in palette definitions. To be used in Gwyddion initialization and eventually replaced by loading palette definitions from external files.


gwy_palette_def_dump ()

GString*    gwy_palette_def_dump            (GwyPaletteDef *palette_def);

Dumps a paletted definition to text.

palette_def : A palette definition.
Returns : A GString with palette text representation.

Since 1.4.


gwy_palette_def_parse ()

GwyPaletteDef* gwy_palette_def_parse        (const gchar *text,
                                             gboolean rename_on_clash);

Creates a palette defnition from a text dump.

text : A text palette definition dump, as created with gwy_palette_def_dump().
rename_on_clash : Whether the created palette should be renamed to an unique name instad of overwriting the existing one on a name clash.
Returns : The palette (NULL on failure).

Since 1.4.


gwy_palette_def_is_set()

#define gwy_palette_def_is_set(pd) (GWY_PALETTE_DEF(pd)->data->len)

Expands to TRUE if the palette definition contains any colors.

XXX: This is flawed. Unset palette definitions should not exist, though currently gwy_palette_def_new() creates them.

pd : A palette definition.

See Also

GwyPalette