1.0 KiB · text History cc97953
import QtQuick
import org.kde.kirigami as Kirigami

// A machine's first pixels as one continuous band, the strip the web UI
// and the phone draw under every running machine.
Item {
    id: strip

    property var pixels: []
    property real cellHeight: Kirigami.Units.smallSpacing * 2

    implicitHeight: cellHeight
    clip: true

    Repeater {
        model: strip.pixels.length

        // Each cell spans whole device pixels from its own left edge to the
        // next one's, so neighbours meet exactly: no seams from fractional
        // widths, however many pixels the width is split into.
        delegate: Rectangle {
            required property int index
            readonly property var px: strip.pixels[index] || [0, 0, 0]
            readonly property int n: strip.pixels.length
            x: Math.floor(index * strip.width / n)
            width: Math.floor((index + 1) * strip.width / n) - x
            height: strip.cellHeight
            antialiasing: false
            color: Qt.rgba(px[0] / 255, px[1] / 255, px[2] / 255, 1)
        }
    }
}