Created
March 29, 2018 16:33
-
-
Save ed95/77a81d780f125217d5c3e856c4c4be04 to your computer and use it in GitHub Desktop.
A simple JUCE app using emojis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************* | |
The block below describes the properties of this PIP. A PIP is a short snippet | |
of code that can be read by the Projucer and used to generate a JUCE project. | |
BEGIN_JUCE_PIP_METADATA | |
name: EmojiJUCE | |
vendor: JUCE | |
website: http://juce.com | |
dependencies: juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics | |
exporters: xcode_mac, xcode_iphone | |
type: Component | |
mainClass: EmojiJUCE | |
END_JUCE_PIP_METADATA | |
*******************************************************************************/ | |
#pragma once | |
#include "../JuceLibraryCode/JuceHeader.h" | |
#include "juce_EmojiDefines.h" | |
//============================================================================== | |
π ππ : π΅ π | |
{ | |
ππ (π* π»ππ, π<float> π»ππ) | |
: ππ (π»ππ), | |
ππ (π»ππ) | |
{ | |
ππ (40, 40); | |
ππ(); | |
} | |
bool ππ() | |
{ | |
ππ += ππ; | |
ππ.y += 0.1f; | |
πΒ·π ((int) ππ.x, | |
(int) ππ.y); | |
if (π* π¦ = ππ¦()) | |
π π (ππ.x, (float) π¦->πππ()) && ππ.y < (float) π¦->πππ(); | |
π ππ.y < 400.0f && ππ.x >= -10.0f; | |
} | |
π³ π¨βπ¨ (πΎ& π) πΆπ¦ | |
{ | |
ππ->ππ (π, ππ π().toFloat(), RectanglePlacement::Β·, 1.0f); | |
} | |
//============================================================================== | |
π* ππ; | |
π<float> ππ, | |
ππ { π²().nextFloat() * 4.0f - 2.0f, | |
π²().nextFloat() * -6.0f - 2.0f }; | |
//============================================================================== | |
πΏπ¨ (ππ) | |
}; | |
//============================================================================== | |
π EmojiJUCE : π΅ π, | |
π π° | |
{ | |
π΅: | |
//============================================================================== | |
EmojiJUCE() | |
{ | |
ππ (600, 400); | |
π (); | |
π¬π° (60); | |
} | |
~EmojiJUCE() | |
{ | |
} | |
//============================================================================== | |
π³ π¨βπ¨ (πΎ& π) πΆπ¦ | |
{ | |
π.π (ππΌ().ππ¨ (ResizableWindow::backgroundColourId)); | |
π.ππ (π (16.0f)); | |
π.ππ¨ (π¨ (255, 255, 255)); | |
ππ§ π€‘; | |
if (Base64::convertFromBase64 (π€‘, "QXByaWwgRm9vbCdzIQ==")) | |
π.ππ (π€‘.toString(), ππ π(), Justification::Β·); | |
} | |
π³ π() πΆπ¦ | |
{ | |
} | |
π: | |
//============================================================================== | |
π³ π°π() πΆπ¦ | |
{ | |
π« (int i = ππ.π(); --i >= 0;) | |
if (! ππ.π€ (i)->ππ()) | |
ππ.π₯ (i); | |
if (π²().nextInt (100) < 4) | |
ππ (ππ.π₯ (πΆ ππ (π, ππ().πΒ·().toFloat()))); | |
} | |
ππ<ππ> ππ; | |
ππ<π> π; | |
//============================================================================== | |
π³ π () | |
{ | |
const char* π»π = R"JUCELogo( | |
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><g mask="url(#mask-2)" fill="#B144C8"> | |
<path d="M23.7 49.5C14 49.5 6 41.5 6 31.7 6 22 14 14 23.7 14 33.5 14 41.5 22 41.5 31.7 41.5 | |
41.5 33.5 49.5 23.7 49.5ZM23.7 15.2C14.6 15.2 7.2 22.6 7.2 31.7 7.2 40.9 14.6 48.3 | |
23.7 48.3 32.9 48.3 40.3 40.9 40.3 31.7 40.3 22.6 32.9 15.2 23.7 15.2Z"/> | |
<path d="M37.7 31.1C38 31.1 38.3 31 38.5 30.8 38.8 30.6 38.9 30.3 38.8 29.9 38.5 27.2 37.4 | |
24.5 35.7 22.3 35.5 22 35.2 21.9 34.8 21.9 34.6 21.9 34.3 22 34.1 22.2L25.5 30.8C25.4 | |
30.9 25.5 31.1 25.7 31.1L37.7 31.1Z"/> | |
<path d="M34.8 41.6L34.8 41.6C35.2 41.6 35.5 41.4 35.7 41.1 37.4 38.9 38.5 36.3 38.8 33.5 38.9 | |
33.2 38.8 32.9 38.5 32.6 38.3 32.4 38 32.3 37.7 32.3L25.7 32.3C25.5 32.3 25.4 32.5 25.5 | |
32.7L34.1 41.2C34.3 41.4 34.6 41.6 34.8 41.6"/> | |
<path d="M12.6 21.9C12.3 21.9 12 22 11.8 22.3 10 24.5 9 27.2 8.6 29.9 8.6 30.3 8.7 30.6 8.9 | |
30.8 9.1 31 9.4 31.1 9.7 31.1L21.8 31.1C22 31.1 22.1 30.9 21.9 30.8L13.4 22.2C13.2 | |
22 12.9 21.9 12.6 21.9"/> | |
<path d="M21.8 32.3L9.7 32.3C9.4 32.3 9.1 32.4 8.9 32.6 8.7 32.9 8.6 33.2 8.6 33.5 9 36.3 10 | |
38.9 11.8 41.1 12 41.4 12.3 41.6 12.6 41.6 12.9 41.6 13.2 41.4 13.4 41.2L13.4 41.2 21.9 | |
32.7C22.1 32.5 22 32.3 21.8 32.3"/> | |
<path d="M23.1 17.7C23.1 17.4 23 17.1 22.8 16.9 22.6 16.7 22.3 16.6 21.9 16.6 19.2 17 16.5 18 14.3 | |
19.8 14 20 13.9 20.3 13.9 20.6 13.9 20.9 14 21.2 14.2 21.4L22.8 29.9C22.9 30.1 23.1 30 23.1 | |
29.8L23.1 17.7Z"/> | |
<path d="M33.6 20.6L33.6 20.6C33.6 20.3 33.4 20 33.1 19.8 30.9 18 28.3 17 25.5 16.6 25.2 16.6 24.9 | |
16.7 24.6 16.9 24.4 17.1 24.3 17.4 24.3 17.7L24.3 29.8C24.3 30 24.5 30.1 24.7 29.9L33.2 | |
21.4C33.4 21.2 33.6 20.9 33.6 20.6"/> | |
<path d="M13.9 42.8C13.9 43.2 14 43.5 14.3 43.7 16.5 45.4 19.2 46.5 21.9 46.8 22.3 46.9 22.6 46.8 | |
22.8 46.5 23 46.3 23.1 46 23.1 45.7L23.1 33.7C23.1 33.5 22.9 33.4 22.8 33.5L14.2 42.1C14 | |
42.3 13.9 42.6 13.9 42.8"/> | |
<path d="M24.3 45.7C24.3 46 24.4 46.3 24.6 46.5 24.9 46.8 25.2 46.9 25.5 46.8 28.3 46.5 30.9 | |
45.4 33.1 43.7 33.4 43.5 33.6 43.2 33.6 42.8 33.6 42.6 33.4 42.3 33.2 42.1L24.7 33.5C24.5 | |
33.4 24.3 33.5 24.3 33.7L24.3 45.7Z"/> | |
</g> | |
</svg> | |
)JUCELogo"; | |
ππ<π·> π₯ (π·π·::π (π»π)); | |
π = π::πΆπ₯ (*π₯); | |
π (π != π³π); | |
} | |
//============================================================================== | |
πΏπ¨ (EmojiJUCE) | |
}; | |
I think this is a good idea for reducing code size, but mostly only for project specific uses. Is changing over the entire library and standard library keyboards going to increase readability? Maybe over time this will grow easier but it essentially requires the coder to learn a new language (linguistically speaking) and introduces a steeper learning curve to new, non-emoji fluent programmers wanting to get started with juce. I hope at the very least the header will be configured so that the emoji defines can be optional (which iβm guessing it will)
I can't wait to use this in my next interview white-board session! Thanks!!! π²
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some serious progress!!
will start working on Emo I, an emoji synthesize based Synth!
Save the day
m