POV-Ray : Newsgroups : povray.binaries.scene-files : Inscription macro Server Time
2 Sep 2024 00:15:38 EDT (-0400)
  Inscription macro (Message 1 to 1 of 1)  
From: Jellby
Subject: Inscription macro
Date: 30 Dec 2003 19:14:37
Message: <3ff214ed@news.povray.org>
This is probably ugly code (adapted and untested):

#include "shapes.inc"

#macro Inscription(T,F,R,D,S,N)
  //T -> Text as a vector of "characters"
  //F -> Font, without extension
  //R -> Circle radius. R > 0 -> outside. R < 0 -> inside
  //D -> Thickness of the letters
  //S -> Scale factor for the letters
  //N -> Scale factor for the spaces
  #local Sign=select(R,-1,1);
  #local R=abs(R);
  #local I=0;
  #local Angle=0;
  #while (I < dimension_size(T,1))
    text {
      ttf concat(F,".ttf")
      T[I], D, 0
      #local Width=Text_Width(concat(F,".ttf"),T[I],S,0)/2;
      #local Space=Text_Space(concat(F,".ttf"),T[I],S,0)-2*Width;
      scale <S, S, 1>
      translate <-Width, 0, -Sign*R>
      bounded_by { box { -<Width,0.5*S,Sign*R>, <Width,0.5*S,D-Sign*R> } }
      rotate -Sign*(Angle+degrees(asin(Width/R)))*y
      #local Angle=Angle+2*degrees(asin(Width/R))+180*N*Space/R;
    }
    #local I=I+1;
  #end
#end

#declare Text = array[43]
  {"S","a","m","p","l","e"," ","t","e","x","t"}

#declare Object = union {
  difference {
    sphere { 4.5 }
    union {
      Inscription(Text,"Arial",+4.6,0.5,0.70,0.30)
    }
    bounded_by { cylinder { -1.05*y, 1.05*y, 4.55 } }
  }
  sphere { 4.45 }
  pigment { color <1, 1, 0> }
}

-- 
light_source{9+9*x,1}camera{orthographic look_at(1-y)/4angle 30location
9/4-z*4}light_source{-9*z,1}union{box{.9-z.1+x clipped_by{plane{2+y-4*x
0}}}box{z-y-.1.1+z}box{-.1.1+x}box{.1z-.1}pigment{rgb<.8.2,1>}}//Jellby


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.