POV-Ray : Newsgroups : povray.newusers : Writing a .inc file : Re: Writing a .inc file Server Time
28 Jul 2024 14:24:03 EDT (-0400)
  Re: Writing a .inc file  
From: Chris B
Date: 28 Jul 2009 14:02:53
Message: <4a6f3d4d@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message 
news:4a6f2cf7@news.povray.org...
> OT <nomail@nomail> wrote:
>> Any ideas on how to actually write a macro to arrange all the elements in 
>> a
>> table?
>
> http://povray.org/documentation/view/3.6.1/430/
>


I assume you mean the periodic table. My first instinct was, like Warp, to 
suggest arrays, but I don't think you actually need them. The macro below 
should do the job.  The reason for first assigning the text to variables 
rather than writing it directly into the scene is simply to allow it to be 
centre aligned within the box.

Regards,
Chris B.

camera {orthographic location <9, 15,-5> look_at <9,0,-5>}
global_settings { ambient_light 10}

#macro AddElement(Number, Symbol, Group, Period)
  union {
    box {<-0.4,-1,-0.4>,<0.4,-0.1,0.4> pigment {rgb BoxColor}}
    #local NumberText = text {ttf "timrom.ttf" Number 1,0 pigment {rgb 
TextColor} scale 0.4 rotate x*90}
    #local SymbolText = text {ttf "timrom.ttf" Symbol 1,0 pigment {rgb 
TextColor} scale 0.4 rotate x*90}
    object {NumberText translate 
z*0.2-(min_extent(NumberText)+max_extent(NumberText))/2}
    object {SymbolText 
translate -z*0.2-(min_extent(SymbolText)+max_extent(SymbolText))/2}
    translate <Group,0,-Period>
  }
#end

#declare TextColor = <2,0,0>;
#declare BoxColor = <0.5,1,0.5>;
AddElement(  "1","H" ,  1,1)
#declare BoxColor = <0.5,1,1  >;
AddElement(  "2","He", 18,1)
// ...
#declare BoxColor = <1,0.3,0.3>;
AddElement(  "3","Li",  1,2)
AddElement( "11","Na",  1,3)
AddElement( "87","Fr",  1,7)
// ...


Post a reply to this message

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