Warning, /education/gcompris/src/activities/land_safe/Accelerometer.qml is written in an unsupported language. File is not indexed.

0001 /* GCompris - Accelerometer.qml
0002  *
0003  * SPDX-FileCopyrightText: 2016 Holger Kaelberer <holger.k@elberer.de>
0004  *
0005  * Authors:
0006  *   Holger Kaelberer <holger.k@elberer.de>
0007  *
0008  *   SPDX-License-Identifier: GPL-3.0-or-later
0009  */
0010 import QtQuick 2.12
0011 import "../../core"
0012 
0013 Item {
0014     id: root
0015 
0016     property double max: 1
0017     property double min: -1
0018     property double current: min
0019     property alias currentRect: currentRect.anchors
0020 
0021     Rectangle {
0022         id: rect
0023         width: parent.width
0024         height: parent.height
0025         anchors.fill: parent
0026         border.width: root.width / 10
0027         border.color: "lightgray"
0028         radius: root.width / 3
0029 
0030         gradient: Gradient {
0031             GradientStop { position: 0.0; color: "green" }
0032             GradientStop { position: 1-(-root.min/(root.max-root.min)); color: "yellow" }
0033             GradientStop { position: 1.0; color: "red" }
0034         }
0035 
0036         Rectangle {
0037             id: baseline
0038             height: 2
0039             width: rect.width
0040             anchors.left: rect.left
0041             anchors.leftMargin: 0
0042             anchors.bottom: rect.bottom
0043             anchors.bottomMargin: -root.min/(root.max-root.min) * rect.height
0044             color: "steelblue"
0045         }
0046 
0047         Rectangle {
0048             id: currentRect
0049             width: rect.width * 1.1
0050             height: root.width / 10
0051             anchors.left: rect.left
0052             anchors.leftMargin: -rect.width * 0.05
0053             anchors.bottom: rect.bottom
0054             anchors.bottomMargin: Math.max(0, (-root.min + root.current)/(root.max-root.min) * rect.height - height)
0055             color: "white"
0056 
0057             Behavior on anchors.bottomMargin {
0058                 PropertyAnimation  {
0059                     duration: 100
0060                     easing.type: Easing.InOutQuad
0061                 }
0062             }
0063         }
0064     }
0065 }