POV-Ray : Newsgroups : povray.binaries.images : tiling pattern challenge : Re: tiling pattern challenge Server Time
30 Jul 2024 18:18:13 EDT (-0400)
  Re: tiling pattern challenge  
From: Samuel Benge
Date: 4 Mar 2011 15:00:00
Message: <web.4d7144417ce2fcf27f98f9e70@news.povray.org>
Jim Holsenback <jho### [at] povrayorg> wrote:
> Here's the deal I'll work on the narrative but I'd like some one to come
> up with a scene file that would make experimentation a bit more user
> friendly.
....
> I'd like something that would allow just changing the Pattern/Type
> values and have the color_map automatically generated.

Hey Jim, here's my take on it.

It reproduces the example you posted, and is flexible enough for all tile types.
Some of the extra options might be removed to shorten the code...

// Code

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

#declare TilingPattern = 22;
#declare TileTypes = 3;

// for seeing how many colors we need
#declare ColorMap  = on;

// make final color black, probably not needed
#declare BlackAtTileType = true;

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

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

// ~Code

It's a little messy, but it works. I think I captured the spirit of what you
were looking for...

Sam


Post a reply to this message

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