POV-Ray : Newsgroups : povray.binaries.images : tiling pattern challenge : Re: tiling pattern challenge Server Time
30 Jul 2024 18:20:22 EDT (-0400)
  Re: tiling pattern challenge  
From: stbenge
Date: 4 Mar 2011 15:34:02
Message: <4d714cba@news.povray.org>
Hi again,

Here's some updated code.

The color_map viewing switch has been removed, since the image in the 
documentation tells everything we need to know. I also added the ability 
to specify the caulk color, how often it should be displayed, and what 
size to make it. In addition to these changes, there are two new entries 
in the color array, giving us a total of six color combos.

An extra array for referencing the pattern types /could/ be added to 
make the TileTypes variable obsolete, but it would lengthen the code.

// Code

#include "colors.inc"
#include "math.inc"

#declare TilingPattern = 5;
#declare TileTypes    = 3;

// 0 = caulk off
// 1 = caulk at every color
// TileTypes = caulk at n TileTypes
#declare CaulkAt    = 1;
#declare CaulkSize  = 0.2;
#declare CaulkColor = White;

#declare ColorArray =
   array[12]{
     Red,        White,
     Green,      Yellow,
     Blue,       Cyan,
     IndianRed,  Pink,
     DarkGreen,  Turquoise
     Violet,     BlueViolet
   }

plane{y,0
   texture{
     pigment{
       tiling TilingPattern
       color_map{
         #declare V=0;
         #declare V2 = 0;
         #while(V<TileTypes*2)
           #if(mod(V,CaulkAt*2) = CaulkAt*2-1 & CaulkAt!=0)
             #declare ThisColor = rgb<0,0,0>;
            #else
             #declare ThisColor =
               ColorArray[mod(V,dimension_size(ColorArray,1))];
           #end
           #declare incre = (1.0-CaulkSize)*even(V)+CaulkSize*odd(V);
           [ V2/TileTypes ThisColor]
           [ (V2+incre)/TileTypes ThisColor]
           #declare V = V + 1;
           #declare V2 = V2 + incre;
         #end
       }
     }
   }
}

// ~Code

Sam


Post a reply to this message

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