Agar
Agar 1.7 Manual

AG_HSVPal(3)

SYNOPSIS

#include <agar/core.h>
#include <agar/gui.h>

DESCRIPTION

ScreenshotThe AG_HSVPal widget is a HSV (Hue, Saturation, Value) color editor which allows the user to edit a color's hue, saturation, value and alpha components. The widget can bind directly to different color representations:

INHERITANCE HIERARCHY

AG_Object(3)-> AG_Widget(3)-> AG_HSVPal.

INITIALIZATION


AG_HSVPal * AG_HSVPalNew (AG_Widget *parent, Uint flags)


The AG_HSVPalNew() function allocates, initializes, and attaches a new AG_HSVPal widget. Acceptable flags include:
AG_HSVPAL_SHOW_RGBShow the RGB value in text form.
AG_HSVPAL_SHOW_HSVShow the HSV value in text form.
AG_HSVPAL_NOALPHA(Read-only) Transparency control is disabled. Set (or cleared) when pixel-format is bound to a pixel format with (or without) alpha.
AG_HSVPAL_FORCE_NOALPHADisable the transparency control.
AG_HSVPAL_NOPREVIEWDisable the color preview band.
AG_HSVPAL_HFILLExpand horizontally in parent container.
AG_HSVPAL_VFILLExpand vertically in parent container.
AG_HSVPAL_EXPANDShorthand for AG_HSVPAL_HFILL AG_HSVPAL_VFILL|.

UPDATING VALUES


void AG_HSVPalUpdateHue (AG_HSVPal *pal, int x, int y)

void AG_HSVPalUpdateSV (AG_HSVPal *pal, int x, int y)


AG_HSVPalUpdateHue() sets the hue to that closest to cursor coordinates x, y and triggers a refresh. AG_HSVPalUpdateSV() sets the saturation and value to that at cursor coordinates x, y and triggers a refresh.

BINDINGS

The AG_HSVPal widget provides the following bindings:
AG_Color *agcolor A native AG_Color(3) structure.
float *hue Hue (0..1).
float *saturation Saturation (0..1).
float *value Value (0..1).
float *alpha Single-precision component value (0..1).
AG_PixelFormat **pixel-format Pointer to AG_PixelFormat(3) describing the packed-pixel format of pixel and pixel64. Note that pixel-format should be set first. If the format has an alpha component, AG_HSVPAL_NOALPHA will be set accordingly (use AG_HSVPAL_FORCE_NOALPHA to disable).
Uint32 *pixel 32-bit packed pixel value.
Uint64 *pixel64 64-bit packed pixel value. Available in AG_LARGE build.
void *RGBv A three-element array containing the RGB components. Acceptable binding types include FLOAT and DOUBLE, INT and UINT8. For floating point types, the values are scaled to 0.0-1.0. For integral types, the values are scaled to 0-255.
void *RGBAv Same as above, except that the array has 4 elements where the last element is the alpha component.

EVENTS

The AG_HSVPal widget generates the following events:
h-changed (void)
The hue has changed.
sv-changed (void)
The saturation or the value has changed.

BUGS

Conversion between integer RGB and HSV triplets incurs loss of precision. In cases where it is desirable to maintain the same hue throughout changes in saturation, the color should be stored in HSV format.

SEE ALSO

AG_Intro(3), AG_Widget(3), AG_Window(3)

HISTORY

The AG_HSVPal widget first appeared in Agar 1.0. The pixel64 binding, AG_HSVPalUpdateHue() and AG_HSVPalUpdateSV() appeared in Agar 1.6.0.


ElectronTubeStore Csoft.net www.libAgar.org is © 2024 Julien Nadeau Carriere <vedge@csoft.net>.
Support LibAgar: www.patreon.com/libAgar.