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 #ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX 21 #define INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX 22 23 #include <drawinglayer/drawinglayerdllapi.h> 24 25 #include <basegfx/matrix/b2dhommatrix.hxx> 26 #include <basegfx/range/b2drange.hxx> 27 #include <basegfx/color/bcolor.hxx> 28 #include <basegfx/utils/gradienttools.hxx> 29 #include <vector> 30 31 32 namespace drawinglayer 33 { 34 namespace texture 35 { 36 class DRAWINGLAYER_DLLPUBLIC GeoTexSvx 37 { 38 public: 39 GeoTexSvx(); 40 virtual ~GeoTexSvx(); 41 42 // compare operator 43 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const; operator !=(const GeoTexSvx & rGeoTexSvx) const44 bool operator!=(const GeoTexSvx& rGeoTexSvx) const { return !operator==(rGeoTexSvx); } 45 46 // virtual base methods 47 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; 48 virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const; 49 }; 50 } // end of namespace texture 51 } // end of namespace drawinglayer 52 53 54 namespace drawinglayer 55 { 56 namespace texture 57 { 58 /// helper class for processing equal number of matrices and colors 59 /// for texture processing 60 struct B2DHomMatrixAndBColor 61 { 62 basegfx::B2DHomMatrix maB2DHomMatrix; 63 basegfx::BColor maBColor; 64 }; 65 } // end of namespace texture 66 } // end of namespace drawinglayer 67 68 69 namespace drawinglayer 70 { 71 namespace texture 72 { 73 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradient : public GeoTexSvx 74 { 75 protected: 76 basegfx::ODFGradientInfo maGradientInfo; 77 basegfx::B2DRange maDefinitionRange; 78 basegfx::BColor maStart; 79 basegfx::BColor maEnd; 80 double mfBorder; 81 82 public: 83 GeoTexSvxGradient( 84 const basegfx::B2DRange& rDefinitionRange, 85 const basegfx::BColor& rStart, 86 const basegfx::BColor& rEnd, 87 double fBorder); 88 virtual ~GeoTexSvxGradient() override; 89 90 // compare operator 91 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override; 92 93 // virtual base methods 94 virtual void appendTransformationsAndColors( 95 std::vector< B2DHomMatrixAndBColor >& rEntries, 96 basegfx::BColor& rOuterColor) = 0; 97 }; 98 } // end of namespace texture 99 } // end of namespace drawinglayer 100 101 102 namespace drawinglayer 103 { 104 namespace texture 105 { 106 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientLinear final : public GeoTexSvxGradient 107 { 108 double mfUnitMinX; 109 double mfUnitWidth; 110 double mfUnitMaxY; 111 112 public: 113 GeoTexSvxGradientLinear( 114 const basegfx::B2DRange& rDefinitionRange, 115 const basegfx::B2DRange& rOutputRange, 116 const basegfx::BColor& rStart, 117 const basegfx::BColor& rEnd, 118 sal_uInt32 nSteps, 119 double fBorder, 120 double fAngle); 121 virtual ~GeoTexSvxGradientLinear() override; 122 123 virtual void appendTransformationsAndColors( 124 std::vector< B2DHomMatrixAndBColor >& rEntries, 125 basegfx::BColor& rOuterColor) override; 126 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; 127 }; 128 } // end of namespace texture 129 } // end of namespace drawinglayer 130 131 132 namespace drawinglayer 133 { 134 namespace texture 135 { 136 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientAxial final : public GeoTexSvxGradient 137 { 138 double mfUnitMinX; 139 double mfUnitWidth; 140 141 public: 142 GeoTexSvxGradientAxial( 143 const basegfx::B2DRange& rDefinitionRange, 144 const basegfx::B2DRange& rOutputRange, 145 const basegfx::BColor& rStart, 146 const basegfx::BColor& rEnd, 147 sal_uInt32 nSteps, 148 double fBorder, 149 double fAngle); 150 virtual ~GeoTexSvxGradientAxial() override; 151 152 virtual void appendTransformationsAndColors( 153 std::vector< B2DHomMatrixAndBColor >& rEntries, 154 basegfx::BColor& rOuterColor) override; 155 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; 156 }; 157 } // end of namespace texture 158 } // end of namespace drawinglayer 159 160 161 namespace drawinglayer 162 { 163 namespace texture 164 { 165 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientRadial final : public GeoTexSvxGradient 166 { 167 public: 168 GeoTexSvxGradientRadial( 169 const basegfx::B2DRange& rDefinitionRange, 170 const basegfx::BColor& rStart, 171 const basegfx::BColor& rEnd, 172 sal_uInt32 nSteps, 173 double fBorder, 174 double fOffsetX, 175 double fOffsetY); 176 virtual ~GeoTexSvxGradientRadial() override; 177 178 virtual void appendTransformationsAndColors( 179 std::vector< B2DHomMatrixAndBColor >& rEntries, 180 basegfx::BColor& rOuterColor) override; 181 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; 182 }; 183 } // end of namespace texture 184 } // end of namespace drawinglayer 185 186 187 namespace drawinglayer 188 { 189 namespace texture 190 { 191 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientElliptical final : public GeoTexSvxGradient 192 { 193 public: 194 GeoTexSvxGradientElliptical( 195 const basegfx::B2DRange& rDefinitionRange, 196 const basegfx::BColor& rStart, 197 const basegfx::BColor& rEnd, 198 sal_uInt32 nSteps, 199 double fBorder, 200 double fOffsetX, 201 double fOffsetY, 202 double fAngle); 203 virtual ~GeoTexSvxGradientElliptical() override; 204 205 virtual void appendTransformationsAndColors( 206 std::vector< B2DHomMatrixAndBColor >& rEntries, 207 basegfx::BColor& rOuterColor) override; 208 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; 209 }; 210 } // end of namespace texture 211 } // end of namespace drawinglayer 212 213 214 namespace drawinglayer 215 { 216 namespace texture 217 { 218 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientSquare final : public GeoTexSvxGradient 219 { 220 public: 221 GeoTexSvxGradientSquare( 222 const basegfx::B2DRange& rDefinitionRange, 223 const basegfx::BColor& rStart, 224 const basegfx::BColor& rEnd, 225 sal_uInt32 nSteps, 226 double fBorder, 227 double fOffsetX, 228 double fOffsetY, 229 double fAngle); 230 virtual ~GeoTexSvxGradientSquare() override; 231 232 virtual void appendTransformationsAndColors( 233 std::vector< B2DHomMatrixAndBColor >& rEntries, 234 basegfx::BColor& rOuterColor) override; 235 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; 236 }; 237 } // end of namespace texture 238 } // end of namespace drawinglayer 239 240 241 namespace drawinglayer 242 { 243 namespace texture 244 { 245 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientRect final : public GeoTexSvxGradient 246 { 247 public: 248 GeoTexSvxGradientRect( 249 const basegfx::B2DRange& rDefinitionRange, 250 const basegfx::BColor& rStart, 251 const basegfx::BColor& rEnd, 252 sal_uInt32 nSteps, 253 double fBorder, 254 double fOffsetX, 255 double fOffsetY, 256 double fAngle); 257 virtual ~GeoTexSvxGradientRect() override; 258 259 virtual void appendTransformationsAndColors( 260 std::vector< B2DHomMatrixAndBColor >& rEntries, 261 basegfx::BColor& rOuterColor) override; 262 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; 263 }; 264 } // end of namespace texture 265 } // end of namespace drawinglayer 266 267 268 namespace drawinglayer 269 { 270 namespace texture 271 { 272 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxHatch final : public GeoTexSvx 273 { 274 basegfx::B2DRange maOutputRange; 275 basegfx::B2DHomMatrix maTextureTransform; 276 basegfx::B2DHomMatrix maBackTextureTransform; 277 double mfDistance; 278 double mfAngle; 279 sal_uInt32 mnSteps; 280 281 bool mbDefinitionRangeEqualsOutputRange : 1; 282 283 public: 284 GeoTexSvxHatch( 285 const basegfx::B2DRange& rDefinitionRange, 286 const basegfx::B2DRange& rOutputRange, 287 double fDistance, 288 double fAngle); 289 virtual ~GeoTexSvxHatch() override; 290 291 // compare operator 292 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override; 293 294 void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); 295 double getDistanceToHatch(const basegfx::B2DPoint& rUV) const; 296 const basegfx::B2DHomMatrix& getBackTextureTransform() const; 297 }; 298 } // end of namespace texture 299 } // end of namespace drawinglayer 300 301 302 namespace drawinglayer 303 { 304 namespace texture 305 { 306 // This class applies a tiling to the unit range. The given range 307 // will be repeated inside the unit range in X and Y and for each 308 // tile a matrix will be created (by appendTransformations) that 309 // represents the needed transformation to map a filling in unit 310 // coordinates to that tile. 311 // When offsetX is given, every 2nd line will be offsetted by the 312 // given percentage value (offsetX has to be 0.0 <= offsetX <= 1.0). 313 // Accordingly to offsetY. If both are given, offsetX is preferred 314 // and offsetY is ignored. 315 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxTiled final : public GeoTexSvx 316 { 317 basegfx::B2DRange maRange; 318 double mfOffsetX; 319 double mfOffsetY; 320 321 sal_Int32 iterateTiles(::std::vector< basegfx::B2DHomMatrix >* pMatrices) const; 322 323 public: 324 GeoTexSvxTiled( 325 const basegfx::B2DRange& rRange, 326 double fOffsetX = 0.0, 327 double fOffsetY = 0.0); 328 virtual ~GeoTexSvxTiled() override; 329 330 // compare operator 331 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override; 332 333 void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) const; 334 sal_uInt32 getNumberOfTiles() const; 335 }; 336 } // end of namespace texture 337 } // end of namespace drawinglayer 338 339 340 #endif //_DRAWINGLAYER_TEXTURE_TEXTURE_HXX 341 342 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 343