This Porcessing code places text on a cirlce. If the circle is full it adds another smaller circle
The Same thing as circles.js but in processing. Extends a example by Daniel Shiffman –>
//Info: http://processingjs.org/reference
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Example 17-8: Characters along a curve
// extended by fabiantheblind
// http://www.the-moron.net
// The message to be displayed
String message = "this is fabiantheblind Keeper of the Sacred Chao Adept of Canhoto son of H.Z. and Dr.D member of the moron net who travells the hello worlds and does stuff that involves things\n";
message = message + message +message +message+message+message+message+message+message+message;
PFont f;
// The radius of a circle
float r = 100;
int pt = 10;
size(320,320);
f = createFont("Georgia",pt,true);
textFont(f);
// The text must be centered!
textAlign(CENTER);
smooth();
background(255);
// Start in the center and draw the circle
translate(width/2, height/2);
noFill();
stroke(0);
//ellipse(0, 0, r*2, r*2);
// We must keep track of our position along the curve
float arclength = 0;
// For every box
for (int i = 0; i < message.length(); i ++ ) {
// The character and its width
char currentChar = message.charAt(i);
// Instead of a constant width, we check the width of each character.
float w = textWidth(currentChar);
// Each box is centered so we move half the width
arclength += w/2;
// Angle in radians is the arclength divided by the radius
// Starting on the left side of the circle by adding PI
float theta = PI + arclength / r;
pushMatrix();
// Polar to Cartesian conversion allows us to find the point along the curve.
// See Chapter 13 for a review of this concept.
translate(r*cos(theta), r*sin(theta));
// Rotate the box (rotation is offset by 90 degrees)
rotate(theta + PI/2);
// Display the character
fill(0);
text(currentChar,0,0);
popMatrix();
// Move halfway again
arclength += w/2;
// calc the length of the circle
float u = 2*PI*r;
// if the arclength exeeds the cirlces length
// reduce the radius and make a new smaller cirlce
if(arclength > u - w){
r = r -pt;
arclength = 0;
// it has to stop somehow or we get below 0
if(r < pt*2){
r = pt;
break;
}
}
}
//save("circleProcessing.jpg")






CircleText.app C++ OpenFrameworks
This program does the same as this -> processing code or
this-> InDesign Javascript, but it is written in c++ and openFrameworks. Yeah thats right i do cpp now. It feels a bit wired. After taking 32 hours of intensive training in c and c++ my head feels a: bit ->messedup() but *good.
int main (void){
char str[32] = “fabiantheblind enters a new world”;
printf(“%s”,str);
return 0;
}
The code is provided as is with no warrenty at all
state of: Sat Jun 4 11:31:59 CEST 2011
have fun with it…
the main.cpp
// Based on: // Learning Processing // Daniel Shiffman // http://www.learningprocessing.com // Example 17-8: Characters along a curve // // Edited by fabiantheblind // http://www.the-moron.net #include "ofMain.h" #include "circleText.h" #include "ofAppGlutWindow.h" //======================================================================== int main( ){ ofAppGlutWindow window; ofSetupOpenGL(&window, 1000,1000, OF_WINDOW); // <-------- setup the GL context // this kicks off the running of my app // can be OF_WINDOW or OF_FULLSCREEN // pass in width and height too: ofRunApp( new CrclTxtApp()); }the circleText.h
// Based on: // Learning Processing // Daniel Shiffman // http://www.learningprocessing.com // Example 17-8: Characters along a curve // // Edited by fabiantheblind // http://www.the-moron.net #pragma once #include "ofMain.h" #include <sstream> #include <string> #include <SourceText.h> class CrclTxtApp : public ofBaseApp{ public: void setup(); void update(); void draw(); //void drawCircle(); void txtCircle(string txt); void txtCircleRun(int frmcnt,string txt, float r,int pt); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); ofTrueTypeFont franklinBook; ofTrueTypeFont verdana; ofTrueTypeFont franklinBookLarge; ofTTFCharacter curChar; ofImage myImage; bool saveAFrame; float radius; int pointsize; int snapCounter; string message; float counter; };the circleText.cpp
// Based on: // Learning Processing // Daniel Shiffman // http://www.learningprocessing.com // Example 17-8: Characters along a curve // // Edited by fabiantheblind // http://www.the-moron.net #include "circleText.h" // reading a text file #include <iostream> #include <fstream> #include <string> #include <algorithm> //-------------------------------------------------------------- void CrclTxtApp::setup(){ saveAFrame = FALSE; // The radius of a circle radius = ofGetWidth()/3; pointsize = 8; // this loads the font franklinBook.loadFont("OCRAEXT.ttf", pointsize,true,true,true); // this is the text message = "this is fabiantheblind Keeper of the Sacred Chao Adept of Canhoto son of H.Z. and Dr.D member of the moron net who travells the hello worlds and does stuff that involves things.\nThe quick, brown fox jumps over a lazy dog. DJs flock by when MTV ax quiz prog. Junk MTV quiz graced by fox whelps. Bawds jog, flick quartz, vex nymphs. Waltz, bad nymph, for quick jigs vex! Fox nymphs grab quick-jived waltz. Brick quiz whangs jumpy veldt fox. Bright vixens jump; dozy fowl quack. Quick wafting zephyrs vex bold Jim. Quick zephyrs blow, vexing daft Jim.\n Sex-charged fop blew my junk TV quiz.\n How quickly daft jumping zebras vex. Two driven jocks help fax my big quiz. Quick, Baz, get my woven flax jodhpurs! \"Now fax quiz Jack! \" my brave ghost pled. Five quacking zephyrs jolt my wax bed. Flummoxed by job, kvetching W. zaps Iraq. Cozy sphinx waves quart jug of bad milk. A very bad quack might jinx zippy fowls. Few quips galvanized the mock jury box. Quick brown dogs jump over the lazy fox. The jay, pig, fox, zebra, and my wolves quack! Blowzy red vixens fight for a quick jump. Joaquin Phoenix was gazed by MTV for luck.\n A wizard’s job is to vex chumps quickly in fog. Watch \"Jeopardy! \", Alex Trebek's fun TV quiz game. Woven silk pyjamas exchanged for blue quartz. Brawny gods just"; for(int j = 0; j < 5; j++){ message = message + message; } // count the time counter = 0; // set the bg ofBackground(255,255,255); // set the framerate ofSetFrameRate(25); // dont redraw the background if not called ofSetBackgroundAuto(FALSE); } //-------------------------------------------------------------- // only count up void CrclTxtApp::update(){ counter++; } //-------------------------------------------------------------- void CrclTxtApp::draw(){ // the first 3 frames or so dont show the text // so we wait 10 frames if(counter > 10){ //translate it to the center ofTranslate(ofGetWidth()/2, ofGetHeight()/2); // if you want to twist it in runtime // ofRotateZ(counter); // use this function if you only want to write the circle without animation //txtCircle(message); txtCircleRun(counter - 11,message,radius,pointsize); }//close pre counter // if you want to write sequences if(saveAFrame ==TRUE){ myImage.grabScreen(0,0,ofGetWidth(),ofGetHeight()); myImage.saveImage("Screenrecord-"+ofToString(snapCounter)+".png"); snapCounter++; } } // tihs is the animated circle // depends on counter void CrclTxtApp::txtCircleRun(int frmcnt,string txt, float r,int pt){ // get the global values to local //float r = radius;// ofGetWidth() / 4; //int pt = pointsize; //15; static float rad = r; static float arclength = 0; char input[txt.length()]; // For every box int i = frmcnt%txt.length(); // for (int i = 0; i < txt.length(); i ++ ) { // The character and its width // later on we use this character again for checking for newline characters stringstream ss; string s; char currentChar; currentChar = message[i]; // push it to a stream ss << currentChar; // and then into a string again ss >> s; // Instead of a constant width, we check the width of each character. float w = franklinBook.stringWidth(s); // Each box is centered so we move half the width arclength += w/2; // Angle in radians is the arclength divided by the radius // Starting on the left side of the circle by adding PI float theta = PI + arclength / rad; // push the matrix ofPushMatrix(); // Polar to Cartesian conversion allows us to find the point along the curve. // this translate the singe character onto his position on the circle ofTranslate(0+(rad*cos(theta)), 0+( rad*sin(theta))); // calc the rotation of the single character. this is in radians float rot = (theta + (PI/2)); // turn radians to degrees float degrees = rot * (180/PI); // now rotate ofRotateZ(degrees); // Display the "character" // watch out its a string ofSetColor(0,0,0); // set the textheight franklinBook.setLineHeight(pt); // draw the singe "character" // watch out its astring franklinBook.drawString(s, 0,0); ofPopMatrix(); // Move halfway again arclength += w/2; float u = 2*PI*rad; // this checks for breakline or if the circle is full if((arclength > u - w)||(currentChar == '\n')){ // reduce the radius by the textheight *1.5 rad = rad - (pt*1.5); // set the arc back to arclength = 0; // check if the circle is to small if(rad < pt*2){ rad = pt; // break; } // close if(r < pt*2) }// close if((arclength > u - w)||(currentChar == '\n')) // } } // tihs is for drawing the circle without animation void CrclTxtApp::txtCircle(string txt){ // get the global values to local float r = radius;// ofGetWidth() / 4; int pt = pointsize; //15; float arclength = 0; char input[txt.length()]; // For every box for (int i = 0; i < txt.length(); i ++ ) { // The character and its width // later on we use this character again for checking for newline characters stringstream ss; string s; char currentChar; currentChar = message[i]; // push it to a stream ss << currentChar; // and then into a string again ss >> s; // Instead of a constant width, we check the width of each character. float w = franklinBook.stringWidth(s); // Each box is centered so we move half the width arclength += w/2; // Angle in radians is the arclength divided by the radius // Starting on the left side of the circle by adding PI float theta = PI + arclength / r; // push the matrix ofPushMatrix(); // Polar to Cartesian conversion allows us to find the point along the curve. // this translate the singe character onto his position on the circle ofTranslate(0+(r*cos(theta)), 0+( r*sin(theta))); // calc the rotation of the single character. this is in radians float rot = (theta + (PI/2)); // turn radians to degrees float degrees = rot * (180/PI); // now rotate ofRotateZ(degrees); // Display the "character" // watch out its a string ofSetColor(0,0,0); // set the textheight franklinBook.setLineHeight(pt); // draw the singe "character" // watch out its astring franklinBook.drawString(s, 0,0); ofPopMatrix(); // Move halfway again arclength += w/2; float u = 2*PI*r; // this checks for breakline or if the circle is full if((arclength > u - w)||(currentChar == '\n')){ // reduce the radius by the textheight *1.5 r = r - (pt*1.5); // set the arc back to arclength = 0; // check if the circle is to small if(r < pt*2){ r = pt; break; } // close if(r < pt*2) }// close if((arclength > u - w)||(currentChar == '\n')) } } //-------------------------------------------------------------- void CrclTxtApp::keyPressed (int key){ } //-------------------------------------------------------------- void CrclTxtApp::keyReleased(int key){ } //-------------------------------------------------------------- void CrclTxtApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void CrclTxtApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void CrclTxtApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void CrclTxtApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void CrclTxtApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void CrclTxtApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void CrclTxtApp::dragEvent(ofDragInfo dragInfo){ }