Add normal hsl and hsla functions

This commit is contained in:
miruka 2019-07-18 01:27:14 -04:00
parent fa61e8f0e3
commit cf13315d4f
2 changed files with 14 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// This file is part of harmonyqml, licensed under LGPLv3. // This file is part of harmonyqml, licensed under LGPLv3.
import QtQuick 2.12 import QtQuick 2.12
import "utils.js" as Ut
QtObject { QtObject {
id: theme id: theme
@ -44,6 +45,7 @@ QtObject {
property color foregroundDim2: Qt.hsla(0, 0, 0.3, 1) property color foregroundDim2: Qt.hsla(0, 0, 0.3, 1)
property color foregroundError: Qt.hsla(0.95, 0.64, 0.32, 1) property color foregroundError: Qt.hsla(0.95, 0.64, 0.32, 1)
property color textBorder: Qt.hsla(0, 0, 0, 0.07) property color textBorder: Qt.hsla(0, 0, 0, 0.07)
property color accent: Ut.hsl(160, 62, 55)
} }
property QtObject controls: QtObject { property QtObject controls: QtObject {

View File

@ -1,6 +1,18 @@
// Copyright 2019 miruka // Copyright 2019 miruka
// This file is part of harmonyqml, licensed under LGPLv3. // This file is part of harmonyqml, licensed under LGPLv3.
function hsl(hue, saturation, lightness) {
return hsla(hue, saturation, lightness, 1.0)
}
function hsla(hue, saturation, lightness, alpha) {
// Convert standard hsla(0-360, 1-100, 1-100, 0-1) to Qt format
return Qt.hsla(hue / 360, saturation / 100, lightness / 100, alpha)
}
function arrayToModelItem(keys_name, array) { function arrayToModelItem(keys_name, array) {
// Convert an array to an object suitable to be in a model, example: // Convert an array to an object suitable to be in a model, example:
// [1, 2, 3] → [{keys_name: 1}, {keys_name: 2}, {keys_name: 3}] // [1, 2, 3] → [{keys_name: 1}, {keys_name: 2}, {keys_name: 3}]