POV-Ray : Newsgroups : povray.text.scene-files : picture cataloging macro Server Time
8 Jul 2024 10:51:39 EDT (-0400)
  picture cataloging macro (Message 1 to 1 of 1)  
From: Pete
Subject: picture cataloging macro
Date: 1 Sep 2000 22:00:11
Message: <2424.278T1275T11884436PeterC@nym.alias.net>
Here is a small .pov file that will generate a sort
of thumbnail index catalog of pictures.  Simply add an
"add_picture()" call for each picture.  All pictures
are assumed to have the same height / width ratio.

This routine writes out an intermediate file
called "try.pov", overwriting any older version
of "try.pov".


Pete

-- 

global_settings {
  assumed_gamma 2.4 // adjust to taste  :)
}


background { color red 0 green 0.03 blue 0.4 }


camera {
  direction <0, 0, 1>
  right <1, 0, 0>
  up <0, 1, 0>
  orthographic
  translate <0, 0, -10>
}


#declare num_pics = 0;

#macro add_pic(pictype, filename)
  #write(_txtr_file, "#declare p", num_pics, " = pigment {\n")
  #write(_txtr_file, "  image_map {\n")
  #write(_txtr_file, "    ", pictype, " \"", filename, "\"\n")
  #write(_txtr_file, "    interpolate 2\n")
  #write(_txtr_file, "  }\n")
//  #write(_txtr_file, "  translate <-0.5, -0.5, 0>\n")
  #write(_txtr_file, "}\n\n\n")
  #declare num_pics = num_pics + 1;
#end


#declare txtr_output_file = "try.pov"
#fopen _txtr_file txtr_output_file write
#write(_txtr_file, "#render \"This is try.pov!!!\"\n")

/* here is where you list your image files ...
   The add_pic marco will update the count of the
   number of pictures. */
add_pic("png", "test.png")
add_pic("png", "mtmandj.png")
add_pic("png", "retr_pic.png")
add_pic("tga", "view_2.tga")
add_pic("gif", "torus_tile2.gif")


#declare sizex = int(sqrt(num_pics));
#if ((sizex * sizex) < num_pics)
  #declare sizex = sizex + 1;
#end


#macro place_pic(picindex, xx, yy)
#write(_txtr_file, "box {\n")
#write(_txtr_file, "  <0, 0, 0>, <1, 1, 0>\n")
#write(_txtr_file, "  pigment {\n")
#write(_txtr_file, "    p", picindex, "\n")
#write(_txtr_file, "  }\n")
#write(_txtr_file, "  scale ", 1 / sizex, "\n")
#local xxx = xx/sizex - 0.5;
#local yyy = ((sizex - yy) - 1) / sizex - 0.5;
#write(_txtr_file, "  translate <", xxx, ", ", yyy, ", 0", ">\n")
#write(_txtr_file, "  finish { ambient 1 diffuse 0 }\n")
#write(_txtr_file, "}\n\n\n")
#end


#declare pic_index = 0;
#declare tiley = 0;
#while (tiley < sizex)
  #declare tilex = 0;
  #while (tilex < sizex)
    #if (pic_index < num_pics)
      place_pic(pic_index, tilex, tiley)
    #end
    #declare pic_index = pic_index + 1;
    #declare tilex = tilex + 1;
  #end
  #declare tiley = tiley + 1;
#end


#fclose _txtr_file

#render "about to include try.pov\n"
#include "try.pov"


/* actual end of this file */


Post a reply to this message

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