|
|
/* the macro belongs in ..\includes\shapes.inc file, caution if overwriting
previous macro! */
/* BEGIN MODIFIED CIRCLE TEXT MACRO */
// Circle_Text author: Ron Parker
/* Circle_Text( Font, Text, Size, Spacing, Thickness, Radius, Inverted,
Justification, Angle )
Creates a text object with the bottom (or top) of the character cells
aligned
with all or part of a circle. This macro should be used inside an
object{...}
block.
Font: The font to use (see the documentation for the text object)
Text: The text string to be created
Size: The height of the text string, as you would use to scale a
standard text object
Spacing: The amount of space to add between the letters.
Thickness: The thickness of the letters (see the documentation for the
text object)
Radius: The radius of the circle along which the letters are aligned
Inverted: If this parameter is nonzero, the tops of the letters will
point toward the center of the circle. Otherwise, the
bottoms
of the letters will do so.
Justification: One of the constants Align_Left, Align_Right, or Align_Center
Angle: The point on the circle from which rendering will begin. The
+x direction is 0 and the +y direction is 90 (i.e. the angle
increases anti-clockwise.
Label: Orient to imaginary cylinder surface. Values -1 to 1 go from
angles -90 to +90, with 0 being top of text toward +z.
This is not aligned to y-axis! Think wood pattern, -z to +z.
*/
#macro Circle_Text(F, T, S, Sp, Th, R, I, J, A, L)
#local FW = Text_Width(F, T, S, Sp);
#local TO = text {ttf F T 1 0 scale<S, S, 1>}
#local TH = max_extent(TO).y;
#local C = array[strlen(T)]
#if(FW > 2*pi*R)
#error concat("\n\n**** Text string \"", T, "\" is too long for a
circle of the specified radius.\n\n\n")
#end
#local AW = -FW*180/pi/R;
#local SA = A;
#local EA = A + AW;
#if(((J = Align_Right) & !I)|((J = Align_Left) & I))
#local SA = A - AW;
#local EA = A;
#else
#if(J = Align_Center)
#local SA = A - AW/2;
#local EA = A + AW/2;
#end
#end
#local CI = 1;
#while(CI <= strlen(T))
#local OE = Text_Width(F, substr(T,CI,1), S, Sp);
#local LW = Text_Width(F, substr(T,1,CI), S, Sp) - OE;
#local LA = SA + AW*LW/FW + OE/2/FW*AW;
#if(I)
#local LA = EA - (LA - SA);
#end
#local TO = text {ttf F substr(T, CI, 1) Th 0 scale<S,S,1>}
#local CA = L; // added bottle label orientation. Bob Hughes
#if(I)
#local C[CI-1] =
object {TO
rotate 180*z
rotate -90*CA*x
translate <OE/2, TH, 0>
rotate -90*z
translate R*x
rotate LA*z
}
#else
#local C[CI-1] =
object {TO
rotate 90*CA*x
translate -OE/2*x
rotate -90*z
translate R*x
rotate LA*z
}
#end
#local CI = CI + 1;
#end
// Create the final object, a union of individual text object letters.
union {
#local CI=0;
#while(CI < strlen(T))
object {C[CI]}
#local CI = CI + 1;
#end
}
#end
/* END MODIFIED CIRCLE TEXT MACRO */
/* BEGIN EXAMPLE SCENE */
#include "shapes.inc"
camera {location <0,1.5,-3.5> look_at 0}
light_source {<5,5,-20> rgb 1 shadowless}
background {rgb 1}
cylinder {<0,0,-1>,<0,0,1>,1
pigment { // use object pigment pattern
object {
Circle_Text(
"cyrvetic.ttf",
"Centered text, not inverted",
.2, 0.0, .03, 1.01, false, Align_Center, 90, 1
)
color rgbf <1,1,1,0.9>,
color rgb 0
}
}
rotate -90*x
}
/* END EXAMPLE SCENE */
--
Bob H.
http://www.3digitaleyes.com
Post a reply to this message
|
|