Mainly for Linda. I've just had a go at running my code under JHS, in Google Chrome. (I mention that since the choice of browser might perhaps have an effect on graphics.) Once I'd worked out how to load a script file, it worked fine.
Raul's remarks about 4x3 arrays etc related to the layout of the six faces, aka the "net". They do not concern the aspect ratio of graphics for squares/faces. The Cross pattern that you've (Linda) been using fits in 4x3; 6 elements correspond to the 6 faces and 6 correspond to filler. All but one of the other 10 layouts also fit in 4x3, (or 3x4, trivially); the remaining one needs a 5x2 or 2x5 array. If 0 represents filler, and 1 represents a face, this last net may be regarded as (eg) 2 5 $ 0 0 1 1 1 1 1 1 0 0 . Perhaps the non-square appearance of faces in some approaches (Raul's? mine?) is a side-effect of your browser. Mike On 26/06/2015 06:43, Linda Alvord wrote:
Raul, After I wrote this message I looked again at your result in JHS and I apologize. I have been looking at little squares of color so long that I sometimes see rectangles! I keep holding back from giving up on blending colors, and am slow to tackle your approach, but Mike Day seems to be enjoying it. Linda -----Original Message----- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda Alvord Sent: Thursday, June 25, 2015 9:28 PM To: programm...@jsoftware.com Subject: Re: [Jprogramming] Trouble making patter for a color cube In jqt the image is in an adjustable container which can be stretched until all colors are squares. In JHS the advantage I that my pattern is all squared. I can cut and paste it into word and then print additional text with the actual images. Have you looked at your code in JHS? Linda -----Original Message----- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Raul Miller Sent: Thursday, June 25, 2015 9:14 PM To: Programming forum Subject: Re: [Jprogramming] Trouble making patter for a color cube When I use jqt, the squares of color are square. I am not sure why they changed to non-square rectangles for you. Thanks, -- Raul On Thu, Jun 25, 2015 at 9:11 PM, Linda Alvord <lindaalv...@verizon.net> wrote:I put the pattern in a 4x4 matrix because I use JHS a lot and then the squares of color are not rectangles like they were in jqt and yourexample.Linda -----Original Message----- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Raul Miller Sent: Thursday, June 25, 2015 6:33 PM To: Programming forum Subject: Re: [Jprogramming] Trouble making patter for a color cube http://www.abdulbaki.org/Unfolding_A_Cube.html has 10 ways of unfolding a cube which fit in a 4x3 (or 3x4) array. (And an 11th which does not.) -- Raul On Thu, Jun 25, 2015 at 11:30 AM, Mike Day <mike_liz....@tiscali.co.uk> wrote:I'm not sure I made it clear that I'd assumed each of BLACK BLUE ... etc is a numerical triple, ie 0 0 0 for BLACK, 1 1 1 for WHITE. So this line should have appeared: 'BLACK BLUE GREEN CYAN RED MAGENTA YELLOW WHITE'=:#:i.8 Apologies also for using lower case for "blank" in the definition ofplan;I'd forgotten it was a defined global in my workspace. Here's a slightly modified definition of mycube, with localisation of the nouns "plan" and "colours": mycube=: 3 : 0 : nsteps =. 2 >. <: x 'A B C D H G F E' =. y BLANK =. < BLACK;BLACK;BLACK;BLACK FRONT =. < A;B;C;D BACK =. < H;G;F;E TOP =. < E;F;B;A LEFT =. < H;E;A;D RIGHT =. < F;G;C;B BASE =. < D;C;G;H plan =. BASE(<3 1)}FRONT(<2 1)}(LEFT,TOP,RIGHT)1}BACK(<0 1)}4 3$BLANK colours =. ,/,/>,"_1 each/"1 nsteps mysquarecolours each plan colours viewmat i.($plan)*nsteps+1 ) It occurs to me that one could specify alternative "nets" to represent the cube. You've chosen a cross, but you can also have a T, and more generally, the left and right faces can roll anywhere up and down their sides; and of course, we can tip the whole thing on its side, or roll the base around to the left of left or the right of right.... I suppose the net-shape could be an optional left argument for a dyadic "cube" verb, probably easiest to have an arbitrary enumeration of the net-shapes. I don't often use JHS, having got used to JQT. My problem with sending messages seems to be a recent feature of my Thunderbird installation. I hope that helps. and hope that the code works for you. If it does, then have a look at this and be very amazed! .... 30 mycube BLACK,BLUE,WHITE,GREEN,RED,YELLOW,CYAN,:MAGENTA Mike On 25/06/2015 09:14, Linda Alvord wrote:Mike, I'm sorry you are having such a problem with the messages. I have found that if I run a working program in JHS and then copy the scriptandpaste in an email, I can eliminate typing errors in the code. Then intheemail you can write comments around it and not need NB. all the time. I got your code entered and it ran with no errors. However I tried Mycube '' and got no result. I'll look at it some more. Linda -----Original Message----- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Mike Day Sent: Thursday, June 25, 2015 3:18 AM To: programm...@jsoftware.com Subject: Re: [Jprogramming] Trouble making patter for a color cube I'm still not sure the following got sent yesterday, so here's a fourth attempt. Sorry about the double-line-spacing, M On 24/06/2015 15:46, Mike Day wrote:I've just had a look at the correspondence. It seems to me that it's better to consider the 8 corners of the cube. If we specify their colours, then we merely need to interpolate the colours along the edges and within the faces. Here's an attempt to do that, plagiarising blatantly from Raul's earlier postings. Over to Linda to render the code in basic J. The 8 corners may indeed use the 8 colours in #:i.8, but don't need to do so, and may use 8 triples of any numbers in [0.0,1.0]. The code follows below, with some comments, and apologies for line-wraps, line-skips or whatever. Also apologies for any typos in this patter, Mike NB. revision of Raul's colour-mixing verb, with 4 corner colours rather than 3 NB. given corner colours ABCD (4x3 array), and x>1 steps from A to B etc NB. make an (x+1)x(x+1)x3 array of mixed colours NB. assumes input colours are in [0,1], but output in [0,255] msc=:mysquarecolours =: 3 : 0 : nsteps =. x 'A B C D' =. y lamda =. (,:~-.)@:(%~ i.@>:) nsteps AB =. lamda +/@:(*/"1) A,:B NB. mix of colours between corners A & B CD =. lamda +/@:(*/"1) D,:C NB. mix of colours between corners C & D 1 0 2 |: <.255 * lamda +/@:(*/"1) AB,:CD NB. transpose 'cos I got the order wrong! ) NB. Cube layout: A-H label the corners; NB. (looked ok in the edit window, added ... to NB. force spacing!!!) NB. ..H-G NB. ..|+| NB. H-E-F-G sides are AB,BC,...,BF,EA,...FG,GH NB. |+|+|+| faces are ABCD, DCGH, ... HGFE NB. D-A-B-C NB. ..|+| NB. ..D-C NB. ..|+| NB. ..H-G NB. verb to draw the plan NB. lhs = number of steps = %: number of facets on a face NB. rhs = 8 x 3 array of corner colours in range [0,1] mycube=: 3 : 0 : nsteps =. 2 >. <: x 'A B C D H G F E' =. y BLANK =. < BLACK;BLACK;BLACK;BLACK FRONT =. < A;B;C;D BACK =. < H;G;F;E TOP =. < E;F;B;A LEFT =. < H;E;A;D RIGHT =. < F;G;C;B BASE =. < D;C;G;H plan =: BASE(<3 1)}FRONT(<2 1)}(LEFT,TOP,RIGHT)1}BACK(<0 1)}4 3$blank colours =: ,/,/>,"_1 each/"1 nsteps mysquarecolours each plan colours viewmat i.4 3*nsteps+1 ) NB. sample call using all colours in #:i.8 NB. 4 mycube BLACK,BLUE,WHITE,GREEN,RED,YELLOW,CYAN,:MAGENTA NB. The colours don't have to be all distinct NB. 3 mycube BLACK,BLUE,WHITE,GREEN,RED,YELLOW,BLUE,:BLACK On 24/06/2015 07:18, Raul Miller wrote: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 notcorrect.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...
--- 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