1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #include <test/outputdevice.hxx>
12 #include <vcl/gradient.hxx>
16 Bitmap
OutputDeviceTestGradient::setupLinearGradient()
18 initialSetup(12, 12, constBackgroundColor
);
20 Gradient
aGradient(css::awt::GradientStyle_LINEAR
, Color(0xFF, 0xFF, 0xFF),
21 Color(0x00, 0x00, 0x00));
22 aGradient
.SetAngle(900_deg10
);
23 tools::Rectangle
aDrawRect(maVDRectangle
.Left() + 1, maVDRectangle
.Top() + 1,
24 maVDRectangle
.Right() - 1, maVDRectangle
.Bottom() - 1);
25 mpVirtualDevice
->DrawGradient(aDrawRect
, aGradient
);
27 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
30 Bitmap
OutputDeviceTestGradient::setupLinearGradientAngled()
32 initialSetup(12, 12, constBackgroundColor
);
34 Gradient
aGradient(css::awt::GradientStyle_LINEAR
, Color(0xFF, 0xFF, 0xFF),
35 Color(0x00, 0x00, 0x00));
36 aGradient
.SetAngle(450_deg10
);
37 tools::Rectangle
aDrawRect(maVDRectangle
.Left() + 1, maVDRectangle
.Top() + 1,
38 maVDRectangle
.Right() - 1, maVDRectangle
.Bottom() - 1);
39 mpVirtualDevice
->DrawGradient(aDrawRect
, aGradient
);
41 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
44 Bitmap
OutputDeviceTestGradient::setupLinearGradientBorder()
46 initialSetup(12, 12, constBackgroundColor
);
48 Gradient
aGradient(css::awt::GradientStyle_LINEAR
, Color(0xFF, 0xFF, 0xFF),
49 Color(0x00, 0x00, 0x00));
50 aGradient
.SetBorder(50);
51 tools::Rectangle
aDrawRect(maVDRectangle
.Left() + 1, maVDRectangle
.Top() + 1,
52 maVDRectangle
.Right() - 1, maVDRectangle
.Bottom() - 1);
53 mpVirtualDevice
->DrawGradient(aDrawRect
, aGradient
);
55 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
58 Bitmap
OutputDeviceTestGradient::setupLinearGradientIntensity()
60 initialSetup(12, 12, constBackgroundColor
);
62 Gradient
aGradient(css::awt::GradientStyle_LINEAR
, Color(0xFF, 0xFF, 0xFF),
63 Color(0x00, 0x00, 0x00));
64 aGradient
.SetStartIntensity(50);
65 tools::Rectangle
aDrawRect(maVDRectangle
.Left() + 1, maVDRectangle
.Top() + 1,
66 maVDRectangle
.Right() - 1, maVDRectangle
.Bottom() - 1);
67 mpVirtualDevice
->DrawGradient(aDrawRect
, aGradient
);
69 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
72 Bitmap
OutputDeviceTestGradient::setupLinearGradientSteps()
74 initialSetup(12, 12, constBackgroundColor
);
76 Gradient
aGradient(css::awt::GradientStyle_LINEAR
, Color(0xFF, 0xFF, 0xFF),
77 Color(0x00, 0x00, 0x00));
78 aGradient
.SetAngle(900_deg10
);
79 aGradient
.SetSteps(4);
80 tools::Rectangle
aDrawRect(maVDRectangle
.Left() + 1, maVDRectangle
.Top() + 1,
81 maVDRectangle
.Right() - 1, maVDRectangle
.Bottom() - 1);
82 mpVirtualDevice
->DrawGradient(aDrawRect
, aGradient
);
84 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
87 Bitmap
OutputDeviceTestGradient::setupAxialGradient()
89 initialSetup(13, 13, constBackgroundColor
);
91 Gradient
aGradient(css::awt::GradientStyle_AXIAL
, Color(0xFF, 0xFF, 0xFF),
92 Color(0x00, 0x00, 0x00));
93 aGradient
.SetAngle(900_deg10
);
94 tools::Rectangle
aDrawRect(maVDRectangle
.Left() + 1, maVDRectangle
.Top() + 1,
95 maVDRectangle
.Right() - 1, maVDRectangle
.Bottom() - 1);
96 mpVirtualDevice
->DrawGradient(aDrawRect
, aGradient
);
98 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
101 Bitmap
OutputDeviceTestGradient::setupRadialGradient()
103 initialSetup(12, 12, constBackgroundColor
);
105 Gradient
aGradient(css::awt::GradientStyle_RADIAL
, Color(0xFF, 0xFF, 0xFF),
106 Color(0x00, 0x00, 0x00));
107 tools::Rectangle
aDrawRect(maVDRectangle
.Left() + 1, maVDRectangle
.Top() + 1,
108 maVDRectangle
.Right() - 1, maVDRectangle
.Bottom() - 1);
109 mpVirtualDevice
->DrawGradient(aDrawRect
, aGradient
);
111 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
114 Bitmap
OutputDeviceTestGradient::setupRadialGradientOfs()
116 initialSetup(12, 12, constBackgroundColor
);
118 Gradient
aGradient(css::awt::GradientStyle_RADIAL
, Color(0xFF, 0xFF, 0xFF),
119 Color(0x00, 0x00, 0x00));
120 aGradient
.SetOfsX(100); // Move center to the bottom-right corner.
121 aGradient
.SetOfsY(100);
122 tools::Rectangle
aDrawRect(maVDRectangle
.Left() + 1, maVDRectangle
.Top() + 1,
123 maVDRectangle
.Right() - 1, maVDRectangle
.Bottom() - 1);
124 mpVirtualDevice
->DrawGradient(aDrawRect
, aGradient
);
126 return mpVirtualDevice
->GetBitmap(maVDRectangle
.TopLeft(), maVDRectangle
.GetSize());
129 } // end namespace vcl::test
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */