The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-7 by Raw Material Software ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the
  7. GNU General Public License, as published by the Free Software Foundation;
  8. either version 2 of the License, or (at your option) any later version.
  9. JUCE is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with JUCE; if not, visit www.gnu.org/licenses or write to the
  15. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  16. Boston, MA 02111-1307 USA
  17. ------------------------------------------------------------------------------
  18. If you'd like to release a closed-source product which uses JUCE, commercial
  19. licenses are also available: visit www.rawmaterialsoftware.com/juce for
  20. more information.
  21. ==============================================================================
  22. */
  23. #include "../../../../juce_core/basics/juce_StandardHeader.h"
  24. BEGIN_JUCE_NAMESPACE
  25. #include "juce_GradientBrush.h"
  26. #include "../contexts/juce_LowLevelGraphicsContext.h"
  27. //==============================================================================
  28. GradientBrush::GradientBrush (const Colour& colour1,
  29. const float x1,
  30. const float y1,
  31. const Colour& colour2,
  32. const float x2,
  33. const float y2,
  34. const bool isRadial) throw()
  35. : gradient (colour1, x1, y1,
  36. colour2, x2, y2,
  37. isRadial)
  38. {
  39. }
  40. GradientBrush::GradientBrush (const ColourGradient& gradient_) throw()
  41. : gradient (gradient_)
  42. {
  43. }
  44. GradientBrush::~GradientBrush() throw()
  45. {
  46. }
  47. Brush* GradientBrush::createCopy() const throw()
  48. {
  49. return new GradientBrush (gradient);
  50. }
  51. void GradientBrush::applyTransform (const AffineTransform& transform) throw()
  52. {
  53. gradient.transform = gradient.transform.followedBy (transform);
  54. }
  55. void GradientBrush::multiplyOpacity (const float multiple) throw()
  56. {
  57. gradient.multiplyOpacity (multiple);
  58. }
  59. bool GradientBrush::isInvisible() const throw()
  60. {
  61. return gradient.isInvisible();
  62. }
  63. //==============================================================================
  64. void GradientBrush::paintPath (LowLevelGraphicsContext& context,
  65. const Path& path, const AffineTransform& transform) throw()
  66. {
  67. context.fillPathWithGradient (path, transform, gradient, EdgeTable::Oversampling_4times);
  68. }
  69. void GradientBrush::paintRectangle (LowLevelGraphicsContext& context,
  70. int x, int y, int w, int h) throw()
  71. {
  72. context.fillRectWithGradient (x, y, w, h, gradient);
  73. }
  74. void GradientBrush::paintAlphaChannel (LowLevelGraphicsContext& context,
  75. const Image& alphaChannelImage, int imageX, int imageY,
  76. int x, int y, int w, int h) throw()
  77. {
  78. context.saveState();
  79. if (context.reduceClipRegion (x, y, w, h))
  80. context.fillAlphaChannelWithGradient (alphaChannelImage, imageX, imageY, gradient);
  81. context.restoreState();
  82. }
  83. END_JUCE_NAMESPACE