POV-Ray : Newsgroups : povray.binaries.images : Calendar v2 [25kb] Server Time
17 Aug 2024 04:14:43 EDT (-0400)
  Calendar v2 [25kb] (Message 1 to 6 of 6)  
From: Tom Melly
Subject: Calendar v2 [25kb]
Date: 23 Nov 2001 11:54:30
Message: <3bfe7f46@news.povray.org>
Okay, you can now specify an arbitary object which will be used at a particular
date - couldn't see how to implement a daily calendar though (at least not
without resorting to perl). POV is very fussy about what it'll read.... ;)

Here's the new calendar code...

#version 3.5;


// 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 <XTrans,YTrans,0>
  }
#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<XTrans, YTrans, 0>}
      #end
      #local XTrans = XTrans + CalXOff;
      #if(ModDInt = 6)
        #local XTrans = 0;
        #local YTrans = YTrans - CalYOff;
      #end
    #end
  #end
#end

and a small sample scene...

#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}
}

#include "cal.inc"
#declare MyCalendar =
union{
  MakeCal(2001,11,23,2.0,1.0,"c:/winnt/fonts/comi.ttf",1,0,6,2.6, myObj)
  translate x*-6.5
  translate y*4
  translate z*-0.001
}

object{MyCalendar pigment{Red}}



--
#macro G(D,E,F)#local I=array[3]{D,E,F}#local B=0;triangle{#while(
B<3)#while(I[B])A[mod(I[B],10)]+#local I[B]=div(I[B],10);#end<-5,-
2,9>#local B=B+1;#end}#end #local A=array[7]{x,x*2,x*4,y,y*2,y*4,z
}light_source{-x*6-z*9,1}mesh{G(105,10,146)G(105,246,10)G(105,56,
146)G(105,1256,246)G(1256,126,220)G(22156,2216,201)pigment{rgb 1}}//TM


Post a reply to this message


Attachments:
Download 'revised calender macro.jpg' (25 KB)

Preview of image 'revised calender macro.jpg'
revised calender macro.jpg


 

From: Trevor Quayle
Subject: Re: Calendar v2 [25kb]
Date: 23 Nov 2001 12:08:33
Message: <3bfe8291$1@news.povray.org>
Are you using windows or do you want it to be non-platform specific?

-tgq

"Tom Melly" <tom### [at] tomandlucouk> wrote in message
news:3bfe7f46@news.povray.org...
> Okay, you can now specify an arbitary object which will be used at a
particular
> date - couldn't see how to implement a daily calendar though (at least not
> without resorting to perl). POV is very fussy about what it'll read.... ;)
>
> Here's the new calendar code...
>
> #version 3.5;
>
>
> // 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 <XTrans,YTrans,0>
>   }
> #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<XTrans, YTrans, 0>}
>       #end
>       #local XTrans = XTrans + CalXOff;
>       #if(ModDInt = 6)
>         #local XTrans = 0;
>         #local YTrans = YTrans - CalYOff;
>       #end
>     #end
>   #end
> #end
>
> and a small sample scene...
>
> #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}
> }
>
> #include "cal.inc"
> #declare MyCalendar =
> union{
>   MakeCal(2001,11,23,2.0,1.0,"c:/winnt/fonts/comi.ttf",1,0,6,2.6, myObj)
>   translate x*-6.5
>   translate y*4
>   translate z*-0.001
> }
>
> object{MyCalendar pigment{Red}}
>
>
>
> --
> #macro G(D,E,F)#local I=array[3]{D,E,F}#local B=0;triangle{#while(
> B<3)#while(I[B])A[mod(I[B],10)]+#local I[B]=div(I[B],10);#end<-5,-
> 2,9>#local B=B+1;#end}#end #local A=array[7]{x,x*2,x*4,y,y*2,y*4,z
> }light_source{-x*6-z*9,1}mesh{G(105,10,146)G(105,246,10)G(105,56,
> 146)G(105,1256,246)G(1256,126,220)G(22156,2216,201)pigment{rgb 1}}//TM
>
>
>


Post a reply to this message

From: Tom Melly
Subject: Re: Calendar v2 [25kb]
Date: 23 Nov 2001 12:22:12
Message: <3bfe85c4$1@news.povray.org>
"Trevor Quayle" <Tin### [at] hotmailcom> wrote in message
news:3bfe8291$1@news.povray.org...
> Are you using windows or do you want it to be non-platform specific?
>

Ideally NPS (which I could implement via perl). Is there anyway to get POV to
return today's date as a string - it would be a nice feature for date/time
stamping images anyway...

Windows is what I use - the problems I have hit.

1. "date" requires a prompt from me ("Enter new date:") (although not at work,
since there's a /t option). I've got around this by creating a file, and then
piping a dir list of the file to another file, which then includes today's date.

2. POV won't read a string unless it is enclosed in quotes, so I've got no way
of parsing the file in POV and I can't think of a batch command that will help
quote strings/lines in a file....


Post a reply to this message

From: Trevor Quayle
Subject: Re: Calendar v2 [25kb]
Date: 23 Nov 2001 12:31:02
Message: <3bfe87d6$1@news.povray.org>
"Tom Melly" <tom### [at] tomandlucouk> wrote in message
news:3bfe85c4$1@news.povray.org...
> "Trevor Quayle" <Tin### [at] hotmailcom> wrote in message
> news:3bfe8291$1@news.povray.org...
> > Are you using windows or do you want it to be non-platform specific?
> >
>
> Ideally NPS (which I could implement via perl). Is there anyway to get POV
to
> return today's date as a string - it would be a nice feature for date/time
> stamping images anyway...
>
> Windows is what I use - the problems I have hit.
>
> 1. "date" requires a prompt from me ("Enter new date:") (although not at
work,
> since there's a /t option). I've got around this by creating a file, and
then
> piping a dir list of the file to another file, which then includes today's
date.
>
> 2. POV won't read a string unless it is enclosed in quotes, so I've got no
way
> of parsing the file in POV and I can't think of a batch command that will
help
> quote strings/lines in a file....
>
>


Actually that was along the lines I was thinking, but I guess you haven't
found a way to make it work yet and I can't think of anything else yet. Back
to the drawing board.

-tgq


Post a reply to this message

From: Bill DeWitt
Subject: Re: Calendar v2 [25kb]
Date: 23 Nov 2001 13:29:19
Message: <3bfe957f$1@news.povray.org>
Here's what Bob sent me once. It took some playing around to get it to
do exactly what I wanted, chopping up the date string into lumps.


Post a reply to this message


Attachments:
Download 'Gettime.zip' (3 KB)

From: Francois Labreque
Subject: Re: Calendar v2 [25kb]
Date: 23 Nov 2001 20:40:33
Message: <3BFEF94B.3090500@videotron.ca>
Tom Melly wrote:

> "Trevor Quayle" <Tin### [at] hotmailcom> wrote in message
> news:3bfe8291$1@news.povray.org...
> 
>>Are you using windows or do you want it to be non-platform specific?
>>
>>
> 
> Ideally NPS (which I could implement via perl). Is there anyway to get POV to
> return today's date as a string - it would be a nice feature for date/time
> stamping images anyway...
> 
> Windows is what I use - the problems I have hit.
> 
> 1. "date" requires a prompt from me ("Enter new date:") (although not at work,
> since there's a /t option). I've got around this by creating a file, and then
> piping a dir list of the file to another file, which then includes today's date.


As I mentioned in the p.international group a while ago, you can do

echo. | date | find "Current" > datefile.txt
echo. | time | find "Current" > timefile.txt

(The period has to be right next to "echo" for this to work)

> 2. POV won't read a string unless it is enclosed in quotes, so I've got no way
> of parsing the file in POV and I can't think of a batch command that will help
> quote strings/lines in a file....
> 


That is still a problem, though.

-- 
/*Francois Labreque*/#local a=x+y;#local b=x+a;#local c=a+b;#macro P(F//
/*    flabreque    */L)polygon{5,F,F+z,L+z,L,F pigment{rgb 9}}#end union
/*        @        */{P(0,a)P(a,b)P(b,c)P(2*a,2*b)P(2*b,b+c)P(b+c,<2,3>)
/*   videotron.ca  */}camera{location<6,1.25,-6>look_at a orthographic}


Post a reply to this message

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