/* * Rendering of a great seal as a circle, with individual letters * of a given string rendered around a circle center. * * Sketch by Michael Goldwasser */ void setup() { size(600,600); background(255); // move origin to center of canvas translate(0.5*width, 0.5*height); // let's start by drawing the annulus float outerRadius = 0.45 * width; float innerRadius = 0.3 * width; float annulusHeight = outerRadius - innerRadius; float textPct = 0.6; // percentage of annulus float textHeight = textPct*annulusHeight; float textPadding = 0.5*(annulusHeight - textHeight); fill(0,26,162); ellipse(0, 0, 2*outerRadius, 2*outerRadius); fill(237,233,217); ellipse(0, 0, 2*innerRadius, 2*innerRadius); // now let's render text on the annulus PFont custom = createFont("LucidaGrande-Bold", textHeight); // I don't like the default font textFont(custom); textSize(textHeight); fill(134,132,113); // horizontally centered around 1.5*PI, facing inward textArc("UNIVERSITAS SANCTI LUDOVICI", innerRadius + 1.25*textPadding, 0.7*PI, 2.3*PI, false); // horizontally centered around 0.5*PI, facing outward textArc("1818", outerRadius - 1.25*textPadding, 0.4*PI, 0.6*PI, true); } void draw() { } /* * Render the message with baseline along a circular arc around the origin. * if faceOutward is true, bottom of letters will be farther from center. * * This version lays out characters so that their centers are equally spaced. * Even better would be to use the actual widths of individual characters, with * fixed inter-letter spacing. */ void textArc(String msg, float radius, float startAngle, float stopAngle, boolean faceOutward) { textAlign(CENTER,BASELINE); int numChars = msg.length(); float thetaIncrement = (stopAngle - startAngle) / numChars; for (int j=0; j < numChars; j++) { // time to render msg.charAt(j) pushMatrix(); float theta; if (faceOutward) { theta = stopAngle - thetaIncrement * (0.5+j); } else { theta = startAngle + thetaIncrement * (0.5+j); } translate(radius*cos(theta), radius*sin(theta)); rotate(theta + HALF_PI); // so character at top is normally aligned if (faceOutward) { rotate(PI); } text(msg.charAt(j), 0, 0); popMatrix(); } }