Lasernet has a number of different methods of changing the colour of objects in the Forms Editor.
Amending the font colour
The text colour in rearranges and text boxes can be easily changed in the text box properties.
To change the text colour, follow these steps:
1. Double-click the text to open the object properties window and click the Font tab.
2. Click the Color button.
Another window will appear which allows you to customise the text colour.
Default colours in Lasernet
Lasernet uses five default colours, red, green, blue, white and black. However, HEX colour codes can be used to allow for a greater range of colours. For example, a light orange using the hex code #fadda2.
Adding a border and/or background to text
Within the Border tab, there is a Background and Border section. To add a border and/or background, follow these steps:
1. Click the Border tab.
There are two checkboxes:
Border: for setting the border colour, the thickness of the line, the margin and on what sides of the rearrange the line will appear
Background: to select and enable the background colour for the text.
2. Edit the border thickness, the location, its margin and background colour.
3. Once you are happy with the settings, click the Ok button.
Amending the colour of a Rearrange via scripting
To alter the colour of a rearrange, follow these steps:
1. Double-click on the rearrange, click the Objects tab and enter an Input object name in the text box.
2. Select the Script checkbox which activates the text box in the bottom right-hand corner where the script text can be written.
//To set the text colour (To use hex replace red with the hex code i.e. 0xFF0000 is red). CurrentRearrange.color = red; //To set the background colour. CurrentOutputRearrange.backgroundColor = blue; //To set the text box border colour. CurrentOutputRearrange.borderColor = red;
//Returns the data back into the rearrange with the above changes CurrentRearrange.text;
Using the Shape tool (Lasernet v7+)
From Lasernet version 7 you can create Lines, Rectangles and Rounded Rectangles using the Shape tool. There are two different ways of amending the colour for this:
- Using the properties via the Shape tool.
- Using scripts.
Each approach has a different method for changing the colour.
Using the properties via the Shape tool
The method is identical to changing the colour in a rearrange. Double-click on the shape to bring up its properties. Using the two sections: Fill and Line, you can change the relevant information for the shape.
Using the scripts via the Shape tool - Individual Shapes
If you are using the shape tool to create an individual shape, scripting must be enabled and an input object name must be added:
//Sets the border colour of a rectangle or colour of the line. CurrentOutputRearrange.color = red; //Sets the background colour. CurrentOutputRearrange.backgroundColor = blue;
You can also reference a rearrange shape from another or if you do not want to use CurrentOutputRearrange, there is another method to change the colours. This time you must provide an Output Object name only, in the example scripts below, ‘EFS’, is used as the object name.
//Sets the border colour of a rectangle or colour of the line. EFS[0].color = red; //Sets the background colour. EFS[0].backgroundColor = blue;
Shapes in a pattern
Using the shape tool on a pattern means that the number of shapes will change dynamically depending on the input. These can be coloured with more complex scripts. Scripting needs to be enabled, using the checkbox, and also requires an output object name. This can be entered on the Output tab of the shape properties. In the example scripts below, ‘EFS’, is used as the object name.
//Sets the line colour to red. EFS[Line].color = red;
//Sets the background colour. EFS[Line].backgroundColor = red;
//Sets the border colour. EFS[Line].borderColor = red; //Sets the background colour. EFS[Line].backgroundColor = blue;
Complex Scripts An example of a more complex script to colour shapes or text can be seen below:
//Colours all even lines of a shape rearrange on a pattern, blue. if(Line % 2){ EFS[Line].backgroundColor = blue; }
//Colours all odd lines in a shape rearrange, red. if(Line % 2 == 0){ EFS[Line].backgroundColor = red; }
the above being used together:
if(Line % 2){ //Colours all even lines of a shape rearrange, blue. EFS[Line].backgroundColor = blue; } else{ //Colours all odd lines in a shape rearrange, red. EFS[Line].backgroundColor = red; }
Add a comment
Please log in or register to submit a comment.