Fluid
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1/*
2 * This file is part of Fluid.
3 *
4 * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
5 *
6 * $BEGIN_LICENSE:MPL2$
7 *
8 * This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 *
12 * $END_LICENSE$
13 */
14
15#pragma once
16
17#include <QColor>
18#include <QObject>
19#include <QQmlEngine>
20
26class Color : public QObject
27{
28 Q_OBJECT
29 QML_ELEMENT
30 QML_SINGLETON
31public:
32 explicit Color(QObject *parent = nullptr);
33
38 Q_INVOKABLE QColor transparent(const QColor &color, qreal alpha);
39
40
44 Q_INVOKABLE QColor blend(const QColor &color1, const QColor &color2, qreal alpha);
45
49 Q_INVOKABLE qreal luminance(const QColor &color);
50
54 Q_INVOKABLE bool isDarkColor(const QColor &color);
55
61 Q_INVOKABLE QColor lightDark(const QColor &background, const QColor &lightColor,
62 const QColor &darkColor);
63
64 static Color *create(QQmlEngine *engine, QJSEngine *jsEngine);
65};
66
Utility functions for colors.
Definition color.h:27
static Color * create(QQmlEngine *engine, QJSEngine *jsEngine)
Definition color.cpp:52
Q_INVOKABLE QColor blend(const QColor &color1, const QColor &color2, qreal alpha)
Definition color.cpp:27
Q_INVOKABLE qreal luminance(const QColor &color)
Definition color.cpp:36
Q_INVOKABLE QColor lightDark(const QColor &background, const QColor &lightColor, const QColor &darkColor)
Definition color.cpp:47
Q_INVOKABLE bool isDarkColor(const QColor &color)
Definition color.cpp:41
Q_INVOKABLE QColor transparent(const QColor &color, qreal alpha)
Definition color.cpp:22