Scripting Interface |
The JavaScript class providing information about a specific palette. More...
Public Slots | |
String | getPath () |
Returns the folder in which this palette is located. More... | |
String | getName () |
Returns the name of this palette. The extension (".plt") is not included. More... | |
bool | isValid () |
Returns true if the palette object is valid. More... | |
bool | isLoaded () |
Returns true if the palette was successfully loaded from the disk. More... | |
bool | isNotFound () |
Returns true if the palette was found at the location specified by the path and name. More... | |
BaseColor * | getColorByIndex (int index) |
Returns the colour found at the given index. Returns an invalid colour if the index is out of bound or otherwise invalid. More... | |
BaseColor * | getColorById (String &uniqueId) |
Returns the colour found by the given Id. If the colour is not found, the isValid property will be false. More... | |
bool | getLock () |
Try to obtain the database lock. Return true on success, and false on failure. The lock will be held until it is released in script or the ui. Safe to call multiple time to get the lock state. More... | |
bool | releaseLock () |
Release access to the palette. Other users will be able to obtain the access rights to the palette. More... | |
bool | isColorPalette () |
Returns whether the palette is a colour palette. More... | |
bool | isTexturePalette () |
Returns whether the palette is a texture palette. More... | |
void | setToColorPalette () |
Sets the type of the palette to be a colour palette. More... | |
void | setToTexturePalette () |
Sets the type of the palette to be a texture palette. More... | |
Color * | createNewColor (int colorType, String &name, QVariant colorData) |
Create a new colour of a given type. More... | |
Color * | createNewSolidColor (String &name, QVariant colorData) |
Create a new solid colour. More... | |
Color * | createNewLinearGradientColor (String &name, QVariant colorData) |
Create a new linear gradient colour. More... | |
Color * | createNewRadialGradientColor (String &name, QVariant colorData) |
Create a new radial gradient colour. More... | |
Texture * | createNewTexture (String &name, String &filename, bool tiled) |
Create a new texture colour object. More... | |
Texture * | createNewTexture (String &name, QImage &bitmap, bool tiled) |
Create a new texture from a QImage object (may not be done from the script). More... | |
BaseColor * | duplicateColor (BaseColor *source) |
Create a duplicate of a colour object - this colorID is unique. More... | |
BaseColor * | cloneColor (BaseColor *source) |
Create a clone of a colour object - this colorID is identical to original colour. More... | |
BaseColor * | cloneColor (BaseColor *source, bool replaceOnIDConflict) |
Create a clone of a colour object - resolve the potential ID conflict by either cloning or duplicating the colour. More... | |
bool | removeColor (String &uniqueId) |
Delete a colour from the palette. More... | |
bool | moveColor (int index, int beforeIndex) |
Moves a colour at the specified index. More... | |
bool | acquire (BaseColor *color) |
Move a color to this palette. More... | |
Properties | |
int | nColors |
Number of colours in this palette. More... | |
String | id |
The palette ID of this palette. More... | |
int | location |
Returns one of the PaletteLocation constants or -1 if the palette is invalid. More... | |
int | elementId |
Returns the element id in which the palette is stored if location is PaletteLocation ELEMENT. Returns -1 if the palette is not stored in an element. More... | |
The JavaScript class providing information about a specific palette.
A Palette object can be obtained from PaletteList methods like getPaletteByIndex
, getPaletteById
or createPalette
or from the PaletteObjectManager method getPalette
. The Palette class defines a palette of colours. It provides access to functionalities of palettes like:
|
slot |
Move a color to this palette.
Will remove the colour from its original palette and move it to this one. Returns false if the colour is invalid or if this is the same palette as the current colour palette. If this palette has a colour with the same colour ID as the source colour, it will return false also.
color | : The colour to be acquired. |
Create a clone of a colour object - this colorID is identical to original colour.
Will create a copy of the colour with all the same values including the colorID. The source must be from another palette otherwise it will return an invalid color.
source | : The source colour to be cloned. |
Create a clone of a colour object - resolve the potential ID conflict by either cloning or duplicating the colour.
This version allow you to specify whether to replace an already existing color when cloning the palette.
source | : The source colour to be cloned. |
replaceOnIDConflict | : True to replace an already existing colour when cloning the palette. |
|
slot |
Create a new colour of a given type.
colorType | : colorType can be: |
name | : The name of the colour to be created. |
colorData | : Depending on the value of colorType argument, colorData has to be either an array of objects or an object. If the colorType argument is SOLID_COLOR, the colorData must be an object defined like this: { r : 255, g: 0, b: 0, a : 255 } to represent a solid red colour. If the colorType argument is one of the gradients, there must be an array of objects, one for each gradient tack. For example: [ { r : 255, g: 0, b: 0, a : 255, t: 0 }, { r : 0, g: 0, b: 255, a : 255, t: 1 } ] would define a gradient going from red to blue. The t parameter in each object represents the tack position and is a double value going from 0 to 1. |
|
slot |
Create a new linear gradient colour.
Same as createNewColor(ColorType.LINEAR_GRADIENT, name, colorData);
name | : The name of the colour to be created. |
colorData | : colorData must be an array of objects, one for each gradient tack. For example: [ { r : 255, g: 0, b: 0, a : 255, t: 0 }, { r : 0, g: 0, b: 255, a : 255, t: 1 } ] would define a gradient going from red to blue. The t parameter in each object represents the tack position and is a double value going from 0 to 1. |
|
slot |
Create a new radial gradient colour.
Same as createNewColor(ColorType.RADIAL_GRADIENT, name, colorData);
name | : The name of the colour to be created. |
colorData | : colorData must be an array of objects, one for each gradient tack. For example: [ { r : 255, g: 0, b: 0, a : 255, t: 0 }, { r : 0, g: 0, b: 255, a : 255, t: 1 } ] would define a gradient going from red to blue. The t parameter in each object represents the tack position and is a double value going from 0 to 1. |
|
slot |
Create a new solid colour.
Same as createNewColor(ColorType.SOLID_COLOR, name, colorData);
name | : The name of the colour to be created. |
colorData | : colorData must be an object defined like this example: { r : 255, g: 0, b: 0, a : 255 } which represents a solid red colour. |
|
slot |
Create a new texture colour object.
Creates a texture pot. Copies the bitmap file internally to the palette.
name | : The name of the texture to be created. |
filename | : The name of the file to be turned into a texture. |
tiled | : Whether or not the texture will be tiled or not. |
|
slot |
Create a new texture from a QImage object (may not be done from the script).
Creates a texture pot. Will copy the bitmap data internally to the palette.
name | : The name of the texture to be created. |
bitmap | : The bitmap to be turned into a texture. |
tiled | : Whether or not the texture will be tiled or not. |
Create a duplicate of a colour object - this colorID is unique.
Creates a copy of the colour with all the same values as source except for the colorID which will be a new uniqueID.
source | : The source colour to be duplicated. |
|
slot |
Returns the colour found by the given Id. If the colour is not found, the isValid property will be false.
uniqueId | : The id of the colour. |
|
slot |
Returns the colour found at the given index. Returns an invalid colour if the index is out of bound or otherwise invalid.
index | : The zero based index of the colour. |
|
slot |
Try to obtain the database lock. Return true on success, and false on failure. The lock will be held until it is released in script or the ui. Safe to call multiple time to get the lock state.
|
slot |
Returns the name of this palette. The extension (".plt") is not included.
|
slot |
Returns the folder in which this palette is located.
|
slot |
Returns whether the palette is a colour palette.
|
slot |
Returns true if the palette was successfully loaded from the disk.
|
slot |
Returns true if the palette was found at the location specified by the path and name.
|
slot |
Returns whether the palette is a texture palette.
|
slot |
Returns true if the palette object is valid.
|
slot |
Moves a colour at the specified index.
Moves the colour at given index just before the colour at beforeIndex in the list. Moves the colour at the end if beforeIndex is -1.
index | : The index of the colour to be moved. |
beforeIndex | : The index of the colour that the color will be moved before. |
|
slot |
Release access to the palette. Other users will be able to obtain the access rights to the palette.
|
slot |
Delete a colour from the palette.
Permanently delete a colour.
uniqueId | : The uniqueID of the colour to be removed. |
|
slot |
Sets the type of the palette to be a colour palette.
|
slot |
Sets the type of the palette to be a texture palette.
|
read |
Returns the element id in which the palette is stored if location is PaletteLocation ELEMENT. Returns -1 if the palette is not stored in an element.
|
read |
The palette ID of this palette.
|
read |
Returns one of the PaletteLocation constants or -1 if the palette is invalid.
|
read |
Number of colours in this palette.