LibreOffice Module drawinglayer (master) 1
texture.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
26#include <vector>
27#include <functional>
28
30{
32 {
33 public:
34 GeoTexSvx();
35 virtual ~GeoTexSvx();
36
37 // compare operator
38 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const;
39 bool operator!=(const GeoTexSvx& rGeoTexSvx) const { return !operator==(rGeoTexSvx); }
40
41 // virtual base methods
42 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const;
43 virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const;
44 };
45
47 {
48 protected:
49 basegfx::ODFGradientInfo maGradientInfo;
51 sal_uInt32 mnRequestedSteps;
53 double mfBorder;
54
55 // provide a single buffer entry used for gradient texture
56 // mapping, see ::modifyBColor implementations
58
59 public:
61 const basegfx::B2DRange& rDefinitionRange,
62 sal_uInt32 nRequestedSteps,
63 const basegfx::BColorStops& rColorStops,
64 double fBorder);
65 virtual ~GeoTexSvxGradient() override;
66
67 // compare operator
68 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override;
69
70 // virtual base methods
72 std::function<void(const basegfx::B2DHomMatrix& rMatrix, const basegfx::BColor& rColor)> aCallback) = 0;
73 };
74
76 {
77 double mfUnitMinX;
79 double mfUnitMaxY;
80
81 public:
83 const basegfx::B2DRange& rDefinitionRange,
84 const basegfx::B2DRange& rOutputRange,
85 sal_uInt32 nRequestedSteps,
86 const basegfx::BColorStops& rColorStops,
87 double fBorder,
88 double fAngle);
89 virtual ~GeoTexSvxGradientLinear() override;
90
92 std::function<void(const basegfx::B2DHomMatrix& rMatrix, const basegfx::BColor& rColor)> aCallback) override;
93 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override;
94 };
95
97 {
98 double mfUnitMinX;
100
101 public:
103 const basegfx::B2DRange& rDefinitionRange,
104 const basegfx::B2DRange& rOutputRange,
105 sal_uInt32 nRequestedSteps,
106 const basegfx::BColorStops& rColorStops,
107 double fBorder,
108 double fAngle);
109 virtual ~GeoTexSvxGradientAxial() override;
110
112 std::function<void(const basegfx::B2DHomMatrix& rMatrix, const basegfx::BColor& rColor)> aCallback) override;
113 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override;
114 };
115
117 {
118 public:
120 const basegfx::B2DRange& rDefinitionRange,
121 sal_uInt32 nRequestedSteps,
122 const basegfx::BColorStops& rColorStops,
123 double fBorder,
124 double fOffsetX,
125 double fOffsetY);
126 virtual ~GeoTexSvxGradientRadial() override;
127
129 std::function<void(const basegfx::B2DHomMatrix& rMatrix, const basegfx::BColor& rColor)> aCallback) override;
130 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override;
131 };
132
134 {
135 public:
137 const basegfx::B2DRange& rDefinitionRange,
138 sal_uInt32 nRequestedSteps,
139 const basegfx::BColorStops& rColorStops,
140 double fBorder,
141 double fOffsetX,
142 double fOffsetY,
143 double fAngle);
144 virtual ~GeoTexSvxGradientElliptical() override;
145
147 std::function<void(const basegfx::B2DHomMatrix& rMatrix, const basegfx::BColor& rColor)> aCallback) override;
148 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override;
149 };
150
152 {
153 public:
155 const basegfx::B2DRange& rDefinitionRange,
156 sal_uInt32 nRequestedSteps,
157 const basegfx::BColorStops& rColorStops,
158 double fBorder,
159 double fOffsetX,
160 double fOffsetY,
161 double fAngle);
162 virtual ~GeoTexSvxGradientSquare() override;
163
165 std::function<void(const basegfx::B2DHomMatrix& rMatrix, const basegfx::BColor& rColor)> aCallback) override;
166 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override;
167 };
168
170 {
171 public:
173 const basegfx::B2DRange& rDefinitionRange,
174 sal_uInt32 nRequestedSteps,
175 const basegfx::BColorStops& rColorStops,
176 double fBorder,
177 double fOffsetX,
178 double fOffsetY,
179 double fAngle);
180 virtual ~GeoTexSvxGradientRect() override;
181
183 std::function<void(const basegfx::B2DHomMatrix& rMatrix, const basegfx::BColor& rColor)> aCallback) override;
184 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override;
185 };
186
187 class GeoTexSvxHatch final : public GeoTexSvx
188 {
193 double mfAngle;
194 sal_uInt32 mnSteps;
195
197
198 public:
200 const basegfx::B2DRange& rDefinitionRange,
201 const basegfx::B2DRange& rOutputRange,
202 double fDistance,
203 double fAngle);
204 virtual ~GeoTexSvxHatch() override;
205
206 // compare operator
207 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override;
208
209 void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices);
210 double getDistanceToHatch(const basegfx::B2DPoint& rUV) const;
212 };
213
214 // This class applies a tiling to the unit range. The given range
215 // will be repeated inside the unit range in X and Y and for each
216 // tile a matrix will be created (by appendTransformations) that
217 // represents the needed transformation to map a filling in unit
218 // coordinates to that tile.
219 // When offsetX is given, every 2nd line will be offsetted by the
220 // given percentage value (offsetX has to be 0.0 <= offsetX <= 1.0).
221 // Accordingly to offsetY. If both are given, offsetX is preferred
222 // and offsetY is ignored.
223 class GeoTexSvxTiled final : public GeoTexSvx
224 {
226 double mfOffsetX;
227 double mfOffsetY;
228
229 public:
231 const basegfx::B2DRange& rRange,
232 double fOffsetX = 0.0,
233 double fOffsetY = 0.0);
234 virtual ~GeoTexSvxTiled() override;
235
236 // compare operator
237 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override;
238
239 // Iterate over created tiles with callback provided.
240 void iterateTiles(std::function<void(double fPosX, double fPosY)> aFunc) const;
241
242 void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) const;
243 sal_uInt32 getNumberOfTiles() const;
244 };
245} // end of namespace drawinglayer::texture
246
247
248/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
GeoTexSvxGradientAxial(const basegfx::B2DRange &rDefinitionRange, const basegfx::B2DRange &rOutputRange, sal_uInt32 nRequestedSteps, const basegfx::BColorStops &rColorStops, double fBorder, double fAngle)
Definition: texture.cxx:250
virtual void modifyBColor(const basegfx::B2DPoint &rUV, basegfx::BColor &rBColor, double &rfOpacity) const override
Definition: texture.cxx:365
virtual void appendTransformationsAndColors(std::function< void(const basegfx::B2DHomMatrix &rMatrix, const basegfx::BColor &rColor)> aCallback) override
Definition: texture.cxx:287
GeoTexSvxGradientElliptical(const basegfx::B2DRange &rDefinitionRange, sal_uInt32 nRequestedSteps, const basegfx::BColorStops &rColorStops, double fBorder, double fOffsetX, double fOffsetY, double fAngle)
Definition: texture.cxx:488
virtual void modifyBColor(const basegfx::B2DPoint &rUV, basegfx::BColor &rBColor, double &rfOpacity) const override
Definition: texture.cxx:579
virtual void appendTransformationsAndColors(std::function< void(const basegfx::B2DHomMatrix &rMatrix, const basegfx::BColor &rColor)> aCallback) override
Definition: texture.cxx:510
virtual void appendTransformationsAndColors(std::function< void(const basegfx::B2DHomMatrix &rMatrix, const basegfx::BColor &rColor)> aCallback) override
Definition: texture.cxx:135
virtual void modifyBColor(const basegfx::B2DPoint &rUV, basegfx::BColor &rBColor, double &rfOpacity) const override
Definition: texture.cxx:232
GeoTexSvxGradientLinear(const basegfx::B2DRange &rDefinitionRange, const basegfx::B2DRange &rOutputRange, sal_uInt32 nRequestedSteps, const basegfx::BColorStops &rColorStops, double fBorder, double fAngle)
Definition: texture.cxx:102
virtual void appendTransformationsAndColors(std::function< void(const basegfx::B2DHomMatrix &rMatrix, const basegfx::BColor &rColor)> aCallback) override
Definition: texture.cxx:407
GeoTexSvxGradientRadial(const basegfx::B2DRange &rDefinitionRange, sal_uInt32 nRequestedSteps, const basegfx::BColorStops &rColorStops, double fBorder, double fOffsetX, double fOffsetY)
Definition: texture.cxx:387
virtual void modifyBColor(const basegfx::B2DPoint &rUV, basegfx::BColor &rBColor, double &rfOpacity) const override
Definition: texture.cxx:469
GeoTexSvxGradientRect(const basegfx::B2DRange &rDefinitionRange, sal_uInt32 nRequestedSteps, const basegfx::BColorStops &rColorStops, double fBorder, double fOffsetX, double fOffsetY, double fAngle)
Definition: texture.cxx:701
virtual void appendTransformationsAndColors(std::function< void(const basegfx::B2DHomMatrix &rMatrix, const basegfx::BColor &rColor)> aCallback) override
Definition: texture.cxx:723
virtual void modifyBColor(const basegfx::B2DPoint &rUV, basegfx::BColor &rBColor, double &rfOpacity) const override
Definition: texture.cxx:792
virtual void appendTransformationsAndColors(std::function< void(const basegfx::B2DHomMatrix &rMatrix, const basegfx::BColor &rColor)> aCallback) override
Definition: texture.cxx:620
virtual void modifyBColor(const basegfx::B2DPoint &rUV, basegfx::BColor &rBColor, double &rfOpacity) const override
Definition: texture.cxx:682
GeoTexSvxGradientSquare(const basegfx::B2DRange &rDefinitionRange, sal_uInt32 nRequestedSteps, const basegfx::BColorStops &rColorStops, double fBorder, double fOffsetX, double fOffsetY, double fAngle)
Definition: texture.cxx:598
virtual void appendTransformationsAndColors(std::function< void(const basegfx::B2DHomMatrix &rMatrix, const basegfx::BColor &rColor)> aCallback)=0
basegfx::BColorStops::BColorStopRange maLastColorStopRange
Definition: texture.hxx:57
virtual bool operator==(const GeoTexSvx &rGeoTexSvx) const override
Definition: texture.cxx:90
basegfx::ODFGradientInfo maGradientInfo
Definition: texture.hxx:49
GeoTexSvxGradient(const basegfx::B2DRange &rDefinitionRange, sal_uInt32 nRequestedSteps, const basegfx::BColorStops &rColorStops, double fBorder)
Definition: texture.cxx:73
basegfx::B2DHomMatrix maBackTextureTransform
Definition: texture.hxx:191
virtual bool operator==(const GeoTexSvx &rGeoTexSvx) const override
Definition: texture.cxx:868
void appendTransformations(::std::vector< basegfx::B2DHomMatrix > &rMatrices)
Definition: texture.cxx:879
virtual ~GeoTexSvxHatch() override
Definition: texture.cxx:864
GeoTexSvxHatch(const basegfx::B2DRange &rDefinitionRange, const basegfx::B2DRange &rOutputRange, double fDistance, double fAngle)
Definition: texture.cxx:811
double getDistanceToHatch(const basegfx::B2DPoint &rUV) const
Definition: texture.cxx:932
basegfx::B2DHomMatrix maTextureTransform
Definition: texture.hxx:190
const basegfx::B2DHomMatrix & getBackTextureTransform() const
Definition: texture.cxx:950
sal_uInt32 getNumberOfTiles() const
Definition: texture.cxx:990
GeoTexSvxTiled(const basegfx::B2DRange &rRange, double fOffsetX=0.0, double fOffsetY=0.0)
Definition: texture.cxx:962
void appendTransformations(::std::vector< basegfx::B2DHomMatrix > &rMatrices) const
Definition: texture.cxx:997
virtual ~GeoTexSvxTiled() override
Definition: texture.cxx:976
virtual bool operator==(const GeoTexSvx &rGeoTexSvx) const override
Definition: texture.cxx:980
void iterateTiles(std::function< void(double fPosX, double fPosY)> aFunc) const
Definition: texture.cxx:1010
virtual bool operator==(const GeoTexSvx &rGeoTexSvx) const
Definition: texture.cxx:50
virtual void modifyOpacity(const basegfx::B2DPoint &rUV, double &rfOpacity) const
Definition: texture.cxx:64
virtual void modifyBColor(const basegfx::B2DPoint &rUV, basegfx::BColor &rBColor, double &rfOpacity) const
Definition: texture.cxx:56
bool operator!=(const GeoTexSvx &rGeoTexSvx) const
Definition: texture.hxx:39