POV-Ray : Newsgroups : povray.newusers : Array coding problem : Re: Array coding problem Server Time
20 Apr 2024 02:37:05 EDT (-0400)
  Re: Array coding problem  
From: AQ
Date: 20 Sep 2016 15:53:55
Message: <2r43ubdf4g2jj2r4695m68knmfpjqko7tr@4ax.com>
On Tue, 20 Sep 2016 19:22:10 +0200, clipka <ano### [at] anonymousorg>
wrote:

>Am 20.09.2016 um 17:39 schrieb AQ:
>> I want to fill a 6 by 3 array with either a 0 or a 1 chosen at random
>> and then use these values in a colour map.  I thought it would be easy
>> but the code below gives an error and I cannot see why.  
>> 
>> #declare Col = array[7][4]
>> #for (j,0,6,1)
>>   #for (k,1,3,1)
>>     Col[j][k] = int(2*rand(R))
>
>You'll want to use
>
>    #declare Col[j][k] = int(2*rand(R))
>
>
>> colour_map {
>>               [0.0/6  rgb < Col[0,1], Col[0,2], Col[0,3] >]        
>>               [1.0/6  rgb < Col[1,1], Col[1,2], Col[1,3] >] 
>>               [2.0/6  rgb < Col[2,1], Col[2,2], Col[2,3] >] 
>>               [3.0/6  rgb < Col[3,1], Col[3,2], Col[3,3] >] 
>>               [4.0/6  rgb < Col[1,1], Col[4,2], Col[4,3] >] 
>>               [5.0/6  rgb < Col[5,1], Col[5,2], Col[5,3] >] 
>>               [6.0/6  rgb < Col[6,1], Col[6,2], Col[6,3] >]
>>             }
>
>You'll also want to replace Col[x,y] with Col[x][y].

Thank you for the help.

Now I have the code working I do not like the effect !!!!!  and will
probably go back to the hand coded colour map.  It was an interesting
exercise though.

John


Post a reply to this message

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