Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / vcl / backendtest / outputdevice / polyline.cxx
blob53a9edab9d1101ff22ddd2b6c2ac04de5bcfdffb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
11 #include <test/outputdevice.hxx>
13 namespace vcl {
14 namespace test {
16 namespace
19 void drawPolyLineOffset(OutputDevice& rDevice, tools::Rectangle const & rRect, int nOffset)
21 tools::Polygon aPolygon(4);
22 aPolygon.SetPoint(Point(rRect.Left() + nOffset, rRect.Top() + nOffset), 0);
23 aPolygon.SetPoint(Point(rRect.Right() - nOffset, rRect.Top() + nOffset), 1);
24 aPolygon.SetPoint(Point(rRect.Right() - nOffset, rRect.Bottom() - nOffset), 2);
25 aPolygon.SetPoint(Point(rRect.Left() + nOffset, rRect.Bottom() - nOffset), 3);
26 aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
28 rDevice.DrawPolyLine(aPolygon);
31 } // end anonymous namespace
33 Bitmap OutputDeviceTestPolyLine::setupRectangle(bool bEnableAA)
35 initialSetup(13, 13, constBackgroundColor, bEnableAA);
37 mpVirtualDevice->SetLineColor(constLineColor);
38 mpVirtualDevice->SetFillColor();
40 drawPolyLineOffset(*mpVirtualDevice, maVDRectangle, 2);
41 drawPolyLineOffset(*mpVirtualDevice, maVDRectangle, 5);
43 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
46 Bitmap OutputDeviceTestPolyLine::setupDiamond()
48 initialSetup(11, 11, constBackgroundColor);
50 mpVirtualDevice->SetLineColor(constLineColor);
51 mpVirtualDevice->SetFillColor();
53 Point aPoint1, aPoint2, aPoint3, aPoint4;
54 OutputDeviceTestCommon::createDiamondPoints(maVDRectangle, 4, aPoint1, aPoint2, aPoint3, aPoint4);
56 tools::Polygon aPolygon(4);
58 aPolygon.SetPoint(aPoint1, 0);
59 aPolygon.SetPoint(aPoint2, 1);
60 aPolygon.SetPoint(aPoint3, 2);
61 aPolygon.SetPoint(aPoint4, 3);
62 aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
64 mpVirtualDevice->DrawPolyLine(aPolygon);
66 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
69 Bitmap OutputDeviceTestPolyLine::setupLines()
71 initialSetup(13, 13, constBackgroundColor);
73 mpVirtualDevice->SetLineColor(constLineColor);
74 mpVirtualDevice->SetFillColor();
76 Point aHorizontalLinePoint1, aHorizontalLinePoint2;
77 Point aVerticalLinePoint1, aVerticalLinePoint2;
78 Point aDiagonalLinePoint1, aDiagonalLinePoint2;
80 OutputDeviceTestCommon::createHorizontalVerticalDiagonalLinePoints(
81 maVDRectangle, aHorizontalLinePoint1, aHorizontalLinePoint2,
82 aVerticalLinePoint1, aVerticalLinePoint2,
83 aDiagonalLinePoint1, aDiagonalLinePoint2);
85 tools::Polygon aHorizontalPolygon(2);
86 aHorizontalPolygon.SetPoint(aHorizontalLinePoint1, 0);
87 aHorizontalPolygon.SetPoint(aHorizontalLinePoint2, 1);
88 mpVirtualDevice->DrawPolyLine(aHorizontalPolygon);
90 tools::Polygon aVerticalPolygon(2);
91 aVerticalPolygon.SetPoint(aVerticalLinePoint1, 0);
92 aVerticalPolygon.SetPoint(aVerticalLinePoint2, 1);
93 mpVirtualDevice->DrawPolyLine(aVerticalPolygon);
95 tools::Polygon aDiagonalPolygon(2);
96 aDiagonalPolygon.SetPoint(aDiagonalLinePoint1, 0);
97 aDiagonalPolygon.SetPoint(aDiagonalLinePoint2, 1);
98 mpVirtualDevice->DrawPolyLine(aDiagonalPolygon);
100 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
103 Bitmap OutputDeviceTestPolyLine::setupAALines()
105 initialSetup(13, 13, constBackgroundColor);
107 mpVirtualDevice->SetAntialiasing(AntialiasingFlags::EnableB2dDraw);
108 mpVirtualDevice->SetLineColor(constLineColor);
109 mpVirtualDevice->SetFillColor();
111 Point aHorizontalLinePoint1, aHorizontalLinePoint2;
112 Point aVerticalLinePoint1, aVerticalLinePoint2;
113 Point aDiagonalLinePoint1, aDiagonalLinePoint2;
115 OutputDeviceTestCommon::createHorizontalVerticalDiagonalLinePoints(
116 maVDRectangle, aHorizontalLinePoint1, aHorizontalLinePoint2,
117 aVerticalLinePoint1, aVerticalLinePoint2,
118 aDiagonalLinePoint1, aDiagonalLinePoint2);
120 tools::Polygon aHorizontalPolygon(2);
121 aHorizontalPolygon.SetPoint(aHorizontalLinePoint1, 0);
122 aHorizontalPolygon.SetPoint(aHorizontalLinePoint2, 1);
123 mpVirtualDevice->DrawPolyLine(aHorizontalPolygon);
125 tools::Polygon aVerticalPolygon(2);
126 aVerticalPolygon.SetPoint(aVerticalLinePoint1, 0);
127 aVerticalPolygon.SetPoint(aVerticalLinePoint2, 1);
128 mpVirtualDevice->DrawPolyLine(aVerticalPolygon);
130 tools::Polygon aDiagonalPolygon(2);
131 aDiagonalPolygon.SetPoint(aDiagonalLinePoint1, 0);
132 aDiagonalPolygon.SetPoint(aDiagonalLinePoint2, 1);
133 mpVirtualDevice->DrawPolyLine(aDiagonalPolygon);
135 return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
138 }} // end namespace vcl::test
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */