C

Qt Quick Ultralite layers Example

// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial

import QtQuick 2.15
import QtQuickUltralite.Layers 2.0

ApplicationScreens {
    Screen {
        id: screen

        width: 800
        height: 480

        property bool vertical: height > width

        property int boxWidth: screen.width * 43 / 100
        property int boxHeight: (vertical ? screen.height : Math.min(screen.height, background.height)) * 40 / 100
        property int marginWidth: screen.width * 4 / 100

        AnimatingItemLayer {
            id: bpp32layer
            z: 2

            width: screen.boxWidth
            height: screen.boxHeight

            anchors.top: spriteLayer16bpp.top
            anchors.right: spriteLayer16bpp.right
            anchors.margins: screen.marginWidth

            renderingHints: ItemLayer.OptimizeForSize
            refreshInterval: 4
            colorDepth: 32
            opacity: 0.6
        }

        SpriteLayer {
            id: spriteLayer32bpp
            z: 4
            opacity: 0.6

            anchors.fill: spriteLayer16bpp

            AnimatingItemLayer {
                z: 2
                renderingHints: ItemLayer.OptimizeForSpeed
                width: screen.boxWidth
                height: screen.boxHeight

                anchors.top: parent.top
                anchors.left: parent.left
                anchors.margins: screen.marginWidth

                colorDepth: 32
                refreshInterval: 2
            }

            Repeater {
                model: 6
                MovingImageLayer {
                    z: 1
                    container: spriteLayer32bpp
                    source: "qt-logo.png"
                }
            }
        }

        SpriteLayer {
            id: spriteLayer16bpp
            z: 0

            width: screen.vertical ? parent.width : background.width
            height: screen.vertical ? parent.height : background.height

            anchors.centerIn: parent

            depth: ItemLayer.Bpp16

            ImageLayer {
                id: background
                z: 0
                anchors.centerIn: parent
                source: "background-big.png"
            }

            AnimatingItemLayer {
                z: 1
                renderingHints: ItemLayer.OptimizeForSpeed
                width: screen.boxWidth
                height: screen.boxHeight

                anchors.left: parent.left
                anchors.bottom: parent.bottom
                anchors.margins: screen.marginWidth

                colorDepth: 16
                depth: ItemLayer.Bpp16
            }
        }

        AnimatingItemLayer {
            depth: ItemLayer.Bpp16Alpha
            z: 1
            width: screen.boxWidth
            height: screen.boxHeight

            anchors.right: spriteLayer16bpp.right
            anchors.bottom: spriteLayer16bpp.bottom
            anchors.margins: screen.marginWidth

            colorDepth: 16
            opacity: 0.6
        }
    }
}