• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mcallegari / qlcplus / 13633248611

03 Mar 2025 02:31PM UTC coverage: 31.871% (+0.4%) from 31.5%
13633248611

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/ui/src/rgbitem.cpp
1
/*
2
  Q Light Controller
3
  rgbitem.cpp
4

5
  Copyright (c) Heikki Junnila
6

7
  Licensed under the Apache License, Version 2.0 (the "License");
8
  you may not use this file except in compliance with the License.
9
  You may obtain a copy of the License at
10

11
      http://www.apache.org/licenses/LICENSE-2.0.txt
12

13
  Unless required by applicable law or agreed to in writing, software
14
  distributed under the License is distributed on an "AS IS" BASIS,
15
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  See the License for the specific language governing permissions and
17
  limitations under the License.
18
*/
19

20
#include <QDebug>
21
#include <QBrush>
22
#include <QPen>
23

24
#include "qlcmacros.h"
25
#include "rgbitem.h"
26

27
RGBItem::RGBItem(QAbstractGraphicsShapeItem* graphicsItem)
×
28
    : m_elapsed(0)
×
29
    , m_graphicsItem(graphicsItem)
30
{
31
}
×
32

33
void RGBItem::setColor(QRgb rgb)
×
34
{
35
    m_oldColor = m_graphicsItem->brush().color();
×
36
    m_color = QColor(rgb);
×
37
    m_elapsed = 0;
×
38
}
×
39

40
QRgb RGBItem::color() const
×
41
{
42
    return m_color.rgb();
×
43
}
44

45
void RGBItem::draw(uint elapsedMs, uint targetMs)
×
46
{
47
    m_elapsed += elapsedMs;
×
48

49
    if (targetMs == 0)
×
50
    {
51
        m_graphicsItem->setBrush(m_color);
×
52
    }
53
    else if (m_elapsed <= targetMs)
×
54
    {
55
        int red, green, blue;
56
        if (m_oldColor.red() < m_color.red())
×
57
            red = SCALE(qreal(m_elapsed), qreal(0), qreal(targetMs), qreal(m_oldColor.red()), qreal(m_color.red()));
×
58
        else
59
            red = SCALE(qreal(m_elapsed), qreal(targetMs), qreal(0), qreal(m_color.red()), qreal(m_oldColor.red()));
×
60
        red = CLAMP(red, 0, 255);
×
61

62
        if (m_oldColor.green() < m_color.green())
×
63
            green = SCALE(qreal(m_elapsed), qreal(0), qreal(targetMs), qreal(m_oldColor.green()), qreal(m_color.green()));
×
64
        else
65
            green = SCALE(qreal(m_elapsed), qreal(targetMs), qreal(0), qreal(m_color.green()), qreal(m_oldColor.green()));
×
66
        green = CLAMP(green, 0, 255);
×
67

68
        if (m_oldColor.blue() < m_color.blue())
×
69
            blue = SCALE(qreal(m_elapsed), qreal(0), qreal(targetMs), qreal(m_oldColor.blue()), qreal(m_color.blue()));
×
70
        else
71
            blue = SCALE(qreal(m_elapsed), qreal(targetMs), qreal(0), qreal(m_color.blue()), qreal(m_oldColor.blue()));
×
72
        blue = CLAMP(blue, 0, 255);
×
73

74
        m_graphicsItem->setBrush(QColor(red, green, blue));
×
75
    }
76
    else
77
        m_graphicsItem->setBrush(m_color);
×
78
}
×
79

80
QAbstractGraphicsShapeItem* RGBItem::graphicsItem() const
×
81
{
82
    return m_graphicsItem.data();
×
83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc