Gradients, transparency and graphics in objects¶
Many objects in PLC-Lab can be assigned color gradients and their own graphics. This allows the user to design them highly individually.
In this section we will show how to e.g. use color gradients in objects to make their appearance more realistic, for example. We will also show you how to adjust the opacity of the colors (and with it, the transparency). Finally we will explain how you can display your own pictures or graphics in objects.
Setting color gradients in objects¶
Color gradients can be used to give objects realistic appearance. For example, a rectangle can be designed with color gradients so that it looks like a metal bar. You can change the color of a geometric object in the section "Main settings -> Appearance -> Colors". There are two properties for the fill color. The property "Fill color" is the color used in the object if no operand for switching the fill color is specified or if this operand has the status '0'. In the property "Fill color status 1" the color is defined which is used when the operand has the status '1' in the property "Operand switching fill color".
In the following example, the appearance of a metal bar is to be given to a rectangular object. You can do this by using a color gradient.
Follow the steps below to do this:
- Select the object.
- In the property "Fill color", call the dialog for the color and select the appropriate gradient.
- Select the left gradient stop and copy the color value to the clipboard.
- Select the right gradient stop and paste the color value from the clipboard.
- Insert a new gradient stop and place it in the center. Select a slightly darker color for it.
At the end, remove the border of the object by setting the line thickness to 0.
Transparency is used, for example, to create glass effects or to superimpose objects and make the different layers visible.
Here is an example where two conveying elements are placed on top of each other. The opacity of the fill color on the upper conveying element was set to 50%. As a result, the objects below it are visible.
In the following example, the two safety doors of a drilling rig are to be shown transparently so that the devices behind them can be seen. In reality the doors are made of glass; this should also be evident in the virtual system. To do this, select the two doors first, then select the color property and change the opacity from 100% to a lower value in the color setting dialog. You can see the effects immediately.
Using graphics (JPEG, PNG, BMP, ...) in objects¶
You can use your own graphics in switch objects and geometric objects. To do this, select a graphics file in the sections "Main settings ->Appearance -> Images" in the properties "Image status 0" and "Image status 1". You only have to select an image at status 1 if an operand for switching the images has been specified.
In the following example, the image of a drill is displayed in a rectangular object. One image is selected for status 0 and one mirror image for status 1.
When the motor of the drill is switched on, the two images should change. This switchover is done by means of a clock flag bit from the IM memory area of PLC-Lab (../see also "Special case clock flag byte: IMMB65534"). The bit IM.M65534.0 is used and AND-linked to the operand of the motor via a calculator object.
Now the simulation is executed as follows:
The change between the two images creates the impression that the drill is turning.
In the next example, we use two fixed circle objects. The upper circle object was configured with one graphic each for the status '0' and the status '1' of an operand. This means that if the operand has the status '0', an image with a white arrow is displayed. For status '1', an image with a yellow arrow is displayed.
For the second circle object, a PNG graphic with a transparent background is used for the status '0'. A second graphic for status '1' is not specified because status '1' should be indicated by a different color of the object. This color is visible because the graphic has transparent areas in which the colors of the circle object can be seen.
The layout shows the following behavior in the simulation:
The example shows that when using PNG graphics with transparent areas, you can also use color switching to indicate a status change. You don't need two graphics.
Now we will show an example in which a switch object is assigned a graphic. Again, we use a PNG graphic with transparent areas. An illuminated switch object is used, in which the graphic is specified. In addition, an operand for switching the colour is specified.
In the simulation, this appears like this:
As of version 126.96.36.199 of PLC-Lab, the operand-dependent color change or the change of graphics within geometric objects is supported even if these objects are not physical objects. This means that, for example, decoration objects can also be assigned color changes or changing graphics.
Using vector graphics (XAML) in objects¶
Vector graphics have the advantage that they can be displayed in any size without changing their display quality. These are never displayed "pixelated".
Below an XAML graphic is displayed in a circle object and its size is changed.
You can see that the graphic is always clear, regardless of its size.
XAML files are basically XML files in which the graphics are defined. These graphics can only be used in PLC-Lab if the files comply with certain criteria.
The elements within the XAML file must be encapsulated in a viewbox:
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Fill"> .... .... </Viewbox>
The following XAML snippet shows an arrow.
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Fill"> <ContentControl Content="➛"/> </Viewbox>
Where are the custom graphic files of a system project stored?¶
If a user-defined graphic is used in an object, this graphic file (e.g. the file with the extension .JPG or .PNG) is copied to the directory of the system project. This file must then also be specified when the system project is shared. If a system project is saved to a different location under a different name using "Save as", the user-defined graphic files used in the project are copied automatically.
If an object which displays a user-defined graphic is copied to the clipboard and pasted into another project, the user-defined graphic files are again copied automatically. It is important that the original file still exists or is accessible when you insert the object into the new project.
Included graphical symbols (bottle, crate, motor, ...)¶
After the installation of PLC-Lab you will find the folder PLC-Lab Editor in your documents. Here you will find sample projects and useful graphic symbols in the Items folder: Bottles, crates (high, flat), balls, etc.