diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-05-25 17:12:07 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-05-31 15:50:50 +0000 |
commit | c4a21708ed186640f4db381dc800febdbc85941e (patch) | |
tree | 72c5414f12b15d6b5e932666a6f4bb72f0ba2bfa /tests/auto/gui/painting/qbrush | |
parent | c538a333db4b7526fb4d9a82c06296d2492bf000 (diff) |
Provide presets for QGradient
Similar to Qt::GlobalColor, the presets allow the user to create
brushes based on predefined gradients, quickly getting pretty pixels
on screen.
The presets are based on the linear gradients from WebGradients, a
free collection of gradients, hosted at https://webgradients.com/.
The few radial and blended gradient presets have been excluded.
Change-Id: I1ce8f2210a6045c9edb8829ab3eddcc313549127
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/gui/painting/qbrush')
-rw-r--r-- | tests/auto/gui/painting/qbrush/tst_qbrush.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp index a2f7a3aa07..8cb1d92568 100644 --- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp +++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp @@ -58,6 +58,7 @@ private slots: void testQGradientCopyConstructor(); void gradientStops(); + void gradientPresets(); void textures(); @@ -326,6 +327,26 @@ void tst_QBrush::gradientStops() QCOMPARE(gradient.stops().at(0).second, QColor()); } +void tst_QBrush::gradientPresets() +{ + QGradient gradient(QGradient::WarmFlame); + QCOMPARE(gradient.type(), QGradient::LinearGradient); + QCOMPARE(gradient.coordinateMode(), QGradient::ObjectBoundingMode); + + QLinearGradient *lg = static_cast<QLinearGradient *>(&gradient); + QCOMPARE(lg->start(), QPointF(0, 1)); + QCOMPARE(lg->finalStop(), QPointF(1, 0)); + + QCOMPARE(lg->stops().size(), 3); + QCOMPARE(lg->stops().at(0), QGradientStop(0, QColor(QLatin1Literal("#ff9a9e")))); + QCOMPARE(lg->stops().at(1), QGradientStop(0.99, QColor(QLatin1Literal("#fad0c4")))); + QCOMPARE(lg->stops().at(2), QGradientStop(1, QColor(QLatin1Literal("#fad0c4")))); + + + QGradient invalidPreset(QGradient::Preset(-1)); + QCOMPARE(invalidPreset.type(), QGradient::NoGradient); +} + void fill(QPaintDevice *pd) { QPainter p(pd); |