update dev300-m58
[ooovba.git] / drawinglayer / source / texture / texture.cxx
blob964099b69141453bb677ba904e6e677806bad9b0
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: texture.cxx,v $
7 * $Revision: 1.6 $
9 * last change: $Author: aw $ $Date: 2008-05-27 14:11:34 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/texture/texture.hxx>
40 #include <basegfx/numeric/ftools.hxx>
41 #include <basegfx/tools/gradienttools.hxx>
43 //////////////////////////////////////////////////////////////////////////////
45 namespace drawinglayer
47 namespace texture
49 GeoTexSvx::GeoTexSvx()
53 GeoTexSvx::~GeoTexSvx()
57 bool GeoTexSvx::operator==(const GeoTexSvx& /*rGeoTexSvx*/) const
59 // default implementation says yes (no data -> no difference)
60 return true;
63 void GeoTexSvx::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& /*rMatrices*/)
65 // default implementation does nothing
68 void GeoTexSvx::modifyBColor(const basegfx::B2DPoint& /*rUV*/, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
70 // base implementation creates random color (for testing only, may also be pure virtual)
71 rBColor.setRed((rand() & 0x7fff) / 32767.0);
72 rBColor.setGreen((rand() & 0x7fff) / 32767.0);
73 rBColor.setBlue((rand() & 0x7fff) / 32767.0);
76 void GeoTexSvx::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
78 // base implementation uses inverse of luminance of solved color (for testing only, may also be pure virtual)
79 basegfx::BColor aBaseColor;
80 modifyBColor(rUV, aBaseColor, rfOpacity);
81 rfOpacity = 1.0 - aBaseColor.luminance();
83 } // end of namespace texture
84 } // end of namespace drawinglayer
86 //////////////////////////////////////////////////////////////////////////////
88 namespace drawinglayer
90 namespace texture
92 void GeoTexSvxGradient::impAppendMatrix(::std::vector< basegfx::B2DHomMatrix >& rMatrices, const basegfx::B2DRange& rRange)
94 basegfx::B2DHomMatrix aNew;
95 aNew.set(0, 0, rRange.getWidth());
96 aNew.set(1, 1, rRange.getHeight());
97 aNew.set(0, 2, rRange.getMinX());
98 aNew.set(1, 2, rRange.getMinY());
99 rMatrices.push_back(maGradientInfo.maTextureTransform * aNew);
102 void GeoTexSvxGradient::impAppendColorsRadial(::std::vector< basegfx::BColor >& rColors)
104 if(maGradientInfo.mnSteps)
106 rColors.push_back(maStart);
108 for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps - 1L; a++)
110 rColors.push_back(interpolate(maStart, maEnd, (double)a / (double)maGradientInfo.mnSteps));
113 rColors.push_back(maEnd);
117 GeoTexSvxGradient::GeoTexSvxGradient(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder)
118 : maTargetRange(rTargetRange),
119 maStart(rStart),
120 maEnd(rEnd),
121 mfBorder(fBorder)
123 maGradientInfo.mnSteps = nSteps;
124 maGradientInfo.mfAspectRatio = 1.0;
127 GeoTexSvxGradient::~GeoTexSvxGradient()
131 bool GeoTexSvxGradient::operator==(const GeoTexSvx& rGeoTexSvx) const
133 const GeoTexSvxGradient* pCompare = dynamic_cast< const GeoTexSvxGradient* >(&rGeoTexSvx);
134 return (pCompare
135 && maGradientInfo.maTextureTransform == pCompare->maGradientInfo.maTextureTransform
136 && maTargetRange == pCompare->maTargetRange
137 && maGradientInfo.mnSteps == pCompare->maGradientInfo.mnSteps
138 && maGradientInfo.mfAspectRatio == pCompare->maGradientInfo.mfAspectRatio
139 && mfBorder == pCompare->mfBorder);
141 } // end of namespace texture
142 } // end of namespace drawinglayer
144 //////////////////////////////////////////////////////////////////////////////
146 namespace drawinglayer
148 namespace texture
150 GeoTexSvxGradientLinear::GeoTexSvxGradientLinear(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fAngle)
151 : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
153 basegfx::tools::createLinearODFGradientInfo(maGradientInfo,
154 rTargetRange,
155 nSteps,
156 fBorder,
157 fAngle);
160 GeoTexSvxGradientLinear::~GeoTexSvxGradientLinear()
164 void GeoTexSvxGradientLinear::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
166 if(maGradientInfo.mnSteps)
168 const double fTop(mfBorder);
169 const double fStripeWidth((1.0 - fTop) / maGradientInfo.mnSteps);
171 for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
173 const double fOffsetUpper(fStripeWidth * (double)a);
175 // create matrix
176 const basegfx::B2DRange aRect(0.0, fTop + fOffsetUpper, 1.0, 1.0);
177 impAppendMatrix(rMatrices, aRect);
182 void GeoTexSvxGradientLinear::appendColors(::std::vector< basegfx::BColor >& rColors)
184 if(maGradientInfo.mnSteps)
186 rColors.push_back(maStart);
188 for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
190 rColors.push_back(interpolate(maStart, maEnd, (double)a / (double)(maGradientInfo.mnSteps + 1L)));
195 void GeoTexSvxGradientLinear::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
197 const double fScaler(basegfx::tools::getLinearGradientAlpha(rUV, maGradientInfo));
199 rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
201 } // end of namespace texture
202 } // end of namespace drawinglayer
204 //////////////////////////////////////////////////////////////////////////////
206 namespace drawinglayer
208 namespace texture
210 GeoTexSvxGradientAxial::GeoTexSvxGradientAxial(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fAngle)
211 : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
213 basegfx::tools::createAxialODFGradientInfo(maGradientInfo,
214 rTargetRange,
215 nSteps,
216 fBorder,
217 fAngle);
220 GeoTexSvxGradientAxial::~GeoTexSvxGradientAxial()
224 void GeoTexSvxGradientAxial::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
226 if(maGradientInfo.mnSteps)
228 const double fHalfBorder(mfBorder * 0.5);
229 double fTop(fHalfBorder);
230 double fBottom(1.0 - fHalfBorder);
231 const double fStripeWidth((fBottom - fTop) / ((maGradientInfo.mnSteps * 2L) - 1L));
233 for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
235 const double fOffset(fStripeWidth * (double)a);
237 // create matrix
238 const basegfx::B2DRange aRect(0.0, fTop + fOffset, 1.0, fBottom - fOffset);
239 impAppendMatrix(rMatrices, aRect);
244 void GeoTexSvxGradientAxial::appendColors(::std::vector< basegfx::BColor >& rColors)
246 if(maGradientInfo.mnSteps)
248 rColors.push_back(maEnd);
250 for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
252 rColors.push_back(interpolate(maEnd, maStart, (double)a / (double)maGradientInfo.mnSteps));
257 void GeoTexSvxGradientAxial::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
259 const double fScaler(basegfx::tools::getAxialGradientAlpha(rUV, maGradientInfo));
261 rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
263 } // end of namespace texture
264 } // end of namespace drawinglayer
266 //////////////////////////////////////////////////////////////////////////////
268 namespace drawinglayer
270 namespace texture
272 GeoTexSvxGradientRadial::GeoTexSvxGradientRadial(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY)
273 : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
275 basegfx::tools::createRadialODFGradientInfo(maGradientInfo,
276 rTargetRange,
277 basegfx::B2DVector(fOffsetX,fOffsetY),
278 nSteps,
279 fBorder);
282 GeoTexSvxGradientRadial::~GeoTexSvxGradientRadial()
286 void GeoTexSvxGradientRadial::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
288 if(maGradientInfo.mnSteps)
290 const double fHalfBorder((1.0 - mfBorder) * 0.5);
291 double fLeft(0.5 - fHalfBorder);
292 double fTop(0.5 - fHalfBorder);
293 double fRight(0.5 + fHalfBorder);
294 double fBottom(0.5 + fHalfBorder);
295 double fIncrementX, fIncrementY;
297 if(maGradientInfo.mfAspectRatio > 1.0)
299 fIncrementY = (fBottom - fTop) / (double)(maGradientInfo.mnSteps * 2L);
300 fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio;
302 else
304 fIncrementX = (fRight - fLeft) / (double)(maGradientInfo.mnSteps * 2L);
305 fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio;
308 for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
310 // next step
311 fLeft += fIncrementX;
312 fRight -= fIncrementX;
313 fTop += fIncrementY;
314 fBottom -= fIncrementY;
316 // create matrix
317 const basegfx::B2DRange aRect(fLeft, fTop, fRight, fBottom);
318 impAppendMatrix(rMatrices, aRect);
323 void GeoTexSvxGradientRadial::appendColors(::std::vector< basegfx::BColor >& rColors)
325 impAppendColorsRadial(rColors);
328 void GeoTexSvxGradientRadial::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
330 const double fScaler(basegfx::tools::getRadialGradientAlpha(rUV, maGradientInfo));
332 rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
334 } // end of namespace texture
335 } // end of namespace drawinglayer
337 //////////////////////////////////////////////////////////////////////////////
339 namespace drawinglayer
341 namespace texture
343 GeoTexSvxGradientElliptical::GeoTexSvxGradientElliptical(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle)
344 : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
346 basegfx::tools::createEllipticalODFGradientInfo(maGradientInfo,
347 rTargetRange,
348 basegfx::B2DVector(fOffsetX,fOffsetY),
349 nSteps,
350 fBorder,
351 fAngle);
354 GeoTexSvxGradientElliptical::~GeoTexSvxGradientElliptical()
358 void GeoTexSvxGradientElliptical::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
360 if(maGradientInfo.mnSteps)
362 const double fHalfBorder((1.0 - mfBorder) * 0.5);
363 double fLeft(0.5 - fHalfBorder);
364 double fTop(0.5 - fHalfBorder);
365 double fRight(0.5 + fHalfBorder);
366 double fBottom(0.5 + fHalfBorder);
367 double fIncrementX, fIncrementY;
369 if(maGradientInfo.mfAspectRatio > 1.0)
371 fIncrementY = (fBottom - fTop) / (double)(maGradientInfo.mnSteps * 2L);
372 fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio;
374 else
376 fIncrementX = (fRight - fLeft) / (double)(maGradientInfo.mnSteps * 2L);
377 fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio;
380 for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
382 // next step
383 fLeft += fIncrementX;
384 fRight -= fIncrementX;
385 fTop += fIncrementY;
386 fBottom -= fIncrementY;
388 // create matrix
389 const basegfx::B2DRange aRect(fLeft, fTop, fRight, fBottom);
390 impAppendMatrix(rMatrices, aRect);
395 void GeoTexSvxGradientElliptical::appendColors(::std::vector< basegfx::BColor >& rColors)
397 impAppendColorsRadial(rColors);
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 = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
406 } // end of namespace texture
407 } // end of namespace drawinglayer
409 //////////////////////////////////////////////////////////////////////////////
411 namespace drawinglayer
413 namespace texture
415 GeoTexSvxGradientSquare::GeoTexSvxGradientSquare(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle)
416 : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
418 basegfx::tools::createSquareODFGradientInfo(maGradientInfo,
419 rTargetRange,
420 basegfx::B2DVector(fOffsetX,fOffsetY),
421 nSteps,
422 fBorder,
423 fAngle);
426 GeoTexSvxGradientSquare::~GeoTexSvxGradientSquare()
430 void GeoTexSvxGradientSquare::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
432 if(maGradientInfo.mnSteps)
434 const double fHalfBorder((1.0 - mfBorder) * 0.5);
435 double fLeft(0.5 - fHalfBorder);
436 double fTop(0.5 - fHalfBorder);
437 double fRight(0.5 + fHalfBorder);
438 double fBottom(0.5 + fHalfBorder);
439 double fIncrementX, fIncrementY;
441 if(maGradientInfo.mfAspectRatio > 1.0)
443 const double fWidth(fRight - fLeft);
444 const double fHalfAspectExpansion(((maGradientInfo.mfAspectRatio - 1.0) * 0.5) * fWidth);
445 fTop -= fHalfAspectExpansion;
446 fBottom += fHalfAspectExpansion;
447 fIncrementX = fWidth / (double)(maGradientInfo.mnSteps * 2L);
448 fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio;
450 else
452 const double fHeight(fBottom - fTop);
453 const double fHalfAspectExpansion((((1.0 / maGradientInfo.mfAspectRatio) - 1.0) * 0.5) * fHeight);
454 fLeft -= fHalfAspectExpansion;
455 fRight += fHalfAspectExpansion;
456 fIncrementY = fHeight / (double)(maGradientInfo.mnSteps * 2L);
457 fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio;
460 for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
462 // next step
463 fLeft += fIncrementX;
464 fRight -= fIncrementX;
465 fTop += fIncrementY;
466 fBottom -= fIncrementY;
468 // create matrix
469 const basegfx::B2DRange aRect(fLeft, fTop, fRight, fBottom);
470 impAppendMatrix(rMatrices, aRect);
475 void GeoTexSvxGradientSquare::appendColors(::std::vector< basegfx::BColor >& rColors)
477 impAppendColorsRadial(rColors);
480 void GeoTexSvxGradientSquare::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
482 const double fScaler(basegfx::tools::getSquareGradientAlpha(rUV, maGradientInfo));
484 rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
486 } // end of namespace texture
487 } // end of namespace drawinglayer
489 //////////////////////////////////////////////////////////////////////////////
491 namespace drawinglayer
493 namespace texture
495 GeoTexSvxGradientRect::GeoTexSvxGradientRect(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle)
496 : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
498 basegfx::tools::createRectangularODFGradientInfo(maGradientInfo,
499 rTargetRange,
500 basegfx::B2DVector(fOffsetX,fOffsetY),
501 nSteps,
502 fBorder,
503 fAngle);
506 GeoTexSvxGradientRect::~GeoTexSvxGradientRect()
510 void GeoTexSvxGradientRect::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
512 if(maGradientInfo.mnSteps)
514 const double fHalfBorder((1.0 - mfBorder) * 0.5);
515 double fLeft(0.5 - fHalfBorder);
516 double fTop(0.5 - fHalfBorder);
517 double fRight(0.5 + fHalfBorder);
518 double fBottom(0.5 + fHalfBorder);
519 double fIncrementX, fIncrementY;
521 if(maGradientInfo.mfAspectRatio > 1.0)
523 fIncrementY = (fBottom - fTop) / (double)(maGradientInfo.mnSteps * 2L);
524 fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio;
526 else
528 fIncrementX = (fRight - fLeft) / (double)(maGradientInfo.mnSteps * 2L);
529 fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio;
532 for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
534 // next step
535 fLeft += fIncrementX;
536 fRight -= fIncrementX;
537 fTop += fIncrementY;
538 fBottom -= fIncrementY;
540 // create matrix
541 const basegfx::B2DRange aRect(fLeft, fTop, fRight, fBottom);
542 impAppendMatrix(rMatrices, aRect);
547 void GeoTexSvxGradientRect::appendColors(::std::vector< basegfx::BColor >& rColors)
549 impAppendColorsRadial(rColors);
552 void GeoTexSvxGradientRect::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
554 const double fScaler(basegfx::tools::getRectangularGradientAlpha(rUV, maGradientInfo));
556 rBColor = (maStart * (1.0 - fScaler)) + (maEnd * fScaler);
558 } // end of namespace texture
559 } // end of namespace drawinglayer
561 //////////////////////////////////////////////////////////////////////////////
563 namespace drawinglayer
565 namespace texture
567 GeoTexSvxHatch::GeoTexSvxHatch(const basegfx::B2DRange& rTargetRange, double fDistance, double fAngle)
568 : mfDistance(0.1),
569 mfAngle(fAngle),
570 mnSteps(10L)
572 double fTargetSizeX(rTargetRange.getWidth());
573 double fTargetSizeY(rTargetRange.getHeight());
574 double fTargetOffsetX(rTargetRange.getMinX());
575 double fTargetOffsetY(rTargetRange.getMinY());
577 // add object expansion
578 if(0.0 != fAngle)
580 const double fAbsCos(fabs(cos(fAngle)));
581 const double fAbsSin(fabs(sin(fAngle)));
582 const double fNewX(fTargetSizeX * fAbsCos + fTargetSizeY * fAbsSin);
583 const double fNewY(fTargetSizeY * fAbsCos + fTargetSizeX * fAbsSin);
584 fTargetOffsetX -= (fNewX - fTargetSizeX) / 2.0;
585 fTargetOffsetY -= (fNewY - fTargetSizeY) / 2.0;
586 fTargetSizeX = fNewX;
587 fTargetSizeY = fNewY;
590 // add object scale before rotate
591 maTextureTransform.scale(fTargetSizeX, fTargetSizeY);
593 // add texture rotate after scale to keep perpendicular angles
594 if(0.0 != fAngle)
596 basegfx::B2DPoint aCenter(0.5, 0.5);
597 aCenter *= maTextureTransform;
599 maTextureTransform.translate(-aCenter.getX(), -aCenter.getY());
600 maTextureTransform.rotate(fAngle);
601 maTextureTransform.translate(aCenter.getX(), aCenter.getY());
604 // add object translate
605 maTextureTransform.translate(fTargetOffsetX, fTargetOffsetY);
607 // prepare height for texture
608 const double fSteps((0.0 != fDistance) ? fTargetSizeY / fDistance : 10.0);
609 mnSteps = basegfx::fround(fSteps + 0.5);
610 mfDistance = 1.0 / fSteps;
612 // build transform from u,v to [0.0 .. 1.0]. As base, use inverse texture transform
613 maBackTextureTransform = maTextureTransform;
614 maBackTextureTransform.invert();
617 GeoTexSvxHatch::~GeoTexSvxHatch()
621 bool GeoTexSvxHatch::operator==(const GeoTexSvx& rGeoTexSvx) const
623 const GeoTexSvxHatch* pCompare = dynamic_cast< const GeoTexSvxHatch* >(&rGeoTexSvx);
624 return (pCompare
625 && maTextureTransform == pCompare->maTextureTransform
626 && mfDistance == pCompare->mfDistance
627 && mfAngle == pCompare->mfAngle
628 && mnSteps == pCompare->mnSteps);
631 void GeoTexSvxHatch::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
633 for(sal_uInt32 a(1L); a < mnSteps; a++)
635 // create matrix
636 const double fOffset(mfDistance * (double)a);
637 basegfx::B2DHomMatrix aNew;
638 aNew.set(1, 2, fOffset);
639 rMatrices.push_back(maTextureTransform * aNew);
643 double GeoTexSvxHatch::getDistanceToHatch(const basegfx::B2DPoint& rUV) const
645 const basegfx::B2DPoint aCoor(maBackTextureTransform * rUV);
646 return fmod(aCoor.getY(), mfDistance);
648 } // end of namespace texture
649 } // end of namespace drawinglayer
651 //////////////////////////////////////////////////////////////////////////////
653 namespace drawinglayer
655 namespace texture
657 GeoTexSvxTiled::GeoTexSvxTiled(const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize)
658 : maTopLeft(rTopLeft),
659 maSize(rSize)
661 if(basegfx::fTools::lessOrEqual(maSize.getX(), 0.0))
663 maSize.setX(1.0);
666 if(basegfx::fTools::lessOrEqual(maSize.getY(), 0.0))
668 maSize.setY(1.0);
672 GeoTexSvxTiled::~GeoTexSvxTiled()
676 bool GeoTexSvxTiled::operator==(const GeoTexSvx& rGeoTexSvx) const
678 const GeoTexSvxTiled* pCompare = dynamic_cast< const GeoTexSvxTiled* >(&rGeoTexSvx);
679 return (pCompare
680 && maTopLeft == pCompare->maTopLeft
681 && maSize == pCompare->maSize);
684 void GeoTexSvxTiled::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
686 double fStartX(maTopLeft.getX());
687 double fStartY(maTopLeft.getY());
689 if(basegfx::fTools::more(fStartX, 0.0))
691 fStartX -= (floor(fStartX / maSize.getX()) + 1.0) * maSize.getX();
694 if(basegfx::fTools::less(fStartX + maSize.getX(), 0.0))
696 fStartX += floor(-fStartX / maSize.getX()) * maSize.getX();
699 if(basegfx::fTools::more(fStartY, 0.0))
701 fStartY -= (floor(fStartY / maSize.getY()) + 1.0) * maSize.getY();
704 if(basegfx::fTools::less(fStartY + maSize.getY(), 0.0))
706 fStartY += floor(-fStartY / maSize.getY()) * maSize.getY();
709 for(double fPosY(fStartY); basegfx::fTools::less(fPosY, 1.0); fPosY += maSize.getY())
711 for(double fPosX(fStartX); basegfx::fTools::less(fPosX, 1.0); fPosX += maSize.getX())
713 basegfx::B2DHomMatrix aNew;
715 aNew.set(0, 0, maSize.getX());
716 aNew.set(1, 1, maSize.getY());
717 aNew.set(0, 2, fPosX);
718 aNew.set(1, 2, fPosY);
720 rMatrices.push_back(aNew);
724 } // end of namespace texture
725 } // end of namespace drawinglayer
727 //////////////////////////////////////////////////////////////////////////////
728 // eof