C

Qt Quick Ultralite perspective_transforms Example

/****************************************************************************** ** ** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
import QtQuick 2.12 import Constants 1.0 Item { // Canvas parameters property int screenWidth: 800 property int screenHeight: 480 // Cover flow (x, y, w, h) on the screen property real coverFlowW: screenWidth * 0.75 property real coverFlowH: screenHeight * 0.75 property real coverFlowX: (screenWidth - coverFlowW) / 2 property real coverFlowY: (screenHeight - coverFlowH) / 2 // Properties related to covers: which one is selected, // how many covers are in the model and how big is texture property real selectedCover: 0 property int numberOfCovers: 5 readonly property int maximumNumberofCovers: 10 property real coverSize: 128 // viewDistance, fov, showReflection and reflectionDistance are // used in each view property real viewDistance: 6 property real fov: 45 property bool showReflection: true property real reflectionDistance: 270 // viewAngle, cameraHeight and coverScaling are used in all views // except perspective view property real viewAngle: -21.0 property real cameraHeight: -1.2 property real coverScaling: 0.8 // Circle view related parameters property real circleRadius: 2.5 // Carousel view related parameters property real carouselZ: 3 // Perspective view related parameters property real perspectiveViewCenterZ: 1.0 property real perspectiveViewCoverDist: 0.3 property real perspectiveViewCenterDist: 1.4 property real perspectiveViewMaxRot: 80.0 // View type and type transition related parameters // Morph ratio is used to morph from the // previous view (0.0) to the current (new) view (1.0) property real morphRatio: 1 property int currentViewType: CoverFlowType.Carousel property int previousViewType: CoverFlowType.Carousel NumberAnimation on morphRatio { id: morphAnimation from: 0.0 to: 1.0 duration: 200 } function switchViewType(newType : int){ previousViewType = currentViewType currentViewType = newType morphAnimation.start() } Behavior on selectedCover { NumberAnimation { duration: 500 } } Behavior on cameraHeight { NumberAnimation { duration: 200 } } Behavior on viewAngle { NumberAnimation { duration: 200 } } }