How do you explain that RIGHT works correctly? Look at the palette, RIGHT.

   load 'viewmat'
   N=:<.63.8*i.5
   BLUE=:(2#"1,.(4#0),N),.N,4#255
   MAGENTA=:2 0 2{"1 BLUE
   CYAN=:0 2 2{"1 BLUE
   RIGHT=:R=:25 3$,P=:(8 7 6 5 4{CYAN)+"1/(8 7 6 5 4){MAGENTA
   RIGHT
510 510 510
510 446 510
510 382 510
510 318 510
510 255 510
446 510 510
446 446 510
446 382 510
446 318 510
446 255 510
382 510 510
382 446 510
382 382 510
382 318 510
382 255 510
318 510 510
318 446 510
318 382 510
318 318 510
318 255 510
255 510 510
255 446 510
255 382 510
255 318 510
255 255 510
   
This image works with "improper" colors.

   RIGHT viewmat A=:i.5 5

Linda


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Wednesday, June 24, 2015 2:18 AM
To: Programming forum
Subject: Re: [Jprogramming] Trouble making patter for a color cube

A color, for viewmat, the way you are using it, is a sequence of three
integers in the range 0 .. 255.

The problem is that none of the sequences in FRONT nor BASE are valid
colors.

This problem is made more confusing because while BLACK and WHITE are single
valued "colors", the others range from black to white with the named color
appearing in the middle. And then you're using just parts of those
sequences. The grammar may be "simple" but the abstractions are not.

So... there are several problems to fix here, but the biggest problem is
that your results are not valid colors. If I subtract 255 from each of the
values you have there, they are better, but still not correct.

Anyways, if I look at the adjacent squares, FRONT should have:

at index 0 (upper left corner):  255 0 0 at index 4 (upper right corner):
255 0 255 at index 20 (lower left corner):  255 255 0 at index 24 (lower
right corner): 255 255 255

 Similarly, BASE should have:

at index 0: 255 255 0
at index 4: 255 255 255
at index 20: 0 255 0
at index 24: 0 255 255

Instead, you have this:

    0 4 20 24{ FRONT -255
255 255 255
255   0 255
255 255   0
255   0   0
    0 4 20 24{ BASE -255
255 255 255
255 255   0
  0 255 255
  0 255   0

Hopefully this helps...

--
Raul

On Wed, Jun 24, 2015 at 1:37 AM, Linda Alvord <[email protected]>
wrote:
> Here's a pattern for a color cube. It still has an error in the FRONT 
> and the BASE. It will look better if that ever gets resolved. It is in
simple J.
>
> load 'viewmat'
> N=:<.63.8*i.5
> BLACK=:25 3$0
> BLUE=:(2#"1,.(4#0),N),.N,4#255
> RED=:2 0 1{"1 BLUE
> MAGENTA=:2 0 2{"1 BLUE
> GREEN=:0 2 1{"1 BLUE
> CYAN=:0 2 2{"1 BLUE
> YELLOW=:2 2 0{"1 BLUE
> WHITE=:25 3$255
> A=:i.5 5
> B=:5 5$0
>
> BACK=:25 3$,><"1 (0 1 2 3 4{GREEN)+"1/(0 1 2 3 4){BLUE BACK viewmat A
>
> TOP=:U=:25 3$,(0 1 2 3 4{RED)+"1/(0 1 2 3 4){BLUE TOP viewmat A;'TOP'
>
> LEFT=:25 3$,(0 1 2 3 4{GREEN)+"1/(0 1 2 3 4){RED LEFT viewmat A
>
> RIGHT=:R=:25 3$,P=:(8 7 6 5 4{CYAN)+"1/(8 7 6 5 4){MAGENTA RIGHT 
> viewmat A
>
> FRONT=:S=:25 3$,Q=:(8 7 6 5 4{YELLOW)+"1/(8 7 6 5 4){MAGENTA FRONT 
> viewmat A
>
> BASE=:25 3$,(8 7 6 5 4{CYAN)+"1/(8 7 6 5 4){YELLOW BASE viewmat A
>
> WOW=:(B,.(|.A),.B,.B),((|:|.25+A),.(50+A),.(|:|.|:|.75+A),.B)
> WOW=:WOW,(B,.(|.|:|.100+A),.B,.B),B,.(125+A),.B,.B
> (BACK,LEFT,TOP,RIGHT,FRONT,BASE) viewmat WOW
>
> Linda
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Linda 
> Alvord
> Sent: Sunday, June 14, 2015 8:52 PM
> To: [email protected]
> Subject: Re: [Jprogramming] Trouble making patter for a color cube
>
> Wow! It works in jgt also.  I expected 6 or 7 separate images. That's 
> exciting.
>
> Linda
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Linda 
> Alvord
> Sent: Sunday, June 14, 2015 8:41 PM
> To: [email protected]
> Subject: Re: [Jprogramming] Trouble making patter for a color cube
>
> This is exactly where I was heading! It is quite beautiful and should
"fold"
> into a cube.
>
> I'd like to get it done "my way" and then I'll study yours and see 
> what will work best for beginners.  I'm hoping it will interst young 
> children to "build" it themselves.
>
> Thank you!  Linda
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Raul 
> Miller
> Sent: Sunday, June 14, 2015 10:14 AM
> To: Programming forum
> Subject: Re: [Jprogramming] Trouble making patter for a color cube
>
> My apologies.
>
> I left out the color definition line. (Brian Schott emailed me a note 
> about this, privately.)
>
> Here's what I think you need:
>
> 'BLACK BLUE GREEN CYAN RED MAGENTA YELLOW WHITE'=:#:i.8
>
> 'BLANK'=: <BLACK;BLACK;BLACK
> 'BACK'=:  <GREEN;CYAN;BLACK
> 'LEFT'=:  <GREEN;BLACK;YELLOW
> 'TOP'=:   <BLACK;BLUE;RED
> 'RIGHT'=: <BLUE;CYAN;MAGENTA
> 'FRONT'=: <RED;MAGENTA;YELLOW
> 'BASE'=:  <YELLOW;WHITE;GREEN
>
> squarecolor=:3 :0
>   'O X Y'=. y
>   colors=. <.255*O+"1]0.25*((i.5)*/Y-"1 O)+"1/(i.5)*/X-"1 O
> )
>
> require'viewmat'
> cube=:3 :0
>   plan=: BASE(<3 1)}FRONT(<2 1)}(LEFT,TOP,RIGHT)1}BACK(<0 1)}4 3$BLANK
>   colors=:  ,/,/>,"_1 each/"1 squarecolor each plan
>   colors viewmat i.20 15
> )
>
> cube''
>
> And, once you have that, you may want to do something like this:
>
>    setsize_jviewmat_ 750 1000
>    savemat_jviewmat_ jpath '~user/color-cube-page.png'
>
> Thanks,
>
> --
> Raul
>
> On Sun, Jun 14, 2015 at 2:01 AM, Linda Alvord 
> <[email protected]>
> wrote:
>> This time I get an error after a large image of color stripes from 
>> red to blue.
>>
>> cube''
>> |value error: BLACK
>> |       colors viewmat i.20 15
>>
>> I'm not sure how to fix it.
>>
>> Linda
>>
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Raul 
>> Miller
>> Sent: Saturday, June 13, 2015 10:00 AM
>> To: Programming forum
>> Subject: Re: [Jprogramming] Trouble making patter for a color cube
>>
>> Ok, fair enough.
>>
>> New plan:
>>
>> TOP=:<,.'TOP';<2 2$;:'BLACK BLUE RED MAGENTA'
>> BACK=:<,.'BACK';<2 2$;:'GREEN CYAN BLACK BLUE'
>> FRONT=:<,.'FRONT';<2 2$;:'RED MAGENTA YELLOW WHITE'
>> BASE=:<,.'BASE';<2 2$;:'YELLOW WHITE GREEN CYAN'
>> LEFT=:<,.'LEFT';<2 2$;:'GREEN BLACK RED YELLOW'
>> RIGHT=:<,.'RIGHT';<2 2$;:'BLUE CYAN MAGENTA WHITE'
>>    BASE(<3 1)}FRONT(<2 1)}(LEFT,TOP,RIGHT)1}BACK(<0 1)}4 3$a:
>>
>> Implementation:
>>
>> 'BLANK'=: <BLACK;BLACK;BLACK
>> 'BACK'=:  <GREEN;CYAN;BLACK
>> 'LEFT'=:  <GREEN;BLACK;YELLOW
>> 'TOP'=:   <BLACK;BLUE;RED
>> 'RIGHT'=: <BLUE;CYAN;MAGENTA
>> 'FRONT'=: <RED;MAGENTA;YELLOW
>> 'BASE'=:  <YELLOW;WHITE;GREEN
>>
>> squarecolor=:3 :0
>>   'O X Y'=. y
>>   colors=. <.255*O+"1]0.25*((i.5)*/Y-"1 O)+"1/(i.5)*/X-"1 O
>> )
>>
>> cube=:3 :0
>>   plan=: BASE(<3 1)}FRONT(<2 1)}(LEFT,TOP,RIGHT)1}BACK(<0 1)}4 3$BLANK
>>   ref=.  ((75*i.4)+/5*i.3) +each <i.5 5
>>   colors=.  ,/,/>,"_1 each/"1 squarecolor each plan
>>   colors viewmat i.20 15
>> )
>>
>> cube''
>>
>> Technically, I didn't need to quote my color names, but I decided to 
>> leave the quotes in as emphasis (or, perhaps more accurately, to give 
>> some style to those particular names).
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Sat, Jun 13, 2015 at 5:11 AM, Linda Alvord 
>> <[email protected]>
>> wrote:
>>> Raul, I can see that a plan is useful. If you think of Black as no
light.
>>> Now build three axes. Blue is to the right (0 to 255). Red is 
>>> forward
>> toward
>>> you. And green moves up from the base. So
>>>
>>> I like your floor plan, Now LEFT and RIGHT are not oriented correctly.
>>>
>>> Try your code in JHS. There you can just place the images where you 
>>> want them.
>>>
>>> Linda
>>>
>>> -----Original Message-----
>>> From: [email protected]
>>> [mailto:[email protected]] On Behalf Of Linda
>> Alvord
>>> Sent: Saturday, June 13, 2015 4:40 AM
>>> To: [email protected]
>>> Subject: Re: [Jprogramming] Trouble making patter for a color cube
>>>
>>> Also, when I ran your code in jqt, I separated the  separate images 
>>> and
>> they
>>> work together.  However they are a horizontal flip of your layout 
>>> for the pieces.  Linda
>>>
>>> -----Original Message-----
>>> From: [email protected]
>>> [mailto:[email protected]] On Behalf Of Linda
>> Alvord
>>> Sent: Saturday, June 13, 2015 4:25 AM
>>> To: [email protected]
>>> Subject: Re: [Jprogramming] Trouble making patter for a color cube
>>>
>>> Raul, I got an error after you layout appeared.  Now that I removed 
>>> that line, I got your six images. They are correct Now put them into 
>>> your
>> layout
>>> pattern so that the correct colors are joined. And make one big 
>>> image with the correct sides joined.
>>>
>>> It still bothers me that two of the faces in my work aren't correct.
>>> Now
>> on
>>> to study your strategy.  Linda
>>>
>>> -----Original Message-----
>>> From: [email protected]
>>> [mailto:[email protected]] On Behalf Of Linda
>> Alvord
>>> Sent: Saturday, June 13, 2015 3:21 AM
>>> To: [email protected]
>>> Subject: Re: [Jprogramming] Trouble making patter for a color cube
>>>
>>> This a "Color Cube. It should print in color. And then you cut it 
>>> out and fold it up and you have a little cube with pretty colors 
>>> that will show
>> you
>>> lots of things about how light makescolors. Myc cube will only have
>>> 125 colors, but it becomes infinite in your imagination.
>>>
>>> However, I will give some thought to what you sent. This is why the 
>>> forum
>> is
>>> such fun. Each person tackles a problem in a different way.
>>>
>>> Linda
>>>
>>> -----Original Message-----
>>> From: [email protected]
>>> [mailto:[email protected]] On Behalf Of Raul 
>>> Miller
>>> Sent: Saturday, June 13, 2015 1:00 AM
>>> To: Programming forum
>>> Subject: Re: [Jprogramming] Trouble making patter for a color cube
>>>
>>> I got a lot of squares running your script, and the one that I 
>>> really
>> liked
>>> was the one that was labeled 'TOP'. So I'll base my implementation 
>>> on that one.
>>>
>>> For something as complicated as this, I think I'd like to sketch out 
>>> first how it's supposed to look.
>>>
>>> So here's my first sketch:
>>> (<'BASE')(<3 1)}(<'FRONT')(<2 1)}(;:'LEFT TOP RIGHT')1}(<'BACK')(<0
>>> 1)}4
>>> 3$a:
>>>
>>> (beware line wrap - that's supposed to be a single line).
>>>
>>> But I also need to think about colors. After a little fiddling, I 
>>> decided
>> to
>>> go with this:
>>>
>>> TOP=:<,.'TOP';<2 2$;:'BLACK BLUE RED MAGENTA'
>>> BACK=:<,.'BACK';<2 2$;:'GREEN CYAN BLACK BLUE'
>>> FRONT=:<,.'FRONT';<2 2$;:'RED MAGENTA YELLOW WHITE'
>>> BASE=:<,.'BASE';<2 2$;:'YELLOW WHITE GREEN CYAN'
>>> LEFT=:<,.'LEFT';<2 2$;:'BLACK RED GREEN YELLOW'
>>> RIGHT=:<,.'RIGHT';<2 2$;:'MAGENTA BLUE WHITE CYAN'
>>>    BASE(<3 1)}FRONT(<2 1)}(LEFT,TOP,RIGHT)1}BACK(<0 1)}4 3$a:
>>>
>>> with that out of the way, all I need is a routine to render squares, 
>>> the rest of the code almost writes itself:
>>>
>>> 'BLACK BLUE GREEN CYAN RED MAGENTA YELLOW WHITE'=:#:i.8
>>>
>>> square=:4 :0
>>>   'O X Y'=. y
>>>   colors=. <.255*O+"1,/0.25*((i.5)*/Y-"1 O)+"1/(i.5)*/X-"1 O
>>>   colors viewmat (i.5 5);x
>>> )
>>>
>>> 'BACK' square GREEN;CYAN;BLACK
>>> 'LEFT' square BLACK;RED;GREEN
>>> 'TOP' square BLACK;BLUE;RED
>>> 'RIGHT' square MAGENTA;BLUE;WHITE
>>> 'FRONT' square RED;MAGENTA;YELLOW
>>> 'BASE' square YELLOW;WHITE;GREEN
>>>
>>> Good enough?
>>>
>>> Thanks,
>>>
>>> --
>>> Raul
>>>
>>>
>>> On Sat, Jun 13, 2015 at 12:04 AM, Linda Alvord 
>>> <[email protected]>
>>> wrote:
>>>> I am planning to begin a review of J Tech Grade 3 before 
>>>> introducing some new topics in Grade 4. I am making a pattern which 
>>>> could be printed and
>>> then
>>>> folded to form a color cube. It requires three dimensions for the 
>>>> three colors of light, Green, Red and  Blue.  I have the colors 
>>>> following the order of counting to 8 in base 2. The columns in the 
>>>> binary array
>>> represent
>>>> Green, Red and then Blue. This insures that the falues are in order 
>>>> from dark to light.
>>>>
>>>>
>>>>
>>>> The pattern must have six sides. All went well with the first 4 
>>>> sides, However the final two sides don't cooperate. I suspect there 
>>>> is some
>>> little
>>>> problem in viewmat. Here is my progress so far. The front and the 
>>>> bottom
>>> are
>>>> the problems. They both involve YELLOW.
>>>>
>>>>
>>>>
>>>> As is usual I welcome ways you may know to improve what I am trying 
>>>> to
>> do.
>>> I
>>>> suggest using JHS to see how this is progressing.
>>>>
>>>>
>>>>
>>>> load 'viewmat'
>>>>
>>>> N=:<.63.8*i.5
>>>>
>>>> BLACK=:9 3$0
>>>>
>>>> BLUE=:(2#"1,.(4#0),N),.N,4#255
>>>>
>>>> RED=:(N,4#255),.2#"1,.(4#0),N
>>>>
>>>> MAGENTA=:(N,4#255),.((4#0),N),.N,4#255
>>>>
>>>> GREEN=:((4#0),N),.(N,4#255),.(4#0),N
>>>>
>>>> CYAN=:((4#0),N),.2#"1 ,.N,4#255
>>>>
>>>> YELLOW=:(2#"1 ,.N,4#255) ,.(4#0),N
>>>>
>>>> WHITE=:9 3$255
>>>>
>>>> (#:i.8);'BLACK','BLUE','RED','MAGENTA','GREEN','CYAN','YELLOW',:'WHITE'
>>>>
>>>>
>>>>
>>>> A=:<.0.5*(i.5 5)+i.5 5
>>>>
>>>>
>>>>
>>>> BLANK=:25 3$255
>>>>
>>>> BACK=:25 3$,><"1 (0 1 2 3 4{GREEN)+"1/(0 1 2 3 4){BLUE
>>>>
>>>> BACK viewmat A
>>>>
>>>> (BACK,BLANK)viewmat (25+A),.|.A
>>>>
>>>>
>>>>
>>>> TOP=:25 3$,><"1 (0 1 2 3 4{RED)+"1/(0 1 2 3 4){BLUE
>>>>
>>>> TOP viewmat A;'TOP'
>>>>
>>>> LEFT=:25 3$,><"1 (0 1 2 3 4{GREEN)+"1/(0 1 2 3 4){RED
>>>>
>>>> LEFT viewmat A
>>>>
>>>> (TOP,LEFT) viewmat (25+|:|.A),.A
>>>>
>>>>
>>>>
>>>> ((TOP,LEFT) viewmat (25+|:|.A),.A),.(BACK,BLANK)viewmat (25+A),.|.A
>>>>
>>>>
>>>>
>>>> RIGHT=:R=:25 3$,><"1 P=:(8 7 6 5 4{CYAN)+"1/(8 7 6 5 4){MAGENTA
>>>>
>>>> RIGHT viewmat A
>>>>
>>>>
>>>>
>>>> FRONT=:S=:25 3$,><"1 Q=:(8 7 6 5 4{YELLOW)+"1/(8 7 6 5 4){MAGENTA
>>>>
>>>> FRONT viewmat A
>>>>
>>>>
>>>>
>>>> BOTTOM=:25 3$,><"1 (8 7 6 5 4{CYAN)+"1/(8 7 6 5 4){YELLOW
>>>>
>>>> BOTTOM viewmat A
>>>>
>>>>
>>>>
>>>> R;S
>>>>
>>>>
>>>>
>>>> I included R;S to show how close the good and the bad faces are 
>>>> prior to using viewmat.
>>>>
>>>>
>>>>
>>>> Linda
>>>>
>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> -
>>>> -- For information about J forums see 
>>>> http://www.jsoftware.com/forums.htm
>>> --------------------------------------------------------------------
>>> -
>>> - For information about J forums see 
>>> http://www.jsoftware.com/forums.htm
>>>
>>> --------------------------------------------------------------------
>>> -
>>> - For information about J forums see 
>>> http://www.jsoftware.com/forums.htm
>>>
>>> --------------------------------------------------------------------
>>> -
>>> - For information about J forums see 
>>> http://www.jsoftware.com/forums.htm
>>>
>>> --------------------------------------------------------------------
>>> -
>>> - For information about J forums see 
>>> http://www.jsoftware.com/forums.htm
>>>
>>> --------------------------------------------------------------------
>>> -
>>> - For information about J forums see 
>>> http://www.jsoftware.com/forums.htm
>> ---------------------------------------------------------------------
>> - For information about J forums see 
>> http://www.jsoftware.com/forums.htm
>>
>> ---------------------------------------------------------------------
>> - For information about J forums see 
>> http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to