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.

82 lines
2.7KB

  1. /*
  2. ==============================================================================
  3. This file was auto-generated!
  4. ==============================================================================
  5. */
  6. #include "../JuceLibraryCode/JuceHeader.h"
  7. //==============================================================================
  8. /*
  9. This component lives inside our window, and this is where you should put all
  10. your controls and content.
  11. */
  12. class MainContentComponent : public AnimatedAppComponent
  13. {
  14. public:
  15. //==============================================================================
  16. MainContentComponent()
  17. {
  18. setSize (800, 600);
  19. setFramesPerSecond (60);
  20. }
  21. void update() override
  22. {
  23. // This function is called at the frequency specified by the setFramesPerSecond() call
  24. // in the constructor. You can use it to update counters, animate values, etc.
  25. }
  26. void paint (Graphics& g) override
  27. {
  28. // (Our component is opaque, so we must completely fill the background with a solid colour)
  29. g.fillAll (Colours::black);
  30. g.setColour (Colours::white);
  31. const int fishLength = 15;
  32. Path spinePath;
  33. for (int i = 0; i < fishLength; ++i)
  34. {
  35. const float radius = 100 + 10 * std::sin (getFrameCounter() * 0.1f + i * 0.5f);
  36. Point<float> p (getWidth() / 2.0f + 1.5f * radius * std::sin (getFrameCounter() * 0.02f + i * 0.12f),
  37. getHeight() / 2.0f + 1.0f * radius * std::cos (getFrameCounter() * 0.04f + i * 0.12f));
  38. // draw the circles along the fish
  39. g.fillEllipse (p.x - i, p.y - i, 2.0f + 2.0f * i, 2.0f + 2.0f * i);
  40. if (i == 0)
  41. spinePath.startNewSubPath (p); // if this is the first point, start a new path..
  42. else
  43. spinePath.lineTo (p); // ...otherwise add the next point
  44. }
  45. // draw an outline around the path that we have created
  46. g.strokePath (spinePath, PathStrokeType (4.0f));
  47. }
  48. void resized() override
  49. {
  50. // This is called when the MainContentComponent is resized.
  51. // If you add any child components, this is where you should
  52. // update their positions.
  53. }
  54. private:
  55. //==============================================================================
  56. // Your private member variables go here...
  57. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
  58. };
  59. // (This function is called by the app startup code to create our main component)
  60. Component* createMainContentComponent() { return new MainContentComponent(); }