-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExtrudedTextWrapper.qml
63 lines (51 loc) · 1.58 KB
/
ExtrudedTextWrapper.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import QtQuick 2.13
import Qt3D.Core 2.13
import Qt3D.Extras 2.13
Entity {
id: root
property int horizontalAlignment: Text.AlignLeft
property int verticalAlignment: Text.AlignBottom
property alias minExt: mesh.minExt
property alias maxExt: mesh.maxExt
property alias ambientColor: material.ambient
property alias specularColor: material.specular
property alias text: mesh.text
property alias depth: mesh.depth
property alias font: mesh.font
property real width: mesh.maxExt.x - mesh.minExt.x
property real height: mesh.maxExt.y - mesh.minExt.y
ExtrudedTextMesh {
id: mesh
property var minExt: geometry.minExtent
property var maxExt: geometry.maxExtent
}
PhongMaterial {
id: material
ambient: "#FFFFFF"
}
Transform {
id: transform
translation: Qt.vector3d(calculateHorizontalPosition(),
calculateVerticalPosition(),
0)
}
components: [mesh, material, transform]
function calculateHorizontalPosition() {
if (horizontalAlignment === Text.AlignRight) {
return -width
} else if (horizontalAlignment === Text.AlignHCenter){
return width * -0.5
} else {
return 0
}
}
function calculateVerticalPosition() {
if (verticalAlignment === Text.AlignTop) {
return -height
} else if (verticalAlignment === Text.AlignVCenter){
return height * -0.5
} else {
return 0
}
}
}