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.

111 lines
3.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE examples.
  4. Copyright (c) 2017 - ROLI Ltd.
  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, vs2017, xcode_iphone
  27. type: Component
  28. mainClass: AnimationAppDemo
  29. useLocalCopy: 1
  30. END_JUCE_PIP_METADATA
  31. *******************************************************************************/
  32. #pragma once
  33. //==============================================================================
  34. /*
  35. This component lives inside our window, and this is where you should put all
  36. your controls and content.
  37. */
  38. class AnimationAppDemo : public AnimatedAppComponent
  39. {
  40. public:
  41. //==============================================================================
  42. AnimationAppDemo()
  43. {
  44. setSize (800, 600);
  45. setFramesPerSecond (60);
  46. }
  47. void update() override
  48. {
  49. // This function is called at the frequency specified by the setFramesPerSecond() call
  50. // in the constructor. You can use it to update counters, animate values, etc.
  51. }
  52. void paint (Graphics& g) override
  53. {
  54. // (Our component is opaque, so we must completely fill the background with a solid colour)
  55. g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
  56. g.setColour (getLookAndFeel().findColour (Slider::thumbColourId));
  57. auto fishLength = 15;
  58. Path spinePath;
  59. for (auto i = 0; i < fishLength; ++i)
  60. {
  61. auto radius = 100 + 10 * std::sin (getFrameCounter() * 0.1f + i * 0.5f);
  62. Point<float> p (getWidth() / 2.0f + 1.5f * radius * std::sin (getFrameCounter() * 0.02f + i * 0.12f),
  63. getHeight() / 2.0f + 1.0f * radius * std::cos (getFrameCounter() * 0.04f + i * 0.12f));
  64. // draw the circles along the fish
  65. g.fillEllipse (p.x - i, p.y - i, 2.0f + 2.0f * i, 2.0f + 2.0f * i);
  66. if (i == 0)
  67. spinePath.startNewSubPath (p); // if this is the first point, start a new path..
  68. else
  69. spinePath.lineTo (p); // ...otherwise add the next point
  70. }
  71. // draw an outline around the path that we have created
  72. g.strokePath (spinePath, PathStrokeType (4.0f));
  73. }
  74. void resized() override
  75. {
  76. // This is called when this component is resized.
  77. // If you add any child components, this is where you should
  78. // update their positions.
  79. }
  80. private:
  81. //==============================================================================
  82. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AnimationAppDemo)
  83. };