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.

100 lines
3.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #include "../JuceLibraryCode/JuceHeader.h"
  20. //==============================================================================
  21. /*
  22. This component lives inside our window, and this is where you should put all
  23. your controls and content.
  24. */
  25. class MainContentComponent : public AnimatedAppComponent
  26. {
  27. public:
  28. //==============================================================================
  29. MainContentComponent()
  30. {
  31. setSize (800, 600);
  32. setFramesPerSecond (60);
  33. }
  34. void update() override
  35. {
  36. // This function is called at the frequency specified by the setFramesPerSecond() call
  37. // in the constructor. You can use it to update counters, animate values, etc.
  38. }
  39. void paint (Graphics& g) override
  40. {
  41. // (Our component is opaque, so we must completely fill the background with a solid colour)
  42. g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
  43. g.setColour (getLookAndFeel().findColour (Slider::thumbColourId));
  44. const int fishLength = 15;
  45. Path spinePath;
  46. for (int i = 0; i < fishLength; ++i)
  47. {
  48. const float radius = 100 + 10 * std::sin (getFrameCounter() * 0.1f + i * 0.5f);
  49. Point<float> p (getWidth() / 2.0f + 1.5f * radius * std::sin (getFrameCounter() * 0.02f + i * 0.12f),
  50. getHeight() / 2.0f + 1.0f * radius * std::cos (getFrameCounter() * 0.04f + i * 0.12f));
  51. // draw the circles along the fish
  52. g.fillEllipse (p.x - i, p.y - i, 2.0f + 2.0f * i, 2.0f + 2.0f * i);
  53. if (i == 0)
  54. spinePath.startNewSubPath (p); // if this is the first point, start a new path..
  55. else
  56. spinePath.lineTo (p); // ...otherwise add the next point
  57. }
  58. // draw an outline around the path that we have created
  59. g.strokePath (spinePath, PathStrokeType (4.0f));
  60. }
  61. void resized() override
  62. {
  63. // This is called when the MainContentComponent is resized.
  64. // If you add any child components, this is where you should
  65. // update their positions.
  66. }
  67. private:
  68. //==============================================================================
  69. // Your private member variables go here...
  70. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
  71. };
  72. // (This function is called by the app startup code to create our main component)
  73. Component* createMainContentComponent() { return new MainContentComponent(); }