POV-Ray : Newsgroups : povray.general : Hexagon pattern with 4 or 7 colors? : Re: Hexagon pattern with 4 or 7 colors? Server Time
28 Apr 2024 00:26:20 EDT (-0400)
  Re: Hexagon pattern with 4 or 7 colors?  
From: Bald Eagle
Date: 3 May 2018 22:20:01
Message: <web.5aebc2a897bd16015cafe28e0@news.povray.org>
But I'm catching up  :D

the scale and the warp need to be immediately after cells, and before the
texture map.

This is still half-baked, but I think you can see how I worked it out.
(when warp gave me an error, I had commented it out, and forgot / read past it)
:(

I still need to properly implement the infinite-thickness text-object function
pigment pattern....   (Say that 5 times fast)

#version 3.7;
global_settings {assumed_gamma 1.0}

#include "colors.inc"

sky_sphere {pigment {rgb <1, 1, 1>}}

camera {
   location <0, 20, 0>    // position & direction of view
  look_at  <0, 0, 0.01>
  right x*image_width/image_height           // horizontal size of view
  up y // vertical size of view
 }

light_source {<0, 25, -1> color White}

#declare Num = array [10];
#for (N, 0, 9)
 #declare Num[N] = text {ttf "arialbd.ttf" chr(48+N) 1, 0 translate <0, 0, -0.5>
scale <1, 1, 1e6>}
#end


#declare T = array [10];
#declare f_Text = array [10];

#for (N, 0, 9)
 #declare f_Text[N] = function {
  pigment {
   pigment_pattern {
    object {Num[N]} // 1, 0}
    warp {repeat x}
    warp {repeat y}
   }
  }
 }
 #declare Current = CHSV2RGB(<N*36, 1, 1>);
 #declare T[N] =
  pigment {
   pigment_pattern {
    object {Num[N]} // 1, 0}
    warp {repeat x}
    warp {repeat y}
   }
   pigment_map {
    [0.0 rgbft Current]
    //[0.9 rgbft Current]
    [1.0 rgb 0]
   }
  scale 0.15
  rotate x*90
  }

#end

#declare SIN60 = sin (radians(60));

/*
// This seems to work fine
box {<-1, 0.1, -1>*10, <1, 0.02, 1>*10
 texture { // #1
            cells
            scale <3, 1, 3*SIN60>
            warp {repeat z*3*SIN60 offset <1.5, 357.4, 0>}
            texture_map {
   #for (N, 0, 0.9, 0.1)
    [N     T[N*10] ]
    [N+0.1 T[N*10] ]
    //#debug concat ( " N = ", str (N, 3, 1),  " N+0.1 = ", str (N+0.1, 3, 1),
" N*10 = ", str (N*10, 3, 1), "\n")
   #end
  }
 }


}
*/


#declare T_Clear = texture {pigment {rgbt 1}}
#declare Texture1 = texture { // #1
   cells
   scale <3, 1, 3*SIN60>
   warp {repeat 3*SIN60*z offset <1.5, 357.4, 0>}
   #declare ONE = on;
   #if (ONE)
    texture_map {
     #for (N, 0, 0.9, 0.1)
      [N     T[N*10] ]
      [N+0.1 T[N*10] ]
      //#debug concat ( " N = ", str (N, 3, 1),  " N+0.1 = ", str (N+0.1, 3, 1),
 " N*10 = ", str (N*10, 3, 1), "\n")
     #end
    }
   #else
    texture_map {
     #for (N, 0, 0.9, 0.1)
      [N     T_Clear ]
      [N+0.1 T_Clear ]
      //#debug concat ( " N = ", str (N, 3, 1),  " N+0.1 = ", str (N+0.1, 3, 1),
 " N*10 = ", str (N*10, 3, 1), "\n")
     #end
    }
   #end

   // the x-offset has to be 1.5, or can increase by
   // adding multiples of 3.0 -- 1.5, 4.5, 7.5 etc.

   translate <0, 0, (1.5*SIN60)>
  } // end texture #1

#declare Texture2 = texture { // #2
   cells
   scale <3, 1, (3*SIN60)>
   warp {repeat 3*SIN60*z offset <1.5, 194.7, 0>} // ditto
   #declare TWO = on;
   #if (TWO)
    texture_map {
     #for (N, 0, 0.9, 0.1)
      [N     T[N*10] ]
      [N+0.1 T[N*10] ]
      //#debug concat ( " N = ", str (N, 3, 1),  " N+0.1 = ", str (N+0.1, 3, 1),
 " N*10 = ", str (N*10, 3, 1), "\n")
     #end
    }
   #else
    texture_map {
     #for (N, 0, 0.9, 0.1)
      [N     T_Clear ]
      [N+0.1 T_Clear ]
      //#debug concat ( " N = ", str (N, 3, 1),  " N+0.1 = ", str (N+0.1, 3, 1),
 " N*10 = ", str (N*10, 3, 1), "\n")
     #end
    }
   #end

   translate <1.5, 0, 0>
  } // end texture #2

#declare Texture3 = texture { // #3
   cells
   scale <3, 1, (3*SIN60)>
   warp {repeat z*3*SIN60 offset <1.5, 73.5, 0>} //ditto
   #declare THREE = on;
   #if (THREE)
    texture_map {
     #for (N, 0, 0.9, 0.1)
      [N     T[N*10] ]
      [N+0.1 T[N*10] ]
      //#debug concat ( " N = ", str (N, 3, 1),  " N+0.1 = ", str (N+0.1, 3, 1),
 " N*10 = ", str (N*10, 3, 1), "\n")
     #end
    }
   #else
    texture_map {
     #for (N, 0, 0.9, 0.1)
      [N     T_Clear ]
      [N+0.1 T_Clear ]
      //#debug concat ( " N = ", str (N, 3, 1),  " N+0.1 = ", str (N+0.1, 3, 1),
 " N*10 = ", str (N*10, 3, 1), "\n")
     #end
    }
   #end

   translate <0, 0, -0.5>
  } // end texture #3


box {<-1, 0, -1>*10, <1, 0.01, 1>*10
 texture {
  //pigment{
  hexagon

  texture {Texture1}

  texture {Texture2}

  texture {Texture3}

  //}
  //finish {ambient .05 diffuse .95}
  //scale .2
 } // end hexagon texture
} // end box

box {<-1, -0.02, -1>*10, <1, -0.01, 1>*10 texture {Texture3}}




/*
box {<-1, 0, -1>*10, <1, 0.01, 1>*10
 pigment {hexagon
  color Black,
  color Gray50,
  color White
  //rotate x*90
 }
}

#declare A = sqrt(3);
#declare B = A/2;

//mod(A,B)
//Value of A modulo B. Returns the remainder after the integer division of A/B.
Formula is  mod=((A/B)-int(A/B))*B.

#for (Z, -10, 10)
 #for (X, -10, 10)
  sphere {<X*3, 0, Z*A> 0.25 pigment {Red}}
  #debug concat ( " mod(", str (X, 1, 0), "*3, 3) = ", str (mod(X*3, 3), 3, 3),
" mod(", str (Z, 1, 0), "*A, A) = ", str (mod(Z*A, A), 3, 3),  "\n")
 #end
#end

#for (Z, -5, 5)
 #for (X, -3, 2)
  sphere {<(X*3)+1.5, 0, (Z*A)+B> 0.25 pigment {Green}}
 #end
#end
*/


Post a reply to this message

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