-
Notifications
You must be signed in to change notification settings - Fork 3
EmuColorPicker
A class for creating a color picker. Color picker elements are designed to look similar to EmuInput elements, although the way they work is not the same.
Inheritance: EmuCore / EmuCallback
EmuColorPicker(x, y, w, h, text, value, callback)
Parameter | Type | Description |
---|---|---|
x | real | The x coordinate where the color picker will be created |
y | real | The y coordinate where the color picker will be created |
w | real | The width of the color picker |
h | real | The height of the color picker |
text | string | The title of the color picker |
value | string | The starting value of the color picker |
callback | function | The callback that will be invoked when the value of the color picker is changed |
Upon clicking the colored rectangle, a dialog containing an RGB axis and a hex code input will appear. The implementation of those are not of importance.
Returns: N/A
Parameter | Type | Description |
---|---|---|
vx1 | real | The x coordinate of the upper-left corner of the color picker |
vx2 | real | The y coordinate of the upper-left corner of the color picker |
vy1 | real | The x coordinate of the lower-right corner of the color picker |
vy2 | real | The y coordinate of the lower-right corner of the color picker |
By default the box which the user types text into occupies the rightmost half of the EmuInput element's bounding box, but in some cases - such as large multi-line input boxes, or small input boxes which only accept a few characters - you may wish to set the location of the box yourself.
Returns: N/A
Parameter | Type | Description |
---|---|---|
alpha_used | real | Whether or not the color picker will also let you select the alpha |
In addition to color, you may wish to select an alpha (transparency) value. Note that color values are store as a single 32-bit integer in ABGR format, so if you specify a 24-bit color value you will need to perform a logical OR
with 0xff000000
if you want the color to be opaque.
var picker = new EmuColorPicker(320, 32, 256, 32, "Color:", 0xff000000 | c_aqua, function() {
var r = value & 0x0000ff;
var g = (value & 0x00ff00) >> 8;
var b = (value & 0xff0000) >> 16;
show_debug_message("The color value was set to R = " + string(r) + ", G = " + string(g) + ", B = " + string(b));
});
picker.SetAlphaUsed(true);
container.AddContent(picker);
This will create an EmuColorPicker element which has an initial color of c_aqua
and allows the user to select an alpha value.