|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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))
#end
#end
.
When I run the code I get the messagePrese
"C:\Povray\Harmonograph\Harmonograph 12.pov" line 62: Parse Error:
Attempt to access uninitialized array element.
But I thought I had initialised it !!
I was planning to us the values in a colour map like this
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] >]
}
Any suggestions please
John
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I get that error all the time - I just fiddle with the code until I get it to
stop.
This works for me on 3.7 :
(note : I changed the range of k to 0 to 3)
###################################################
#declare R = seed(123);
#declare Col = array[7][4]
#for (j,0,6,1)
#for (k,0,3,1)
#declare Col[j][k] = int(2*rand(R));
#end
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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].
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
|
|