The PolygonItem allows to display polygonal primitives with color. More...
Import Statement: | import Felgo 4.0 |
Since: | Felgo 2.0.4 |
Inherits: |
With PolygonItem you can display colored convex polygons. The shape can be closed, opened, filled or unfilled.
Following examples demonstrates the usage of the PolygonItem.
This example demonstrates how to use the PolygonItem to display a black Rectangle that is not filled.
import Felgo import QtQuick GameWindow { Scene { PolygonItem { anchors.centerIn: parent vertices: [ Qt.point(0, 0), Qt.point(10, 0), Qt.point(10, 10), Qt.point(0, 10) ] } } }
This example demonstrates how to use the PolygonItem to display a blue complex shape.
import Felgo import QtQuick GameWindow { Scene { PolygonItem { id: polygon color: "blue" fill: true vertices: [ Qt.point(0, 0), Qt.point(40, 15), Qt.point(100, 110), Qt.point(20, 210), Qt.point(10, 150), Qt.point(80, 110), Qt.point(10, 30) ] } } }
This example demonstrates how to animate color changes of the polygon.
import Felgo import QtQuick GameWindow { Scene { PolygonItem { id: polygon color: "blue" fill: true vertices: [ Qt.point(0, 0), Qt.point(40, 15), Qt.point(100, 110), Qt.point(20, 210), Qt.point(10, 150), Qt.point(80, 110), Qt.point(10, 30) ] } SequentialAnimation { running: true loops: Animation.Infinite ColorAnimation { target: polygon property: "color" to: "red" duration: 1000 } ColorAnimation { target: polygon property: "color" to: "green" duration: 1000 } ColorAnimation { target: polygon property: "color" to: "blue" duration: 1000 } } } }
close : bool |
This property is used to close the polygon silhouette. It is only used when the polygon is not filled. It connects the first vertex with the last vertex in the vertices list. The default value is true.
color : color |
This property stores the color of the primitive. The default value is black.
fill : bool |
This property is used to draw a filled polygon if true, otherwise it draws only its silhouettes. The default value is false to draw only silhouettes.
[since Felgo 2.2.0] texture : url |
The texture which is used to cover the polygon. By default no texture will be used.
The texture is repeated horizontally and vertically to fill the whole Polygon.
Note: Make sure to provide 3 different sized texture versions to support multiple screens and put them into the +hd and +hd2 subfolder, similar to MultiResolutionImage.
This property was introduced in Felgo 2.2.0.
vertices : variant |
This property holds the border vertices of the polygon. By default no vertex is set.