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.

88 lines
2.8KB

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