Creating Games

Building games in Gluon is done by adding Components to the GameObjects in a Scene, and the use of external assets such as sounds, textures and the like is done by adding them as Assets to the project, and then referencing those Assets from the various Components which use them. The many components found in GluonEngine are described in the Components chapter under here. If you need anything that the existing Components don't already provide, you can add your own game logic as well by creating scripts, as described in Creating Game Logic.

Basics of Using Gluon Creator

The work flow of using Gluon Creator to create games is based on the idea that you should be able to use your mouse for as much of the work as possible. As such, adding an Asset to your project is a task done by dragging a file into the Project pane from your file browser (or alternatively by clicking the Add Asset... button in the toolbar). It will then be copied to the project folder, and be made available for use in your game.

Editing Assets which have been added to a game by this method can be done in two ways: Either by double-clicking on the Asset in the Project view or by right-clicking on it and selecting one of the Edit functions in the context menu. When possible, the Asset is opened in a tab in the central part of Creator. For example, double-clicking on a Texture Asset will open the image in an embedded viewer, which will allow you to open it in an external application for editing. Double-clicking on a Scripting Asset will open up the script in the embedded advanced text editor. For all Assets it is the case that Gluon Creator keeps track of changes to the file behind the Asset and ensures that the data in Gluon Creator is updated when the file changes.

To describe a scene in a game, you double-click on the appropriate Scene in the Project view, which causes it to be loaded and shown in the Scene pane, and in the View the camera view will show what the camera sees in the newly loaded scene. You can now edit this scene, by adding and removing GameObjects to the Scene, and by adding Components to those GameObjects.

To add a GameObject to the scene, click on the Add GameObject button on the toolbar, or by right-clicking on an existing GameObject and selecting New GameObject in the context menu. The function will add a new, empty GameObject to the Scene, and if you have an existing GameObject selected, the new one will be added as a child to the selected one. This allows you, as described in Gluon Basics, to build items for the game based on multiple GameObjects in a hierarchy, which all move along with each other.

Adding Components to a GameObject is done by dragging it out of the Components dock and dropping it on the GameObject you wish to add it to.

So that you can change the values for the various Components, selecting a GameObject in the Scene view will make the properties for that object and all the Components on it show up in the Properties view, which is a scrollable, categorized list of all the various properties.

One of the functions which will be performed with some regularity from the Properties view is that of setting references to various Assets, for example setting the texture of a SpriteRenderer, or the sound of a SoundEmitter. This is done by clicking on the ... button in the Properties view and selecting the appropriate item from the dialog which pops up. If there are no objects of this type, you will be informed of this issue.

Assets


An Asset is a piece of data which you can use in your game. Most of the time an Asset found in your Project tree will represent a file (such as a Sound, Texture or Scripting asset), though in some cases it can be for example a file with multiple bits (Brain AI files) or a special representation of some data in a parent asset (Material instances).

In this chapter you will find descriptions of each of the many types of assets, and how to manipulate them in Gluon Creator. Common for all Assets is that when you select an Asset, you will see the properties for it in the Properties view, just as with GameObjects in your Scene view.

Working with Assets

When working with Gluon Creator, you create new assets in one of two ways:

Some assets are created using external applications, such as textures, sounds and the like. These are added to your game project by dragging them in from your file browser and onto your game project. This will copy them into the game project bundle. You can now edit the asset by double-clicking on it, which will open it up in the application which your operating system thinks is most appropriate for the type of file.

Other assets, such as Scripting and Material assets are created directly from inside Gluon Creator. To do this, right-click on the root of the game project, or on a folder underneath it in your Project view, and select the name of the type of asset you wish to create. When you double-click on these assets, they will by default be opened up in a tab in the View and Editing area.

Materials

Materials are a type of asset which describe the surface properties of an object. For example, a material describes what colour and texture to use when rendering a sprite.

Material Structure

Each material contains one or more techniques. A technique represents one way of rendering an object. Different techniques within the same material can be used in different situations. One use case for this is if you want to support three levels of detail in your game. For each material you can create three techniques which you can select dependant on the current detail level. Or you can switch to a different technique for objects in the background. The criteria for selecting the technique are intentionally left up to you.

Each Technique contains a tree of Elements. Each element describes a single operation that produces a result. In essence, these Elements are like Components for GameObjects - they implement the actual logic of the material. Elements can range from a simple addition to the result of a complex offset mapping operation. It is completely up to you how you use and combine these elements. Some of the elements will have required or optional inputs. The aforementioned offset mapping element, for example, requires a diffuse map, a normal map and a height map. It further has an optional specular map and specular level. Contrary to their name, required inputs do not necessarily have to be defined during the creation of the material. This enables you to reuse materials with different inputs, reducing the burden of material creation.

Material Instances

Materials themselves cannot be assigned to objects directly. Instead, only material instances can be assigned to objects. A material instance is a material with all required parameters and possibly some optional parameters defined. In the case of the offset mapping element, this would mean the diffuse, normal and height map which the element needs to use. Gluon normally creates a default material instance for you to use and allows you to add additional instances.

Runtime

During runtime, the above structure would require far too much computing power to process. Therefore, materials and material instances are combined into GLSL Vertex and Fragment programs, which in turn are compiled by the GLSL compiler. The compiled result is then cached on disk for future use. This means the first run of your game will take a little longer because of the compiling process. However, once done, the process should not happen again unless something changes. (Note that, when run in debug mode, this process will //always// be performed, resulting in longer loading times for debug builds.)

Scripting

Scripts are what you as the maker of games write when you need to create your own logic. They are written in the ECMAScript language, and a guide for how to write them can be found in Creating Game Logic.

Sound

Sound files are any kind of sound you might wish to use in a game. This means that they are both sound effects and music. The following is a list of supported formats:

  • Windows Wave (wav)
  • Ogg/Vorbis (ogg)

Texture

A texture is a piece of graphic material in one of the many supported formats. You create and edit these in your preferred graphic editing application. The supported formats include:

  • GIF
  • JPEG
  • Portable Network Graphics (png)
  • SGI
  • SVG
  • Targa (tga)
  • Tiff
  • Windows Bitmap (bmp)
  • XBitmap (xbm)

Rules of thumb

  • Try and keep your height and width a power of 2 pixel size (such as 2, 4, 8, 16, 32, 64, 128, 256, 512 and so on)
  • Larger textures are much more expensive, in particular on mobile devices

Components

A list of the components, and a description of what each one does. The more specific use of each component can be seen by clicking on the name of the component.

CameraController
Allows control of the camera. Multiple CameraControllers can be added to the scene, but only one can be active at any one time.
KeyboardInput
A simple input handling component, which can handle exactly one keyboard key. When building game logic, the state of this key can then easily be checked.
TextRenderer
Shows the text on the screen in the position set by the GameObject the Component is attached to. The font, colour and type can be set for each TextRenderer.
SpriteRenderer
Simply renders a texture in the position set by the GameObject the component is attached to. The sprite can have a tint added. White is the default and will not change the texture.
SphereCollision
A simple sphere collider. Simply add one of these to a GameObject, and you can check whether it collides with any other SphereCollisions in the Scene.
SoundListener
Attach this to the GameObject which represents the character in the game to allow for 3D positional audio.
SoundEmitter
Attach this to the GameObject which is to make a sound, which should be heard from some position in the world by the SoundListener.
Scripting
This allows you to create custom logic for your games. When ever you encounter something which cannot be done with any of the existing Components, this allows you to build your own Components by writing scripts. The Creating Game Logic chapter explores in further depth how the game logic is created.

Camera Controller

Description of the camera controller component and how it works...

Link to API documentation here... (keep this separate, no need to scare people)

Keyboard Input

How to use the keyboard input component and such

Link to API docs (no need to scare people)

Scripting

Any piece of functionality which is not covered by another component is something which you as the maker of games will need to build yourself. This is what the Scripting component is for. Please read on in Creating Game Logic to see how to build your logic.

Sound Components

These two go together, and as such we describe them together.

Link to API docs (no need to scare people)

Sphere Collision

Describe the sphere collision component in some depth...

Link to API docs (no need to scare people)

Sprite Renderer

Describe the sprite renderer component.

Link to API docs (no need to scare people)

Creating Game Logic

When you hit the limit of the capabilities of the many Components provided by GluonEngine, it is time to create your own game logic. This is where the Scripting Component comes in. Using this component, you can use ECMAScript (also known as JavaScript) to react to changes in the game world, and make changes to the world in return. The scripts are written in version 1.5 of the language, using the QtScript engine. If you are familiar with JavaScript from web developing you are in good shape, but its important to note that web browser specific extensions like DOM and some functions are not available.

Resources

The following is an introduction to how these scripts are written, and how they access the various parts of the game. If you are looking for the full scripting API, please look at the following links which are helpfully collected by the Amarok team, who use the same scripting engine:

JavaScript 1.5 Guide
A thorough overview of the language.
API documentation for the standard functions and objects
This documents some functions only available in JavaScript 1.6, which QtScript does not support; they are marked as such.
Quick reference
A Trolltech provided list of objects and functions.

There are also many other JavaScript guides and tutorials on the Internet. Though often web-browser oriented, many are still relevant.

Introduction to Scripting in Gluon

When writing logic for Gluon Engine based games, it is important to understand the structure of the Gluon engine, and that is described in the next paragraphs. After that is a quick by-example description of how to interact with the various parts of the engine through the scripts.

Available Properties

Any script you write will have a number of predefined properties available to them. They provide a more straight forward access to the complete GameObject hierarchy and other core functionality of the game engine. Each of the properties contains a link to the documentation for the object they represent.

MessageHandler
A simple way of passing messages between multiple objects at the same time in a subscription based manner. The two core functions on these objects are subscribe() and publish(). The messages are simple strings, which allows you to make them as verbose or terse as you wish.
Game
The class which controls the game itself. This is how you change scenes, clone objects and other such things. It is also has certain bits of convenience functionality, such as providing you with random numbers.
this.GameProject
The GameProject instance representing the game you are developing. This is mostly a data container, and contains the game's name, description and the list of Scenes the game contains.
this.Scene
The Scene instance that the GameObject in question is connected to. As with GameProject, this is mostly a data container, and the most vital function in it is the access to the root object in the scene, through the function sceneContents().
this.GameObject
All Components are attached to a GameObject, and this is no different for scripts. This is the GameObject this script is attached to, and it provides all the functionality required for positional information and logic. This is the object you need to move around. The object is also used to find objects in the tree, both Components and other GameObjects (something which you can also do with this.Scene.sceneContents() ).
this.Component
The Scripting Component this script is attached to. This particular Component as those above contains little logic in itself - you create that by writing your code.

Object Lifecycle

The lifecycle of the objects in Gluon games means that a specific set of functions are called in a certain order. As this order is specified very deliberately, you can count on it when building your logic. The six functions below are predefined in your Scripting assets when you add them to your GameProject, and the following describes what their purpose is, and when they are called:

  • this.initialize() - Use this for initialization purposes, for things which must happen before the gameloop begins running. This can be used for example to cache references to other objects which you do not wish to expose as properties.
  • this.start() - This function is run immediately before the first call of the update function. This function can be used to set up data which does not require as much time as those in initialize().
  • These functions are called in a loop, until the Scene is changed or the game stopped:
    • this.update(time) - This function is called 25 times every second, and each time it is called, the time parameter is given the number of milliseconds passed since the last update. You should use this value, rather than hardcoding the time between updates, to ensure that your code is future proof. All logic in your game not directly linked to drawing should go in this function.
    • this.draw(timelapse) - This function is called as often as possible, and the timelapse parameter contains the number of milliseconds since the last update call. Use this to interpolate the positions for positions of objects in the game over time, allowing for smoother animations.
  • this.stop() - The opposite of the start() function, this is called after the last update() and draw() calls.
  • this.cleanup() - The opposite of the initialize() function, this is called immediately before the Scene() is unloaded.

Functions and Properties on Other Objects

Accessing other objects in your scene is done by dotting your way through the object tree, or by using the find functions on GameObjects. As this is ECMAScript, everything is essentially a property, even functions. As such, the only difference between retrieving a property and calling a function is the () operator. An example, then, of calling a function on the GameObject to which the script is attached, you can do the following:

this.update = function(time)
{
    // Rotate the GameObject by 90 degrees per second around the Z axis
    this.GameObject.rotate( QVector3D(0, 0, 1), 3.6*time );
}

Special attention must be paid to how you call functions you declare in other scripts. So, an example might be a game where you have a Scene made up of the following hierarchy of GameObjects:

Some Scene
Camera
Camera Controller Component named "CameraController"
Player
Scripting component named "Body"
Head
Scripting component named "Brain"

A Scripting Asset pointed to by Body might then contain the following code:

this.moveRight = function()
{
    // Move the player 1 unit to the right
    this.GameObject.translate( QVector3D(1, 0, 0) );
}

Another Scripting Asset, this one pointed to by Brain, might want to call the function which moves the player right, and for example it could contain the following code:

this.draw = function(timelapse)
{
    // Move the body this head is attached to right
    this.GameObject.parentGameObject().Body.scriptObject().moveRight();
}

Scripting Reference

This page what is for now a straight forward reference to the scripting objects available in Gluon's scripting API, and lists all the functions available on them from within game logic scripts:

Firstly, all the GluonObject classes as found in the Gluon API documentation are available, and all functions marked with the Q_INVOKABLE flag, or which are slots, are available and can be called from game logic.

QVector2D

Static functions

dotProduct(QVector2D,QVector2D)

Perform the dot product operation on the two vectors passed to this function, and return the result

Object functions

add(QVector2D)

Add this object and QVector2D together, andPu return the resulting vector

addOther(QVector2D)

Add the passed QVector2D to this object, and assign the result to the current instance

divide(Number)

Divide this object by the passed number, and return the result

divideBy(Number)

Divide this object by the passed number and assign the result to the current instance

equals(QVector2D)

Check whether this object is equal to the passed value (that is, each component is compared, and if all are equal, the result is true)

isNull()

Returns true if the x and y coordinates are set to 0.0, otherwise returns false.

length()

Returns the length of the vector from the origin.

lengthSquared()

Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.

multiply(Number)

Returns a QVector2D object that is the sum of the given vectors, v1 and v2; each component is added separately.

multiplyBy(Number)

Adds the given vector to this vector and returns a reference to this vector.

multiplyComponents(QVector2D)

Multiplies a copy of this vector's coordinates by the given factor, and returns a reference to this vector.

normalize()

Normalizes the currect vector in place. Nothing happens if this vector is a null vector or the length of the vector is very close to 1.

normalized()

Returns the normalized unit vector form of this vector.

If this vector is null, then a null vector is returned. If the length of the vector is very close to 1, then the vector will be returned as-is. Otherwise the normalized form of the vector of length 1 will be returned.

readFrom(QDataStream)

Read data into this object from the passed QDataStream.

setX(Number)

Set the x component to Number.

setY(Number)

Set the y component to Number

subtract(QVector2D)

Returns a QVector2D object that is formed by subtracting v2 from v1; each component is subtracted separately.

subtractOther(QVector2D)

Subtracts the given vector from this vector and returns a reference to this vector.

toPoint()

Returns the QPoint form of this 2D vector.

toPointF()

Returns the QPointF form of this 2D vector.

toString()

Returns the string representation of this vector.

toVector3D()

Returns the 3D form of this 2D vector, with the z coordinate set to zero.

toVector4D()

Returns the 4D form of this 2D vector, with the z and w coordinates set to zero.

writeTo(QDataStream)

Write the data from this vector into the QDataStream.

x()

Return the x component of this vector

y()

Return the y component of this vector

QVector3D

Static Functions

crossProduct(QVector3D,QVector3D)

Returns the cross-product of the two passed vectors, which corresponds to the normal vector of a plane defined by them.

dotProduct(QVector3D,QVector3D)

Returns the dot product of the two passed vectors

normal(QVector3D,QVector3D)

Returns the cross-product of the two passed vectors, which corresponds to the normal vector of a plane defined by them, normalized to be a unit vector.

Use crossProduct() to compute the cross-product if you do not need the result to be normalized to a unit vector.

Object Functions

distanceToLine(QVector3D point,QVector3D direction)

Returns the distance that this vertex is from a line defined by point and the unit vector direction.

If direction is a null vector, then it does not define a line. In that case, the distance from point to this vertex is returned.

distanceToPlane(QVector3D plane, QVector3D normal)

Returns the distance that this vertex is from a line defined by point and the unit vector direction.

If direction is a null vector, then it does not define a line. In that case, the distance from point to this vertex is returned.

distanceToPlane(QVector3D plane1, QVector3D plane2, QVector3D plane3)

Returns the distance from this vertex to a plane defined by the vertex plane and a normal unit vector. The normal parameter is assumed to have been normalized to a unit vector.

The return value will be negative if the vertex is below the plane, or zero if it is on the plane.

isNull()

Returns true if the x, y, and z coordinates are set to 0.0, otherwise returns false.

length()

Returns the length of the vector from the origin.

lengthSquared()

Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.

normalize()

Normalizes the currect vector in place. Nothing happens if this vector is a null vector or the length of the vector is very close to 1.

normalized()

Returns the normalized unit vector form of this vector.

If this vector is null, then a null vector is returned. If the length of the vector is very close to 1, then the vector will be returned as-is. Otherwise the normalized form of the vector of length 1 will be returned.

addOther(QVector3D)

Add the passed vector to the current instance, and return a reference to this vector.

divideBy(Number)

Divide this object by the Number and assign the result to the current instance

equals(QVector3D)

Check whether this object is equal to the passed value (if all components are equal the resoult is True)

multiplyBy(Number)

Adds the given vector to this vector and returns a reference to this vector.

subtractOther(QVector3D)

Subtracts the given vector from this vector and returns a reference to this vector.

readFrom(QDataStream)

Read data from QDataStream to that object.

setX (Number)

Sets the x coordinate of this point to Number.

setY(Number)

Sets the x coordinate of this point to Number.

setZ(Number)

Sets the y coordinate of this point to Number.

toPoint()

Returns the QPoint form of this 3D vector. The z coordinate is dropped.

toPointF()

Returns the QPointF form of this 3D vector. The z coordinate is dropped.

toVector2D()

Returns the 2D vector form of this 3D vector, dropping the z coordinate.

toVector4D()

Returns the 4D form of the 3D vector, with the w coordinate set to zero.

writeTo(QDataStream)

Write the data from this vector to passed QDataStream.

x()

Returns the x coordinate of this point.

y()

Returns the y coordinate of this point.

z()

Returns the z coordinate of this point.

toString()

Returns a string representing this vector.

add(QVector3D)

Add the object and QVector3D together, returns the resulting vector

subtrac(QVector3D)

Returns QVector3D object that is formed by subtracting vector2 from vector1; each component is subtracted separately.

multiply(Number)

Returns QVector3D object that is sum of the given vectors, vector1 and vector2; each component is added separately.

divide(Number)

Divide this object by Number, returns the result

multiplyComponents(QVector3D)

Multiplies a copy of the vector's coordinates by the given Number, returns a reference to this vector.

QVector4D

Static functions

dotProduct ( QVector4D & v1, QVector4D & v2 )

Returns the dot product of v1 and v2.

Object Functions

QVector4D ( Numberx Numbery, Numberz, Numberw )

Constructs a vector setting coordinations x, y, z, w to Numberx, Numbery, Numberz and Numberw.

isNull ()

Returns true if the x, y, z, and w coordinates are set to 0.

length ()

Returns the length of the vector.

lengthSquared ()

Returns the squared length of the vector.

normalize ()

Normalizes the currect vector in place.

setW (Number)

Sets the w coordinate of this point to the given Number.

setX (Number)

Sets the x coordinate of this point to the given Number.

setY (Number)

Sets the y coordinate of this point to the given Number.

setZ (Number)

Sets the z coordinate of this point to the given Number.

toPoint ()

Returns the QPoint form of this vector. The z and w coordinates are dropped.

toPointF()

Returns the QPointF form of this vector. The z and w coordinates are dropped.

toVector2D ()

Returns the 2D vector form of this 4D vector, dropping the z and w coordinates.

toVector2DAffine ()

Returns the 2D vector form of this 4D vector, dividing the x and y coordinates by the w coordinate and dropping the z coordinate. Returns a null vector if w is zero.

toVector3D ()

Returns the 3D vector form of this 4D vector, dropping the w coordinate.

toVector3DAffine ()

Returns the 3D vector form of this 4D vector, dividing the x, y, and z coordinates by the w coordinate. Returns a null vector if w is zero.

x ()

Returns the x coordinate.

y ()

Returns the y coordinate.

z ()

Returns the z coordinate.

w ()

Returns the w coordinate.

QQuaternion

Static Functions

fromAxisAndAngle (QVector3D & axis, Number)

Creates a normalized quaternion that corresponds to rotating through angle degrees about the specified 3D axis.

nlerp (QQuaternion & q1, QQuaternion & q2, t)

Interpolates along the shortest linear path between the rotational positions q1 and q2. The value t should be between 0 and 1, indicating the distance to travel between q1 and q2. The result will be normalized().

If t is less than or equal to 0, then q1 will be returned. If t is greater than or equal to 1, then q2 will be returned.

slerp (QQuaternion & q1, QQuaternion & q2, t)

Interpolates along the shortest spherical path between the rotational positions q1 and q2. The value t should be between 0 and 1, indicating the spherical distance to travel between q1 and q2.

Object Functions

QQuaternion (Numbe r, Number x, Number y, Number z)

Constructs a quaternion with the vector (x,y,z) and scalar.

conjugate ()

Returns the conjugate of this quaternion, which is (-x, -y, -z, scalar).

isIdentity ()

Returns true if the x, y, and z are set to 0.0, and the scalar is set to 1.0; else returns false.

isNull ()

Returns true if the x, y, z, and scalar are set to 0.0; else returns false.

length ()

Returns the length of the quaternion.

lengthSquared ()

Returns the squared length.

normalize ()

Normalizes the currect quaternion in place.

rotatedVector ( QVector3D & vector )

Rotates vector with this quaternion to produce a new vector in 3D space.

scalar ()

Returns the scalar.

setScalar (Number)

Sets the scalar component yo given Number.

setVector (QVector3D &vector)

Sets the vector component of this quaternion to vector

setX (Number)

Sets the x coordinate.

setX (Number)

Sets the z coordinate.

setX (Number)

Sets the z coordinate.

toVector4D ()

Returns this quaternion as a 4D vector.

vector ()

Returns the vector component of quaternion.

x ()

Returns the x coordinate.

y ()

Returns the y coordinate.

z ()

Returns the z coordinate.

QColor

Static Functions

allowX11ColorNames ()

Returns true if setNamedColor() is allowed to look up colors in the X11 color database.

colorNames ()

Returns a QStringList containing the color names Qt knows.

fromCmyk (Number c, Number m, Number y, Number k, Number a = 255)

Returns QColor constructed from given CMYK color values: c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e. transparency).

fromHsl (Number h, Number s, Number l, Number a = 255 )

Returns a QColor constructed from the HSV color values, h (hue), s (saturation), l (lightness), and a (alpha-channel, i.e. transparency).

fromHsv (Number h, Number s, Number v, Number a = 255 )

Returns a QColor constructed from the HSV color values, h (hue), s (saturation), v (value), and a (alpha-channel, i.e. transparency).

fromRgb (QRGB)

Returns a QColor constructed from the given QRgb value rgb.

fromRgbF (Number r, Number g, Number b, Number a = 1.0)

Returns a QColor constructed from the RGB color values, r (red), g (green), b (blue), and a (alpha-channel, i.e. transparency).

fromRgba ( QRgb rgba )

Returns a QColor constructed from the given QRgb value rgba.

isValidColor ( QString & name )

Returns true if the name is a valid color name and can be used to construct a valid QColor object, else returns false.

setAllowX11ColorNames ( boolean )

Allow setNamedColor() to look up colors in the X11 color database if given argument is Truth.

Object Functions

QColor ( Number r, Number g, Number b, Number a = 255 )

Constructs an invalid color with gives RGB values.

alpha()

Returns the alpha color component of this color.

black ()

Returns the black color component of this color.

blue ()

Returns the blue color component of this color.

convertTo ( Spec colorSpec )

Creates a copy of this color in the format specified by colorSpec.

cyan ()

Returns the cyan color component of this color.

darker (Number)

Returns a darker (or lighter) color, but does not change this object.

getCmyk ( Number c, Number m, Number y, Number k, Number a = 0 )

Sets the contents pointed to by c, m, y, k, and a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components of the color's CMYK value.

getHsl ( Number h, Number s, Number l, Number a = 0 )

Sets the contents pointed to by h, s, l, and a, to the hue, saturation, lightness, and alpha-channel (transparency) components of the color's HSL value.

getHsv (Number h, Number s, Number v, Number a = 0 )

Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (transparency) components of the color's HSV value.

getRgb ( Number r, Number g, Number b, Number a = 0 )

Sets the contents pointed to by r, g, b, and a, to the red, green, blue, and alpha-channel (transparency) components of the color's RGB value

green ()

Returns the green color component of this color.

hslHue ()

Returns the hue color component of this color.

hslSaturation ()

Returns the saturation color component of this color.

hsvHue ()

Returns the hue color component of this color.

hsvSaturation ()

Returns the saturation color component of this color.

hue ()

Returns the hue color component of this color.

isValid ()

Returns true if the color is valid; else returns false.

lighter ( Number factor )

Returns a lighter (or darker) color, but does not change this object.

lightness ()

Returns the lightness color component of this color.

magenta ()

Returns the magenta color component of this color.

name ()

Returns the name of the color in the format "#RRGGBB".

red ()

Returns the red color component of this color.

yellow ()

Returns the yellow color component of this color.

rgb ()

Returns the RGB value of the color. Alpha is dropped.

rgba ()

Returns the RGB value of the color Including alpha.

saturation ()

Returns the saturation color component of this color.

setAlpha (Number)

Sets the alpha of this color to Number.

setBlue (Number)

Sets the blue color component of this color to Number.

setCmyk (Number c, Number m,Number y, Number k, Number a = 255)

Sets the color to CMYK values, c (cyan), m (magenta), y (yellow), k (black), and a (alpha-channel, i.e. transparency).

setGreen ()

Sets the green color component of this color to Number.

setRed (Number)

Sets the red color component of this color to Number.

setHsl (Number h, Number s, Number l, Number a = 255)

Sets a HSL color value; h is the hue, s is the saturation, l is the lightness and a is the alpha component of the HSL color.

setHsv (Number h, Number s, Number v, Number a = 255)

Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha component of the HSV color.

setNamedColor (QString & name)

Sets the RGB value of this QColor to name.

setRgb ( Number r, Number g, Number b, Number a = 255)

Sets the RGB value to r, g, b and the alpha value to a.

setRgba (QRgb rgba)

Sets the RGB value to rgba, including its alpha.

spec ()

Returns the specification of color.

toCmyk ()

Creates and returns a CMYK QColor based on this color.

toHsl ()

Creates and returns an HSL QColor based on this color.

toHsv ()

Creates and returns an HSV QColor based on this color.

toRgb ()

Create and returns an RGB QColor based on this color.

value ()

Returns the value color component of this color.

QSizeF

QSizeF (QSize & size)

Constructs a size with floating point accuracy from the given size.

QSizeF (Number1, Number2)

Constructs a size with the given width = Number1 and height = Number.

boundedTo (QSizeF & otherSize)

Returns a size holding the minimum width and height of this size and the given otherSize.

QSizeF QSizeF::expandedTo (QSizeF & otherSize)

Returns a size holding the maximum width and height of this size and the given otherSize.

height ()

Returns the height.

isEmpty ()

Returns true if width or height is less than or equal to 0; else returns false.

isNull ()

Returns true if width and height are higher then +0.0; otherwise returns false.

isValid ()

Returns true if width and height is equal or greater than 0; else return false.

rheight ()

Returns a reference to height.

rwidth ()

Returns a reference to width.

width ()

Returns the width.

scale (width, height, Qt::AspectRatioMode mode)

Scales the size to a rectangle with the given width and height, according to the specified mode.

setHeight (Number)

Sets the height to given Number.

setWidth (Number)

Sets the width to given Number.

toSize ()

Returns an integer based copy of this size.

transpose ()

Swaps the height and widtht values.