Open eighteight opened 8 years ago
what do you have in mind? how big of a character set were you thinking?
one thing i'd wanted to do was add the ability to pass in custom patterns so you could do animations like: https://youtu.be/UuYC4uDPlkU?t=53
open approach i'd been considering was keeping it old school and making the patterns for 128-255 configurable, like the old days with extended ASCII... so you could build your own code page.
I was thinking of using this block to display the titles of the songs playing in ios. As one may expect, there may be all kinds of characters in the music library titles. However, if it were possible to extend this to a particular set of characters, that would be helpful too in other applications, where custom patterns could be built by hand for specific characters. Looking at your code, I am not sure, how that could be done. Can you point me to a place in the code, where this could be implemented?
Thanks.
Yeah it'll need a little work, I'll see if I can down some time on it tonight.
I pushed some changes last night to allow the display()
method to take a vector<uint16_t>
so raw patterns can be passed in. Here's a sample app I was using to test it. When you scroll with the mouse/trackpad it spins one of the characters:
#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include "UnionJack.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class CinderProjectApp : public App {
public:
void setup() override;
void draw() override;
void mouseWheel(MouseEvent event) override;
vector<UnionJack> mDisplays;
float mRotor = 0.0f;
};
void CinderProjectApp::setup()
{
Color light = Color8u::hex( 0x42a1eb );
Color dark = Color8u::hex( 0x082f4d );
vec2 padding( 20 );
mDisplays = {
UnionJack( "UnionJack *" ).scale( 3 ).position( padding )
.colors( Color8u::hex( 0xf00000 ), Color8u::hex( 0x530000 ) ),
// Let's print out the full ASCII table as a font specimen
UnionJack( 33 ).display( " !\"#$%&'()*+,-./0123456789:;<=>?" ).colors( light, dark ),
UnionJack( 33 ).display( "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" ).colors( light, dark ),
UnionJack( 33 ).display( "`abcdefghijklmnopqrstuvwxyz{|}~\x7F" ).colors( light, dark ),
};
// Position the displays relative to each other.
mDisplays[1].below( mDisplays[0] );
mDisplays[2].below( mDisplays[1] );
mDisplays[3].below( mDisplays[2] );
setWindowSize( padding + mDisplays[3].calcBoundingBox().getLowerRight() );
}
void CinderProjectApp::draw()
{
gl::clear( Color::black() );
for ( auto display = mDisplays.begin(); display != mDisplays.end(); ++display ) {
display->draw();
}
}
void CinderProjectApp::mouseWheel(MouseEvent event)
{
// Scroll the mouse and animate the display.
mRotor += event.getWheelIncrement();
char pattern[8] = { 0xA, 0x8, 0xF, 0xE, 0xD, 0x9, 0xC, 0xB };
int pos = (int) mRotor % 8;
uint16_t val = 1 << ( mRotor > 0 ? pattern[pos] : abs( pos ) );
mDisplays[0].display( 10, val );
}
void prepareSettings( App::Settings *settings )
{
settings->setHighDensityDisplayEnabled();
}
CINDER_APP( CinderProjectApp, RendererGl( RendererGl::Options().msaa( 16 ) ), prepareSettings )
So that would let you set custom values, but I'd need to do a little more thinking about how best to expose customizable character.
Ah, cool, I see what you did. Yes, this can be extended to show custom patterns. Thanks a lot.
Happy New Year!
How would I approach this, if I were to extend this for non-ascii characters?
Thanks.