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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <drawinglayer/texture/texture.hxx>
21 #include <drawinglayer/tools/converters.hxx>
22 #include <basegfx/numeric/ftools.hxx>
23 #include <basegfx/tools/gradienttools.hxx>
24 #include <basegfx/matrix/b2dhommatrixtools.hxx>
26 namespace drawinglayer
30 GeoTexSvx::GeoTexSvx()
34 GeoTexSvx::~GeoTexSvx()
38 bool GeoTexSvx::operator==(const GeoTexSvx
& /*rGeoTexSvx*/) const
40 // default implementation says yes (no data -> no difference)
44 void GeoTexSvx::modifyBColor(const basegfx::B2DPoint
& /*rUV*/, basegfx::BColor
& rBColor
, double& /*rfOpacity*/) const
46 // base implementation creates random color (for testing only, may also be pure virtual)
47 rBColor
.setRed(tools::getRandomColorRange());
48 rBColor
.setGreen(tools::getRandomColorRange());
49 rBColor
.setBlue(tools::getRandomColorRange());
52 void GeoTexSvx::modifyOpacity(const basegfx::B2DPoint
& rUV
, double& rfOpacity
) const
54 // base implementation uses inverse of luminance of solved color (for testing only, may also be pure virtual)
55 basegfx::BColor aBaseColor
;
56 modifyBColor(rUV
, aBaseColor
, rfOpacity
);
57 rfOpacity
= 1.0 - aBaseColor
.luminance();
59 } // end of namespace texture
60 } // end of namespace drawinglayer
63 namespace drawinglayer
67 GeoTexSvxGradient::GeoTexSvxGradient(
68 const basegfx::B2DRange
& rDefinitionRange
,
69 const basegfx::BColor
& rStart
,
70 const basegfx::BColor
& rEnd
,
71 sal_uInt32
/* nSteps */,
75 maDefinitionRange(rDefinitionRange
),
82 GeoTexSvxGradient::~GeoTexSvxGradient()
86 bool GeoTexSvxGradient::operator==(const GeoTexSvx
& rGeoTexSvx
) const
88 const GeoTexSvxGradient
* pCompare
= dynamic_cast< const GeoTexSvxGradient
* >(&rGeoTexSvx
);
91 && maGradientInfo
== pCompare
->maGradientInfo
92 && maDefinitionRange
== pCompare
->maDefinitionRange
93 && mfBorder
== pCompare
->mfBorder
);
95 } // end of namespace texture
96 } // end of namespace drawinglayer
99 namespace drawinglayer
103 GeoTexSvxGradientLinear::GeoTexSvxGradientLinear(
104 const basegfx::B2DRange
& rDefinitionRange
,
105 const basegfx::B2DRange
& rOutputRange
,
106 const basegfx::BColor
& rStart
,
107 const basegfx::BColor
& rEnd
,
111 : GeoTexSvxGradient(rDefinitionRange
, rStart
, rEnd
, nSteps
, fBorder
),
116 maGradientInfo
= basegfx::tools::createLinearODFGradientInfo(
122 if(rDefinitionRange
!= rOutputRange
)
124 basegfx::B2DRange
aInvOutputRange(rOutputRange
);
126 aInvOutputRange
.transform(maGradientInfo
.getBackTextureTransform());
127 mfUnitMinX
= aInvOutputRange
.getMinX();
128 mfUnitWidth
= aInvOutputRange
.getWidth();
129 mfUnitMaxY
= aInvOutputRange
.getMaxY();
133 GeoTexSvxGradientLinear::~GeoTexSvxGradientLinear()
137 void GeoTexSvxGradientLinear::appendTransformationsAndColors(
138 std::vector
< B2DHomMatrixAndBColor
>& rEntries
,
139 basegfx::BColor
& rOuterColor
)
141 rOuterColor
= maStart
;
143 if(maGradientInfo
.getSteps())
145 const double fStripeWidth(1.0 / maGradientInfo
.getSteps());
146 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor
;
147 basegfx::B2DHomMatrix aPattern
;
149 // bring from unit circle [-1, -1, 1, 1] to unit range [0, 0, 1, 1]
150 aPattern
.scale(0.5, 0.5);
151 aPattern
.translate(0.5, 0.5);
153 // scale and translate in X
154 aPattern
.scale(mfUnitWidth
, 1.0);
155 aPattern
.translate(mfUnitMinX
, 0.0);
157 for(sal_uInt32
a(1); a
< maGradientInfo
.getSteps(); a
++)
159 const double fPos(fStripeWidth
* a
);
160 basegfx::B2DHomMatrix
aNew(aPattern
);
162 // scale and translate in Y
163 double fHeight(1.0 - fPos
);
165 if(a
+ 1 == maGradientInfo
.getSteps() && mfUnitMaxY
> 1.0)
167 fHeight
+= mfUnitMaxY
- 1.0;
170 aNew
.scale(1.0, fHeight
);
171 aNew
.translate(0.0, fPos
);
174 aB2DHomMatrixAndBColor
.maB2DHomMatrix
= maGradientInfo
.getTextureTransform() * aNew
;
176 // interpolate and set color
177 aB2DHomMatrixAndBColor
.maBColor
= interpolate(maStart
, maEnd
, double(a
) / double(maGradientInfo
.getSteps() - 1));
179 rEntries
.push_back(aB2DHomMatrixAndBColor
);
184 void GeoTexSvxGradientLinear::modifyBColor(const basegfx::B2DPoint
& rUV
, basegfx::BColor
& rBColor
, double& /*rfOpacity*/) const
186 const double fScaler(basegfx::tools::getLinearGradientAlpha(rUV
, maGradientInfo
));
188 rBColor
= basegfx::interpolate(maStart
, maEnd
, fScaler
);
190 } // end of namespace texture
191 } // end of namespace drawinglayer
194 namespace drawinglayer
198 GeoTexSvxGradientAxial::GeoTexSvxGradientAxial(
199 const basegfx::B2DRange
& rDefinitionRange
,
200 const basegfx::B2DRange
& rOutputRange
,
201 const basegfx::BColor
& rStart
,
202 const basegfx::BColor
& rEnd
,
206 : GeoTexSvxGradient(rDefinitionRange
, rStart
, rEnd
, nSteps
, fBorder
),
210 maGradientInfo
= basegfx::tools::createAxialODFGradientInfo(
216 if(rDefinitionRange
!= rOutputRange
)
218 basegfx::B2DRange
aInvOutputRange(rOutputRange
);
220 aInvOutputRange
.transform(maGradientInfo
.getBackTextureTransform());
221 mfUnitMinX
= aInvOutputRange
.getMinX();
222 mfUnitWidth
= aInvOutputRange
.getWidth();
226 GeoTexSvxGradientAxial::~GeoTexSvxGradientAxial()
230 void GeoTexSvxGradientAxial::appendTransformationsAndColors(
231 std::vector
< B2DHomMatrixAndBColor
>& rEntries
,
232 basegfx::BColor
& rOuterColor
)
236 if(maGradientInfo
.getSteps())
238 const double fStripeWidth(1.0 / maGradientInfo
.getSteps());
239 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor
;
241 for(sal_uInt32
a(1); a
< maGradientInfo
.getSteps(); a
++)
243 const double fPos(fStripeWidth
* a
);
244 basegfx::B2DHomMatrix aNew
;
246 // bring in X from unit circle [-1, -1, 1, 1] to unit range [0, 0, 1, 1]
247 aNew
.scale(0.5, 1.0);
248 aNew
.translate(0.5, 0.0);
250 // scale/translate in X
251 aNew
.scale(mfUnitWidth
, 1.0);
252 aNew
.translate(mfUnitMinX
, 0.0);
254 // already centered in Y on X-Axis, just scale in Y
255 aNew
.scale(1.0, 1.0 - fPos
);
258 aB2DHomMatrixAndBColor
.maB2DHomMatrix
= maGradientInfo
.getTextureTransform() * aNew
;
260 // interpolate and set color
261 aB2DHomMatrixAndBColor
.maBColor
= interpolate(maEnd
, maStart
, double(a
) / double(maGradientInfo
.getSteps() - 1));
263 rEntries
.push_back(aB2DHomMatrixAndBColor
);
268 void GeoTexSvxGradientAxial::modifyBColor(const basegfx::B2DPoint
& rUV
, basegfx::BColor
& rBColor
, double& /*rfOpacity*/) const
270 const double fScaler(basegfx::tools::getAxialGradientAlpha(rUV
, maGradientInfo
));
272 rBColor
= basegfx::interpolate(maStart
, maEnd
, fScaler
);
274 } // end of namespace texture
275 } // end of namespace drawinglayer
278 namespace drawinglayer
282 GeoTexSvxGradientRadial::GeoTexSvxGradientRadial(
283 const basegfx::B2DRange
& rDefinitionRange
,
284 const basegfx::BColor
& rStart
,
285 const basegfx::BColor
& rEnd
,
290 : GeoTexSvxGradient(rDefinitionRange
, rStart
, rEnd
, nSteps
, fBorder
)
292 maGradientInfo
= basegfx::tools::createRadialODFGradientInfo(
294 basegfx::B2DVector(fOffsetX
,fOffsetY
),
299 GeoTexSvxGradientRadial::~GeoTexSvxGradientRadial()
303 void GeoTexSvxGradientRadial::appendTransformationsAndColors(
304 std::vector
< B2DHomMatrixAndBColor
>& rEntries
,
305 basegfx::BColor
& rOuterColor
)
307 rOuterColor
= maStart
;
309 if(maGradientInfo
.getSteps())
311 const double fStepSize(1.0 / maGradientInfo
.getSteps());
312 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor
;
314 for(sal_uInt32
a(1); a
< maGradientInfo
.getSteps(); a
++)
316 const double fSize(1.0 - (fStepSize
* a
));
317 aB2DHomMatrixAndBColor
.maB2DHomMatrix
= maGradientInfo
.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fSize
, fSize
);
318 aB2DHomMatrixAndBColor
.maBColor
= interpolate(maStart
, maEnd
, double(a
) / double(maGradientInfo
.getSteps() - 1));
319 rEntries
.push_back(aB2DHomMatrixAndBColor
);
324 void GeoTexSvxGradientRadial::modifyBColor(const basegfx::B2DPoint
& rUV
, basegfx::BColor
& rBColor
, double& /*rfOpacity*/) const
326 const double fScaler(basegfx::tools::getRadialGradientAlpha(rUV
, maGradientInfo
));
328 rBColor
= basegfx::interpolate(maStart
, maEnd
, fScaler
);
330 } // end of namespace texture
331 } // end of namespace drawinglayer
334 namespace drawinglayer
338 GeoTexSvxGradientElliptical::GeoTexSvxGradientElliptical(
339 const basegfx::B2DRange
& rDefinitionRange
,
340 const basegfx::BColor
& rStart
,
341 const basegfx::BColor
& rEnd
,
347 : GeoTexSvxGradient(rDefinitionRange
, rStart
, rEnd
, nSteps
, fBorder
)
349 maGradientInfo
= basegfx::tools::createEllipticalODFGradientInfo(
351 basegfx::B2DVector(fOffsetX
,fOffsetY
),
357 GeoTexSvxGradientElliptical::~GeoTexSvxGradientElliptical()
361 void GeoTexSvxGradientElliptical::appendTransformationsAndColors(
362 std::vector
< B2DHomMatrixAndBColor
>& rEntries
,
363 basegfx::BColor
& rOuterColor
)
365 rOuterColor
= maStart
;
367 if(maGradientInfo
.getSteps())
371 double fIncrementX(0.0);
372 double fIncrementY(0.0);
374 if(maGradientInfo
.getAspectRatio() > 1.0)
376 fIncrementY
= fHeight
/ maGradientInfo
.getSteps();
377 fIncrementX
= fIncrementY
/ maGradientInfo
.getAspectRatio();
381 fIncrementX
= fWidth
/ maGradientInfo
.getSteps();
382 fIncrementY
= fIncrementX
* maGradientInfo
.getAspectRatio();
385 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor
;
387 for(sal_uInt32
a(1); a
< maGradientInfo
.getSteps(); a
++)
390 fWidth
-= fIncrementX
;
391 fHeight
-= fIncrementY
;
393 aB2DHomMatrixAndBColor
.maB2DHomMatrix
= maGradientInfo
.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fWidth
, fHeight
);
394 aB2DHomMatrixAndBColor
.maBColor
= interpolate(maStart
, maEnd
, double(a
) / double(maGradientInfo
.getSteps() - 1));
395 rEntries
.push_back(aB2DHomMatrixAndBColor
);
400 void GeoTexSvxGradientElliptical::modifyBColor(const basegfx::B2DPoint
& rUV
, basegfx::BColor
& rBColor
, double& /*rfOpacity*/) const
402 const double fScaler(basegfx::tools::getEllipticalGradientAlpha(rUV
, maGradientInfo
));
404 rBColor
= basegfx::interpolate(maStart
, maEnd
, fScaler
);
406 } // end of namespace texture
407 } // end of namespace drawinglayer
410 namespace drawinglayer
414 GeoTexSvxGradientSquare::GeoTexSvxGradientSquare(
415 const basegfx::B2DRange
& rDefinitionRange
,
416 const basegfx::BColor
& rStart
,
417 const basegfx::BColor
& rEnd
,
423 : GeoTexSvxGradient(rDefinitionRange
, rStart
, rEnd
, nSteps
, fBorder
)
425 maGradientInfo
= basegfx::tools::createSquareODFGradientInfo(
427 basegfx::B2DVector(fOffsetX
,fOffsetY
),
433 GeoTexSvxGradientSquare::~GeoTexSvxGradientSquare()
437 void GeoTexSvxGradientSquare::appendTransformationsAndColors(
438 std::vector
< B2DHomMatrixAndBColor
>& rEntries
,
439 basegfx::BColor
& rOuterColor
)
441 rOuterColor
= maStart
;
443 if(maGradientInfo
.getSteps())
445 const double fStepSize(1.0 / maGradientInfo
.getSteps());
446 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor
;
448 for(sal_uInt32
a(1); a
< maGradientInfo
.getSteps(); a
++)
450 const double fSize(1.0 - (fStepSize
* a
));
451 aB2DHomMatrixAndBColor
.maB2DHomMatrix
= maGradientInfo
.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fSize
, fSize
);
452 aB2DHomMatrixAndBColor
.maBColor
= interpolate(maStart
, maEnd
, double(a
) / double(maGradientInfo
.getSteps() - 1));
453 rEntries
.push_back(aB2DHomMatrixAndBColor
);
458 void GeoTexSvxGradientSquare::modifyBColor(const basegfx::B2DPoint
& rUV
, basegfx::BColor
& rBColor
, double& /*rfOpacity*/) const
460 const double fScaler(basegfx::tools::getSquareGradientAlpha(rUV
, maGradientInfo
));
462 rBColor
= basegfx::interpolate(maStart
, maEnd
, fScaler
);
464 } // end of namespace texture
465 } // end of namespace drawinglayer
468 namespace drawinglayer
472 GeoTexSvxGradientRect::GeoTexSvxGradientRect(
473 const basegfx::B2DRange
& rDefinitionRange
,
474 const basegfx::BColor
& rStart
,
475 const basegfx::BColor
& rEnd
,
481 : GeoTexSvxGradient(rDefinitionRange
, rStart
, rEnd
, nSteps
, fBorder
)
483 maGradientInfo
= basegfx::tools::createRectangularODFGradientInfo(
485 basegfx::B2DVector(fOffsetX
,fOffsetY
),
491 GeoTexSvxGradientRect::~GeoTexSvxGradientRect()
495 void GeoTexSvxGradientRect::appendTransformationsAndColors(
496 std::vector
< B2DHomMatrixAndBColor
>& rEntries
,
497 basegfx::BColor
& rOuterColor
)
499 rOuterColor
= maStart
;
501 if(maGradientInfo
.getSteps())
505 double fIncrementX(0.0);
506 double fIncrementY(0.0);
508 if(maGradientInfo
.getAspectRatio() > 1.0)
510 fIncrementY
= fHeight
/ maGradientInfo
.getSteps();
511 fIncrementX
= fIncrementY
/ maGradientInfo
.getAspectRatio();
515 fIncrementX
= fWidth
/ maGradientInfo
.getSteps();
516 fIncrementY
= fIncrementX
* maGradientInfo
.getAspectRatio();
519 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor
;
521 for(sal_uInt32
a(1); a
< maGradientInfo
.getSteps(); a
++)
524 fWidth
-= fIncrementX
;
525 fHeight
-= fIncrementY
;
527 aB2DHomMatrixAndBColor
.maB2DHomMatrix
= maGradientInfo
.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fWidth
, fHeight
);
528 aB2DHomMatrixAndBColor
.maBColor
= interpolate(maStart
, maEnd
, double(a
) / double(maGradientInfo
.getSteps() - 1));
529 rEntries
.push_back(aB2DHomMatrixAndBColor
);
534 void GeoTexSvxGradientRect::modifyBColor(const basegfx::B2DPoint
& rUV
, basegfx::BColor
& rBColor
, double& /*rfOpacity*/) const
536 const double fScaler(basegfx::tools::getRectangularGradientAlpha(rUV
, maGradientInfo
));
538 rBColor
= basegfx::interpolate(maStart
, maEnd
, fScaler
);
540 } // end of namespace texture
541 } // end of namespace drawinglayer
544 namespace drawinglayer
548 GeoTexSvxHatch::GeoTexSvxHatch(
549 const basegfx::B2DRange
& rDefinitionRange
,
550 const basegfx::B2DRange
& rOutputRange
,
553 : maOutputRange(rOutputRange
),
554 maTextureTransform(),
555 maBackTextureTransform(),
559 mbDefinitionRangeEqualsOutputRange(rDefinitionRange
== rOutputRange
)
561 double fTargetSizeX(rDefinitionRange
.getWidth());
562 double fTargetSizeY(rDefinitionRange
.getHeight());
563 double fTargetOffsetX(rDefinitionRange
.getMinX());
564 double fTargetOffsetY(rDefinitionRange
.getMinY());
568 // add object expansion
571 const double fAbsCos(fabs(cos(fAngle
)));
572 const double fAbsSin(fabs(sin(fAngle
)));
573 const double fNewX(fTargetSizeX
* fAbsCos
+ fTargetSizeY
* fAbsSin
);
574 const double fNewY(fTargetSizeY
* fAbsCos
+ fTargetSizeX
* fAbsSin
);
575 fTargetOffsetX
-= (fNewX
- fTargetSizeX
) / 2.0;
576 fTargetOffsetY
-= (fNewY
- fTargetSizeY
) / 2.0;
577 fTargetSizeX
= fNewX
;
578 fTargetSizeY
= fNewY
;
581 // add object scale before rotate
582 maTextureTransform
.scale(fTargetSizeX
, fTargetSizeY
);
584 // add texture rotate after scale to keep perpendicular angles
587 basegfx::B2DPoint
aCenter(0.5, 0.5);
588 aCenter
*= maTextureTransform
;
590 maTextureTransform
= basegfx::tools::createRotateAroundPoint(aCenter
, fAngle
)
591 * maTextureTransform
;
594 // add object translate
595 maTextureTransform
.translate(fTargetOffsetX
, fTargetOffsetY
);
597 // prepare height for texture
598 const double fSteps((0.0 != fDistance
) ? fTargetSizeY
/ fDistance
: 10.0);
599 mnSteps
= basegfx::fround(fSteps
+ 0.5);
600 mfDistance
= 1.0 / fSteps
;
603 GeoTexSvxHatch::~GeoTexSvxHatch()
607 bool GeoTexSvxHatch::operator==(const GeoTexSvx
& rGeoTexSvx
) const
609 const GeoTexSvxHatch
* pCompare
= dynamic_cast< const GeoTexSvxHatch
* >(&rGeoTexSvx
);
611 && maOutputRange
== pCompare
->maOutputRange
612 && maTextureTransform
== pCompare
->maTextureTransform
613 && mfDistance
== pCompare
->mfDistance
614 && mfAngle
== pCompare
->mfAngle
615 && mnSteps
== pCompare
->mnSteps
);
618 void GeoTexSvxHatch::appendTransformations(::std::vector
< basegfx::B2DHomMatrix
>& rMatrices
)
620 if(mbDefinitionRangeEqualsOutputRange
)
622 // simple hatch where the definition area equals the output area
623 for(sal_uInt32
a(1); a
< mnSteps
; a
++)
626 const double fOffset(mfDistance
* (double)a
);
627 basegfx::B2DHomMatrix aNew
;
628 aNew
.set(1, 2, fOffset
);
629 rMatrices
.push_back(maTextureTransform
* aNew
);
634 // output area is different from definition area, back-transform to get
635 // the output area in unit coordinates and fill this with hatch lines
636 // using the settings derived from the definition area
637 basegfx::B2DRange
aBackUnitRange(maOutputRange
);
639 aBackUnitRange
.transform(getBackTextureTransform());
641 // calculate vertical start value and a security maximum integer value to avoid death loops
642 double fStart(basegfx::snapToNearestMultiple(aBackUnitRange
.getMinY(), mfDistance
));
643 const sal_uInt32
nNeededIntegerSteps(basegfx::fround((aBackUnitRange
.getHeight() / mfDistance
) + 0.5));
644 sal_uInt32
nMaxIntegerSteps(::std::min(nNeededIntegerSteps
, sal_uInt32(10000)));
646 while(fStart
< aBackUnitRange
.getMaxY() && nMaxIntegerSteps
)
648 // create new transform for
649 basegfx::B2DHomMatrix aNew
;
651 // adapt x scale and position
652 //aNew.scale(aBackUnitRange.getWidth(), 1.0);
653 //aNew.translate(aBackUnitRange.getMinX(), 0.0);
654 aNew
.set(0, 0, aBackUnitRange
.getWidth());
655 aNew
.set(0, 2, aBackUnitRange
.getMinX());
657 // adapt y position to current step
658 aNew
.set(1, 2, fStart
);
659 //aNew.translate(0.0, fStart);
661 // add new transformation
662 rMatrices
.push_back(maTextureTransform
* aNew
);
665 fStart
+= mfDistance
;
671 double GeoTexSvxHatch::getDistanceToHatch(const basegfx::B2DPoint
& rUV
) const
673 const basegfx::B2DPoint
aCoor(getBackTextureTransform() * rUV
);
674 return fmod(aCoor
.getY(), mfDistance
);
677 const basegfx::B2DHomMatrix
& GeoTexSvxHatch::getBackTextureTransform() const
679 if(maBackTextureTransform
.isIdentity())
681 const_cast< GeoTexSvxHatch
* >(this)->maBackTextureTransform
= maTextureTransform
;
682 const_cast< GeoTexSvxHatch
* >(this)->maBackTextureTransform
.invert();
685 return maBackTextureTransform
;
687 } // end of namespace texture
688 } // end of namespace drawinglayer
691 namespace drawinglayer
695 GeoTexSvxTiled::GeoTexSvxTiled(
696 const basegfx::B2DRange
& rRange
,
700 mfOffsetX(basegfx::clamp(fOffsetX
, 0.0, 1.0)),
701 mfOffsetY(basegfx::clamp(fOffsetY
, 0.0, 1.0))
703 if(!basegfx::fTools::equalZero(mfOffsetX
))
709 GeoTexSvxTiled::~GeoTexSvxTiled()
713 bool GeoTexSvxTiled::operator==(const GeoTexSvx
& rGeoTexSvx
) const
715 const GeoTexSvxTiled
* pCompare
= dynamic_cast< const GeoTexSvxTiled
* >(&rGeoTexSvx
);
718 && maRange
== pCompare
->maRange
719 && mfOffsetX
== pCompare
->mfOffsetX
720 && mfOffsetY
== pCompare
->mfOffsetY
);
723 void GeoTexSvxTiled::appendTransformations(::std::vector
< basegfx::B2DHomMatrix
>& rMatrices
)
725 const double fWidth(maRange
.getWidth());
727 if(!basegfx::fTools::equalZero(fWidth
))
729 const double fHeight(maRange
.getHeight());
731 if(!basegfx::fTools::equalZero(fHeight
))
733 double fStartX(maRange
.getMinX());
734 double fStartY(maRange
.getMinY());
738 if(basegfx::fTools::more(fStartX
, 0.0))
740 const sal_Int32
nDiff(static_cast<sal_Int32
>(floor(fStartX
/ fWidth
)) + 1);
743 fStartX
-= nDiff
* fWidth
;
746 if(basegfx::fTools::less(fStartX
+ fWidth
, 0.0))
748 const sal_Int32
nDiff(static_cast<sal_Int32
>(floor(-fStartX
/ fWidth
)));
751 fStartX
+= nDiff
* fWidth
;
754 if(basegfx::fTools::more(fStartY
, 0.0))
756 const sal_Int32
nDiff(static_cast<sal_Int32
>(floor(fStartY
/ fHeight
)) + 1);
759 fStartY
-= nDiff
* fHeight
;
762 if(basegfx::fTools::less(fStartY
+ fHeight
, 0.0))
764 const sal_Int32
nDiff(static_cast<sal_Int32
>(floor(-fStartY
/ fHeight
)));
767 fStartY
+= nDiff
* fHeight
;
770 if(!basegfx::fTools::equalZero(mfOffsetY
))
772 for(double fPosX(fStartX
); basegfx::fTools::less(fPosX
, 1.0); fPosX
+= fWidth
, nPosX
++)
774 for(double fPosY((nPosX
% 2) ? fStartY
- fHeight
+ (mfOffsetY
* fHeight
) : fStartY
);
775 basegfx::fTools::less(fPosY
, 1.0); fPosY
+= fHeight
)
778 basegfx::tools::createScaleTranslateB2DHomMatrix(
788 for(double fPosY(fStartY
); basegfx::fTools::less(fPosY
, 1.0); fPosY
+= fHeight
, nPosY
++)
790 for(double fPosX((nPosY
% 2) ? fStartX
- fWidth
+ (mfOffsetX
* fWidth
) : fStartX
);
791 basegfx::fTools::less(fPosX
, 1.0); fPosX
+= fWidth
)
794 basegfx::tools::createScaleTranslateB2DHomMatrix(
805 } // end of namespace texture
806 } // end of namespace drawinglayer
808 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */