1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

More example cleanups.

This commit is contained in:
jules 2014-11-04 13:21:37 +00:00
parent a626425764
commit ab63ac4e0d
7 changed files with 31 additions and 45 deletions

View file

@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>13F34</string>
<string>14A389</string>
<key>CFBundleExecutable</key>
<string>AnimationAppExample</string>
<key>CFBundleIdentifier</key>
@ -21,17 +21,17 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>6A317</string>
<string>6A1052d</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>13F26</string>
<string>14A382</string>
<key>DTSDKName</key>
<string>macosx10.9</string>
<string>macosx10.10</string>
<key>DTXcode</key>
<string>0600</string>
<string>0610</string>
<key>DTXcodeBuild</key>
<string>6A317</string>
<string>6A1052d</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSHumanReadableCopyright</key>

View file

@ -20,56 +20,45 @@ class MainContentComponent : public AnimatedAppComponent
{
public:
//==============================================================================
MainContentComponent()
{
setSize (500, 400);
setFramesPerSecond (60);
}
~MainContentComponent()
void update() override
{
// This function is called at the frequency specified by the setFramesPerSecond() call
// in the constructor. You can use it to update counters, animate values, etc.
}
void update()
void paint (Graphics& g) override
{
}
void paint (Graphics& g)
{
// fill background
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (Colours::black);
int fishLength = 15;
// set the drawing colour
g.setColour (Colours::white);
const int fishLength = 15;
// Create a new path object for the spine
Path p;
Path spinePath;
//
for (int i = 0; i < fishLength; ++i)
{
float radius = 100 + 10 * sin (getFrameCounter() * 0.1 + i * 0.5f);
float x = getWidth()/2 + 1.5f * radius * sin (getFrameCounter() * 0.02f + i * 0.12f);
float y = getHeight()/2 + radius * cos (getFrameCounter() * 0.04f + i * 0.12f);
const float radius = 100 + 10 * std::sin (getFrameCounter() * 0.1f + i * 0.5f);
const float x = getWidth() / 2.0f + 1.5f * radius * std::sin (getFrameCounter() * 0.02f + i * 0.12f);
const float y = getHeight() / 2.0f + radius * std::cos (getFrameCounter() * 0.04f + i * 0.12f);
// draw the ellipses of the fish
g.fillEllipse(x - i, y - i, 2 + 2*i, 2 + 2*i);
// draw the circles along the fish
g.fillEllipse (x - i, y - i, 2.0f + 2.0f * i, 2.0f + 2.0f * i);
// start a new path at the beginning otherwise add the next point
if (i == 0)
p.startNewSubPath(x, y);
spinePath.startNewSubPath (x, y); // if this is the first point, start a new path..
else
p.lineTo (x, y);
spinePath.lineTo (x, y); // ...otherwise add the next point
}
// stroke the path that we have created
g.strokePath (p, PathStrokeType (4));
// draw an outline around the path that we have created
g.strokePath (spinePath, PathStrokeType (4));
}
void resized()
@ -83,16 +72,15 @@ public:
private:
//==============================================================================
// private member variables
// Your private member variables go here...
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
};
Component* createMainContentComponent() { return new MainContentComponent(); };
// (This function is called by the app startup code to create our main component)
Component* createMainContentComponent() { return new MainContentComponent(); }
#endif // MAINCOMPONENT_H_INCLUDED

View file

@ -33,7 +33,7 @@ public:
void update() override
{
// This function is called at the frequency specified by the setFramesPerSecond() call
// in the constructor. You can use it
// in the constructor. You can use it to update counters, animate values, etc.
}
void paint (Graphics& g) override

View file

@ -23,7 +23,6 @@ public:
MainContentComponent()
{
setSize (500, 400);
}
~MainContentComponent()

View file

@ -33,7 +33,7 @@ struct AudioAppWizard : public NewProjectWizard
bool initialiseProject (Project& project) override
{
createSourceFolder();
createSourceFolder();
File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp");
File contentCompCpp = getSourceFilesFolder().getChildFile ("MainComponent.cpp");

View file

@ -31,9 +31,9 @@ struct OpenGLAppWizard : public NewProjectWizard
String getDescription() const override { return TRANS("Creates a blank JUCE application with a single window component. This component supports openGL drawing features including 3D model import and GLSL shaders."); }
const char* getIcon() const override { return BinaryData::wizard_OpenGL_svg; }
bool initialiseProject (Project& project) override
bool initialiseProject (Project& project) override
{
createSourceFolder();
createSourceFolder();
File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp");
File contentCompCpp = getSourceFilesFolder().getChildFile ("MainComponent.cpp");
@ -51,7 +51,7 @@ struct OpenGLAppWizard : public NewProjectWizard
// create main window
String windowCpp = project.getFileTemplate ("jucer_OpenglComponentTemplate_cpp")
.replace ("INCLUDE_JUCE", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompCpp), false);
.replace ("INCLUDE_JUCE", CodeHelpers::createIncludeStatement (project.getAppIncludeFile(), contentCompCpp), false);
if (! FileHelpers::overwriteFileWithNewDataIfDifferent (contentCompCpp, windowCpp))
failedFiles.add (contentCompCpp.getFullPathName());
@ -72,7 +72,6 @@ struct OpenGLAppWizard : public NewProjectWizard
sourceGroup.addFile (mainCppFile, -1, true);
return true;
}
};