Audio plugin host https://kx.studio/carla
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.

juce_GlowEffect.cpp 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. GlowEffect::GlowEffect() {}
  16. GlowEffect::~GlowEffect() {}
  17. void GlowEffect::setGlowProperties (float newRadius, Colour newColour, Point<int> pos)
  18. {
  19. radius = newRadius;
  20. colour = newColour;
  21. offset = pos;
  22. }
  23. void GlowEffect::applyEffect (Image& image, Graphics& g, float scaleFactor, float alpha)
  24. {
  25. Image temp (image.getFormat(), image.getWidth(), image.getHeight(), true);
  26. ImageConvolutionKernel blurKernel (roundToInt (radius * scaleFactor * 2.0f));
  27. blurKernel.createGaussianBlur (radius);
  28. blurKernel.rescaleAllValues (radius);
  29. blurKernel.applyToImage (temp, image, image.getBounds());
  30. g.setColour (colour.withMultipliedAlpha (alpha));
  31. g.drawImageAt (temp, offset.x, offset.y, true);
  32. g.setOpacity (alpha);
  33. g.drawImageAt (image, offset.x, offset.y, false);
  34. }
  35. } // namespace juce