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.

113 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE examples.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. The code included in this file is provided under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  7. To use, copy, modify, and/or distribute this software for any purpose with or
  8. without fee is hereby granted provided that the above copyright notice and
  9. this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
  11. WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
  12. PURPOSE, ARE DISCLAIMED.
  13. ==============================================================================
  14. */
  15. /*******************************************************************************
  16. The block below describes the properties of this PIP. A PIP is a short snippet
  17. of code that can be read by the Projucer and used to generate a JUCE project.
  18. BEGIN_JUCE_PIP_METADATA
  19. name: AnimationAppDemo
  20. version: 1.0.0
  21. vendor: JUCE
  22. website: http://juce.com
  23. description: Simple animation application.
  24. dependencies: juce_core, juce_data_structures, juce_events, juce_graphics,
  25. juce_gui_basics, juce_gui_extra
  26. exporters: xcode_mac, vs2022, xcode_iphone
  27. moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
  28. type: Component
  29. mainClass: AnimationAppDemo
  30. useLocalCopy: 1
  31. END_JUCE_PIP_METADATA
  32. *******************************************************************************/
  33. #pragma once
  34. //==============================================================================
  35. /*
  36. This component lives inside our window, and this is where you should put all
  37. your controls and content.
  38. */
  39. class AnimationAppDemo final : public AnimatedAppComponent
  40. {
  41. public:
  42. //==============================================================================
  43. AnimationAppDemo()
  44. {
  45. setSize (800, 600);
  46. setSynchroniseToVBlank (true);
  47. }
  48. void update() override
  49. {
  50. // This function is called at the frequency specified by the setFramesPerSecond() call
  51. // in the constructor. You can use it to update counters, animate values, etc.
  52. }
  53. void paint (Graphics& g) override
  54. {
  55. // (Our component is opaque, so we must completely fill the background with a solid colour)
  56. g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
  57. g.setColour (getLookAndFeel().findColour (Slider::thumbColourId));
  58. auto fishLength = 15;
  59. Path spinePath;
  60. for (auto i = 0; i < fishLength; ++i)
  61. {
  62. auto radius = 100 + 10 * std::sin ((float) getFrameCounter() * 0.1f + (float) i * 0.5f);
  63. Point<float> p ((float) getWidth() / 2.0f + 1.5f * radius * std::sin ((float) getFrameCounter() * 0.02f + (float) i * 0.12f),
  64. (float) getHeight() / 2.0f + 1.0f * radius * std::cos ((float) getFrameCounter() * 0.04f + (float) i * 0.12f));
  65. // draw the circles along the fish
  66. g.fillEllipse (p.x - (float) i, p.y - (float) i, 2.0f + 2.0f * (float) i, 2.0f + 2.0f * (float) i);
  67. if (i == 0)
  68. spinePath.startNewSubPath (p); // if this is the first point, start a new path..
  69. else
  70. spinePath.lineTo (p); // ...otherwise add the next point
  71. }
  72. // draw an outline around the path that we have created
  73. g.strokePath (spinePath, PathStrokeType (4.0f));
  74. }
  75. void resized() override
  76. {
  77. // This is called when this component is resized.
  78. // If you add any child components, this is where you should
  79. // update their positions.
  80. }
  81. private:
  82. //==============================================================================
  83. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AnimationAppDemo)
  84. };