#version 3.5; #declare sample_scene = true; // called by main macro #macro MakeTOU(CalStr, XTrans, YTrans, CalFont, CalExt, CalSpace) text { ttf // font type (only TrueType format for now) CalFont, // Microsoft Windows-format TrueType font file name CalStr, // the string to create CalExt, // the extrusion depth CalSpace // inter-character spacing translate } #end /* Params for MakeCal: Year = Gregorian Year [int] Month = Gregorian Month [int 1 -12] MarkDay = if not 0, unions CalObj with that day CalXOff = space between dates [num] CalYoff = space between rows [num] CalFont = font to use [string] CalExt = extrusion on text object [num] CalSpace = inter-char spacing [num] DayOff = day off-set, [num] 0=sunday, 1=monday, ... 6=saturday CenterOff = x-adjust for month-year header [num] adjust for centering of heading CalObj = object to use at Day */ #macro MakeCal(Year, Month, MarkDay, CalXOff, CalYOff, CalFont, CalExt, CalSpace, DayOff, CenterOff, CalObj) #local YTrans = 0; #local XTrans = 0; //make month / year header #local Months = array[12]{ "January","Febuary","March","April", "May","June","July","August", "September","October","November","December" }; #local TempStr = concat(Months[Month-1], " ",str(Year,0,0)) MakeTOU(TempStr,XTrans+CenterOff, YTrans, CalFont, CalExt, CalSpace) #local YTrans = YTrans - CalYOff; //make days of week #local Days = array[7]{"Su","Mo","Tu","We","Th","Fr","Sa"}; #local Temp = 0; #while(Temp<7) #local TempStr=Days[mod(Temp+DayOff,7)] MakeTOU(TempStr, XTrans, YTrans, CalFont, CalExt, CalSpace) #local XTrans = XTrans + CalXOff; #local Temp = Temp+1; #end #local XTrans = 0; #local YTrans = YTrans - CalYOff; //get Julian day integer #local Day = 1; // easier for leap years #if (Month < 3) #local Month = Month + 12; #local Year=Year-1; #end #local JulDay = Day + int((153 * Month - 457) / 5) + 365 * Year + floor(Year/4) - floor(Year / 100) + floor(Year / 400) + 1721118.5; #local JulDay = JulDay - 1; #local LastDay = -1; #local CalDay = 0; #local First = 1; //convert Jul day int to Gregorian cal date, output and inc Jul day #while(LastDay < CalDay) #local LastDay = CalDay; #local JulDay = JulDay + 1; #local ModDInt = floor(mod(JulDay + 2 - DayOff, 7)); #local Z = floor(JulDay - 1721118.5); #local R = JulDay - 1721118.5 - Z; #local G = Z - 0.25; #local A = floor(G / 36524.25); #local B = A - floor(A / 4); #local CalYear = floor((B+G) / 365.25); #local C = B + Z - floor(365.25 * CalYear); #local CalMonth = int((5 * C + 456) / 153); #local CalDay = C - int((153 * CalMonth - 457) / 5) + R; #if (CalMonth > 12) #local CalYear = CalYear + 1; #local CalMonth = CalMonth - 12; #end #if(First | CalDay > 1) // pre-1st of month filler #if(First) #local First = 0; #local Temp = 0; #while (Temp < ModDInt) #local XTrans = XTrans + CalXOff; #local Temp = Temp + 1; #end #end //a date - add to tempstr and output #local TempStr = str(CalDay,2,0) MakeTOU(TempStr, XTrans, YTrans, CalFont, CalExt, CalSpace) #if (CalDay=MarkDay) object{CalObj translate} #end #local XTrans = XTrans + CalXOff; #if(ModDInt = 6) #local XTrans = 0; #local YTrans = YTrans - CalYOff; #end #end #end #end //and a small sample scene... #if(sample_scene) #include "colors.inc" sky_sphere {pigment{wrinkles scale 2 pigment_map{[0 rgb<0.2,0.2,0.7>][1 White]}}} camera { location <0.0, 0.0, 0-12.0> look_at <0.0, 0.0, 0.0> } light_source { 0*x // light's position (translated below) color rgb <1,1,1> // light's color translate <-20, 40, -50> } #declare myObj= sphere_sweep{ b_spline 7, <-0.50,-0.95, 0>,0.01 <-0.30,-1.05, 0>,0.02 < 0.57,-0.50, 0>,0.03 < 0.00, 0.00, 0>,0.04 <-0.50,-0.45, 0>,0.03 < 0.35,-1.00, 0>,0.02 < 0.53,-0.90, 0>,0.01 scale 2.0 rotate z*15 translate <0.2,1.1,0> pigment{Green} } #declare MyCalendar = union{ MakeCal(2002,5,23,2.0,1.0,"c:/windows/fonts/arial.ttf",1,0,6,2.6, myObj) translate x*-6.5 translate y*4 translate z*-0.001 } object{MyCalendar pigment{Red}} #end