|
|
// Hi Bill,
//
// min_extent and max_extent will help centering text;
// this whole post is a demo scene -- render with
// -F +W512 +H384 +A0.1
//
// Replace "/2*x" by
// "/2*<1,1,0>" to center along x and y
// "/2" to center along all axes
// "*-1" to right-justify
// "*<1,.5,0> to right-justify and center along y
// etc. (and change the macro's name accordingly!)
//
// Sputnik
// macros to center an object along the x-axis
// (more precisely: to center the bounding box of
// the object; this works well for text objects)
#macro Simple_center_along_x (Obj)
object { Obj translate -(max_extent(Obj)-min_extent(Obj))/2*x }
#end//macro Simple_center_along_x
#macro Center_along_x (Obj)
object { Obj translate -(max_extent(Obj)-min_extent(Obj))/2*x
// "}" omitted to allow modifiers without object{...}
#end//macro Center_along_x
// a text object
#declare TextObject = text { ttf "timrom.ttf" "[---Text---]" 0.1, 0
pigment { color rgb 1 }
}
// put centered text into scene
Simple_center_along_x ( TextObject ) // that's all!
object { Simple_center_along_x ( TextObject )
translate -z
}
Center_along_x ( TextObject ) // {
translate -2*z
}
// origin, z-axis, x-z-plane, light and camera
union {
sphere { 0, 0.1 }
cylinder { -3*z, 3*z, 0.02 }
cone { 3*z, 0.1, 3.5*z, 0 }
pigment { color green 1 }
finish { ambient .3 diffuse .7 }
}
plane { y, 0
pigment { checker rgbt <1, .7, 0, .4> rgbt <1, 1, 0, .4> }
finish { ambient .3 diffuse .7 }
}
light_source { <-1, 3, -2>*100, rgb 1 }
camera { location -4.5*z look_at 0 rotate <40, 20, 0> translate -z }
// END
Post a reply to this message
|
|