void RgbEffects::RenderSingleStrandSkips(int Skips_BandSize, int Skips_SkipSize, int Skips_StartPos, const wxString & Skips_Direction)
{
    int x = Skips_StartPos - 1;
    xlColour color, black(0,0,0);
    int second = 0;
    int max = BufferWi;
    int direction = mapDirection(Skips_Direction);
    if (direction > 1) {
        max /= 2;
    }



    size_t colorcnt = GetColorCount();
    if (fitToTime) {
        int position = (GetEffectTimeIntervalPosition() * speed);
        x += position * Skips_BandSize;
    } else if (speed > 1) {
        int cur = state / 10;
        x += cur * Skips_BandSize;
    }
    while (x > max) {
        x -= (Skips_BandSize +  Skips_SkipSize) * colorcnt;
    }

    int firstX = x;
    int colorIdx = 0;

    while (x < max) {
        palette.GetColor(colorIdx, color);
        colorIdx++;
        if (colorIdx >= colorcnt) {
            colorIdx = 0;
        }
        for (int cnt = 0; cnt < Skips_BandSize && x < max; cnt++) {
            int mappedX = mapX(x, max, direction, second);
            if (mappedX >= 0 && mappedX < BufferWi) {
                for (int y = 0; y < BufferHt; y++) {
                    SetPixel(mappedX, y, color);
                }
            }
            if (second >= 0 && second < BufferWi) {
                for (int y = 0; y < BufferHt; y++) {
                    SetPixel(second, y, color);
                }
            }
            x++;
        }
        x += Skips_SkipSize;
    }
    colorIdx = GetColorCount() - 1;
    x = firstX - 1;
    while (x >= 0) {
        x -= Skips_SkipSize;

        palette.GetColor(colorIdx, color);
        colorIdx--;
        if (colorIdx < 0) {
            colorIdx = GetColorCount() - 1;
        }
        for (int cnt = 0; cnt < Skips_BandSize && x >= 0; cnt++) {
            int mappedX = mapX(x, max, direction, second);
            if (mappedX >= 0 && mappedX < BufferWi) {
                for (int y = 0; y < BufferHt; y++) {
                    SetPixel(mappedX, y, color);
                }
            }
            if (second >= 0 && second < BufferWi) {
                for (int y = 0; y < BufferHt; y++) {
                    SetPixel(second, y, color);
                }
            }
            x--;
        }
    }
}
Exemple #2
0
int main(int argc, char **argv)
{
    if (argc != 2) {
        fprintf(stderr, "usage: %s <xml input file>\n", argv[0]);
        return 1;
    }

    QCoreApplication app(argc, argv);

    QFile file;
    file.setFileName(argv[1]);
    if (!file.open(QIODevice::ReadOnly)) {
        fprintf(stderr, "cannot open %s: %s\n", qPrintable(file.fileName()), qPrintable(file.errorString()));
        return 1;
    }

    QDomDocument dom;
    dom.setContent(&file);

    if (dom.documentElement().tagName() != QLatin1String("xkbConfigRegistry")) {
        fprintf(stderr, "cannot parse %s, this is not an XKB config file\n", qPrintable(file.fileName()));
        return 1;
    }

    QDomElement layoutList = find("layoutList", dom.documentElement());
    if (layoutList.isNull()) {
        fprintf(stderr, "cannot parse %s, this is not an XKB config file\n", qPrintable(file.fileName()));
        return 1;
    }

    QList<XKBLayout> layouts = findLayouts(layoutList);

    // copyright and stuff
    printf("/****************************************************************************\n"
           "**\n"
           "** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n"
           "** All rights reserved.\n"
           "** Contact: Nokia Corporation ([email protected])\n"
           "**\n"
           "** This file is part of the QtGui module of the Qt Toolkit.\n"
           "**\n"
           "** $QT_BEGIN_LICENSE:LGPL$\n"
           "** Commercial Usage\n"
           "** Licensees holding valid Qt Commercial licenses may use this file in\n"
           "** accordance with the Qt Commercial License Agreement provided with the\n"
           "** Software or, alternatively, in accordance with the terms contained in\n"
           "** a written agreement between you and Nokia.\n"
           "**\n"
           "** GNU Lesser General Public License Usage\n"
           "** Alternatively, this file may be used under the terms of the GNU Lesser\n"
           "** General Public License version 2.1 as published by the Free Software\n"
           "** Foundation and appearing in the file LICENSE.LGPL included in the\n"
           "** packaging of this file.  Please review the following information to\n"
           "** ensure the GNU Lesser General Public License version 2.1 requirements\n"
           "** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.\n"
           "**\n"
           "** In addition, as a special exception, Nokia gives you certain additional\n"
           "** rights.  These rights are described in the Nokia Qt LGPL Exception\n"
           "** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.\n"
           "**\n"
           "** GNU General Public License Usage\n"
           "** Alternatively, this file may be used under the terms of the GNU\n"
           "** General Public License version 3.0 as published by the Free Software\n"
           "** Foundation and appearing in the file LICENSE.GPL included in the\n"
           "** packaging of this file.  Please review the following information to\n"
           "** ensure the GNU General Public License version 3.0 requirements will be\n"
           "** met: http://www.gnu.org/copyleft/gpl.html.\n"
           "**\n"
           "** If you have questions regarding the use of this file, please contact\n"
           "** Nokia at [email protected].\n"
           "** $QT_END_LICENSE$\n"
           "**\n"
           "****************************************************************************/\n"
           "\n"
           "// This file is auto-generated, do not edit!\n"
           "\n");

    // data structure
    printf("static struct {\n"
           "    const char *layout;\n"
           "    const char *variant; // 0 means any variant\n"
           "    Qt::LayoutDirection direction;\n"
           "    QLocale::Language language;\n"
           "    QLocale::Country country;\n"
           "} xkbLayoutData[] = {\n");

    // contents
    foreach (const XKBLayout &l, layouts) {
        const QString country = mapCountry(l.description);
        QString lang = mapLanguage(l.name);
        if (lang.isEmpty())
            lang = "C";
        printf("    // name = %s, description = %s\n"
               "    { \"%s\", \"\", %s, QLocale::%s, QLocale::%s },\n",
               l.name.toAscii().constData(),
               l.description.toAscii().constData(),
               l.name.toAscii().constData(),
               mapDirection(lang).toAscii().constData(),
               lang.toAscii().constData(),
               country.toAscii().constData());
        foreach (const QString &v, l.variants) {
            QString vlang = mapLanguage(l.name + ":" + v);
            if (vlang.isEmpty())
                vlang = "C";
            printf("    // name = %s:%s, description = %s\n"
                   "    { \"%s\", \"%s\", %s, QLocale::%s, QLocale::%s },\n",
                   l.name.toAscii().constData(),
                   v.toAscii().constData(),
                   l.description.toAscii().constData(),
                   l.name.toAscii().constData(),
                   v.toAscii().constData(),
                   mapDirection(vlang).toAscii().constData(),
                   vlang.toAscii().constData(),
                   country.toAscii().constData());
        }
    }

    // wrapping up
    printf("    { 0, 0, Qt::LeftToRight, QLocale::C, QLocale::AnyCountry }\n"
           "};\n");

    return 0;
}