Debian Codegraph @

tests/manual/distancefieldtext/TextScene.qml

raw
1 // Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import Qt3D.Core 2.0
5 import Qt3D.Render 2.0
6 import Qt3D.Input 2.0
7 import Qt3D.Extras 2.9
8 import QtQuick 2.0 as QQ2;
9
10 Entity {
11 id: sceneRoot
12
13 property alias fontFamily : text.font.family
14 property alias fontBold : text.font.bold
15 property alias fontItalic : text.font.italic
16
17 signal clicked()
18
19 Camera {
20 id: camera
21 projectionType: CameraLens.PerspectiveProjection
22 fieldOfView: 45
23 aspectRatio: 16/9
24 nearPlane : 0.1
25 farPlane : 1000.0
26 position: Qt.vector3d( 0.0, 0.0, 20.0 )
27 upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
28 viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
29 }
30
31 FirstPersonCameraController {
32 camera: camera
33 linearSpeed: 0.1 + camera.position.z
34 }
35
36 components: [
37 RenderSettings {
38 activeFrameGraph : ForwardRenderer {
39 camera: camera
40 clearColor: "black"
41 }
42 },
43 InputSettings {
44 }
45 ]
46
47 function getChars(n) {
48 var s = "";
49 for (var i = 0; i < n; i++) {
50 s += String.fromCharCode(32+i);
51 if (i % 16 == 15)
52 s += "\n";
53 }
54 return s;
55 }
56
57 property int strLen : 28
58
59 onClicked: {
60 strLen += 1
61 if (strLen > 96)
62 strLen = 10
63 }
64
65 Entity {
66 components: [
67 Transform {
68 id: rot
69 translation: Qt.vector3d(-5, -5, 0)
70 }
71 ]
72
73 QQ2.SequentialAnimation {
74 loops: QQ2.Animation.Infinite
75 running: true
76 QQ2.NumberAnimation {
77 target: rot
78 property: "rotationY"
79 from: 0; to: -80;
80 duration: 2000
81 }
82 QQ2.NumberAnimation {
83 target: rot
84 property: "rotationY"
85 from: -80; to: 80;
86 duration: 4000
87 }
88 QQ2.NumberAnimation {
89 target: rot
90 property: "rotationY"
91 from: 80; to: 0;
92 duration: 2000
93 }
94 }
95
96 Text2DEntity {
97 id: text
98 font.pointSize: 1
99 text: getChars(strLen)
100 width: 20
101 height: 10
102 }
103 }
104 }