Linda, I wasn't tight, though I might be this evening
as it's my birthday...
Well, I tried to generalise as soon as I saw your code,
and that's when I got into difficulty. But I've just
realised that the factor 0.5 needed to be taken into
account too. See changes sketched out below.
With your code, I find the fourth corner is X + Y - O.
This won't work properly for all choices of colours for
three corners of each faces. It's ok with your choices:
|: 13 : '+/_1 1 1 *>>y' every FRONT;LEFT;TOP;BACK;RIGHT;BASE
1 0 0 0 1 1
1 1 1 0 0 0
0 1 0 0 0 0
If for example a face had three corners as White;Green;Blue,
you'd get
13 : '+/_1 1 1 *>>y' W;G;B
_1 0 0
It still "works", but not properly - try C =: W just before V = ...
I now think your earlier not-working problem might be
that you redefine the global C; it starts off as cyan but
becomes the result of face each. Your faces are already
defined so it shouldn't really be a problem, but who
knows...
Try the following variants, with the rest of your code
unchanged;
30 cube '' is pleasing!
cube=: 3 :0
3 cube y
:
c =. x
plan=:4 3$V,FRONT,V,LEFT,TOP,V,V,BACK,RIGHT,V,BASE,V
paint=:,/,/>,"_1 each/"1 c face each plan
paint viewmat i.4 3*c
)
face=: 3 :0
3 face y
:
ic =. (i.%<:) x NB. ==> 0 1/(n-1) 2/(n-1)... 1
'O X Y'=.y
NB. removed redundant "1 ...
brush=.<.255*O+"1(ic*/Y-O)+"1/ic*/X-O
)
Any help?
Mike
On 27/07/2015 06:30, Linda Alvord wrote:
You were tight - I got in trouble trying to generalize to mor squares. An it
almost works. The size seems ok, but I can't get the colors to work.
load 'viewmat'
'E B G C R M Y W'=:#:i.8
V=:<E;E;E
FRONT=:<M;R;W
LEFT=:<M;W;B
TOP=:<W;Y;C
BACK=:<C;G;B
RIGHT=:<G;Y;E
BASE=:<B;E;M
face=: 3 :0
'O X Y'=.y
brush=.D=: <.255*O+"1]0.5*((i.N)*/Y-"1 O)+"1/(i.N)*/X-"1 O
)
cube=: 3 :0
N=:y
plan=:4 3$V,FRONT,V,LEFT,TOP,V,V,BACK,RIGHT,V,BASE,V
paint=:,/,/>,"_1 each/"1 C=:face each plan
paint viewmat i.N*4 3
)
cube 5
Linda
-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Mike Day
Sent: Sunday, July 26, 2015 4:47 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Trouble making patter for a color cube
This variant (some way below here) worked ok for me on Friday when you
(Linda) first posted it.
Have you tried clear'' and (re)load? (Always works!)
I was a bit puzzled by your hard-wiring of 3 (as in i.3) - is it just a
coincidence that colours are also defined in triples?
Mike
On 26/07/2015 21:28, Linda Alvord wrote:
Raul, could you please check this code again. It doesn't seem to work
at all anymore. Thanks.
Linda
-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Raul
Miller
Sent: Friday, July 24, 2015 12:51 PM
To: Programming forum <programm...@jsoftware.com>
Subject: Re: [Jprogramming] Trouble making patter for a color cube
That looks plausible.
The colors in the middles of the squares are interesting.
The top middle square's center color might be something of an "indian
red".
The middle of the square below that might be an "aquamarine".
The color in the middle on the left side might be a "medium purple".
The color in the middle on the right side might be an "olive drab"
The color in the middle to its right might be a "turquoise".
The color in the middle of the bottom square is probably a "purple"?
Or at least, those are the best I can come up with, for names.
Thanks,
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm