QML根据角度变换控制转速数字大小

版权声明:如果对您有帮助,求点赞!本文为博主原创作品,转载请声明出处! https://blog.csdn.net/u011086209/article/details/87188326

import QtQuick 2.6

Text {
    id: rpmText
    // 转速刻度值的坐标
    property int numTextX
    property int numTextY
    // 转速刻度值: 0 ~ 9
    property string numText
    // 转速刻度值颜色
    property string numTextColor
    // 指针当前所在角度
    property var pointerAngle
    // 刻度值所在角度
    property var numTextPosiAngle
    // 判断指针所在角度是否大于刻度值上限角度
    property bool beyondLimitMax: pointerAngle > (numTextPosiAngle + 15)
    // 判断指针所在角度是否处于刻度值上限角度与下限角度之间
    property bool betweenLimit: (pointerAngle > (numTextPosiAngle - 15) && pointerAngle <= (numTextPosiAngle + 15))
    x: numTextX
    y: numTextY
    scale: betweenLimit ? (10/7 - (Math.abs(pointerAngle - numTextPosiAngle) / 43.5)) : 1.0
    opacity: beyondLimitMax ? 1.0 : (betweenLimit ? (1.0 - (Math.abs(pointerAngle - numTextPosiAngle) * 0.8 / 240.0))*0.8 : 0.6)
    text: numText
    color: numTextColor
    font.pixelSize: 23
    font.family: UiController.font["handel-gothic"]
}

猜你喜欢

转载自blog.csdn.net/u011086209/article/details/87188326