<commit_before>#include "gradient.h"

#include <QImage>
#include <QColor>
#include <QPainter>

QImage Gradient::m_rgb = QImage();

QImage Gradient::getRGBGradient()
{
    initialize();

    return m_rgb;
}

QColor Gradient::getRGBColor(const quint32 x, const quint32 y)
{
    Q_ASSERT(x < 255);
    Q_ASSERT(y < 255);

    initialize();

    return QColor(m_rgb.pixel (qMin(x, (quint32)255), qMin(y,(quint32)255)));
}

void Gradient::fillWithGradient(int r, int g, int b, QPainter *painter, int x)
{
    QColor top = Qt::black;
    QColor col(r, g , b);
    QColor bottom = Qt::white;

    QLinearGradient blackGrad(QPointF(0,0), QPointF(0, 127));
    blackGrad.setColorAt(0, top);
    blackGrad.setColorAt(1, col);
    QLinearGradient whiteGrad(QPointF(0,128), QPointF(0, 255));
    whiteGrad.setColorAt(0, col);
    whiteGrad.setColorAt(1, bottom);

    painter->fillRect(x, 0, x, 128, blackGrad);
    painter->fillRect(x, 128, x, 256, whiteGrad);
}

void Gradient::initialize ()
{
    if( m_rgb.isNull () == false )
        return;<commit_msg>Fix assert on gradient<commit_after>#include "gradient.h"

#include <QImage>
#include <QColor>
#include <QPainter>

QImage Gradient::m_rgb = QImage();

QImage Gradient::getRGBGradient()
{
    initialize();

    return m_rgb;
}

QColor Gradient::getRGBColor(const quint32 x, const quint32 y)
{
    initialize();

    return QColor(m_rgb.pixel (qMin(x, (quint32)255), qMin(y,(quint32)255)));
}

void Gradient::fillWithGradient(int r, int g, int b, QPainter *painter, int x)
{
    QColor top = Qt::black;
    QColor col(r, g , b);
    QColor bottom = Qt::white;

    QLinearGradient blackGrad(QPointF(0,0), QPointF(0, 127));
    blackGrad.setColorAt(0, top);
    blackGrad.setColorAt(1, col);
    QLinearGradient whiteGrad(QPointF(0,128), QPointF(0, 255));
    whiteGrad.setColorAt(0, col);
    whiteGrad.setColorAt(1, bottom);

    painter->fillRect(x, 0, x, 128, blackGrad);
    painter->fillRect(x, 128, x, 256, whiteGrad);
}

void Gradient::initialize ()
{
    if( m_rgb.isNull () == false )
        return;
{'fraction_non_alphanumeric': 0.15384615384615385, 'fraction_numerical': 0.043816942551119765, 'mean_word_length': 4.229007633587786, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3707097', 'n_tokens_mistral': 853, 'n_tokens_neox': 768, 'n_words': 170}