Groups | Search | Server Info | Login | Register
Groups > comp.sys.sinclair > #7214
| From | Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> |
|---|---|
| Newsgroups | comp.sys.sinclair |
| Subject | Re: Hitomezashi |
| Date | 2026-03-13 00:11 +1100 |
| Organization | A noiseless patient Spider |
| Message-ID | <ikqa8m-ra3.ln1@otis.foo> (permalink) |
| References | <01df7be931f55e89.balglaas@xs4all.nl> |
Groovy hepcat Jan van den Broek was jivin' in comp.sys.sinclair on Tue,
3 Mar 2026 08:09 am. It's a cool scene! Dig it.
> Seeing this video https://www.youtube.com/watch?v=JbfhzlMk2eY
Cool! I also looked at one of the linked articles
(https://www.tandfonline.com/doi/full/10.1080/17513472.2023.2187999),
which is quite interesting.
> about creating random hitomezashi-patterns inspired me to create this:
> http://balglaas.sdf.org/hitomezashi/hitomezashi.html
> but also to create this:
Please take the following critique in the manner in which it's
intended, as a constructive criticism.
> 10 REM Hitomezashi
Comments should be informative. They should explain what's going on.
For a program intro comment, maybe explain the purpose of the program.
> 20 LET l=5
> 30 LET w=240
> 40 LET h=150
> 50 RANDOMIZE
It is a good idea to clear the screen before drawing the pattern.
50 RANDOMIZE: CLS
> 60 REM === Border ========
Good! Separating logical parts of a program with comments is a good
idea. Also, maybe start these logical parts with "round number" line
numbers; perhaps on hundreds (100, 200, 300, etc.) or thousands (1000,
2000, 3000, etc.). It just helps separate the parts. It's not essential
though.
> 70 PLOT 0,0
> 80 DRAW w+l,0
> 90 DRAW 0,h+l
> 100 DRAW -(w+l),0
> 110 DRAW 0,-(h+l)
> 120 REM === Vertical ======
> 130 LET i=1
> 140 GO SUB 370
Calling a one line subroutine is wasteful. It'll slow the program
down. You may as well just put the RAND line here.
> 150 LET j=0
> 160 IF dp=0 THEN GO TO 190
> 170 PLOT l*i,l*j
> 180 DRAW 0,l
> 190 LET dp=1-dp
> 200 LET j=j+1
> 210 IF j*l<=h THEN GO TO 160
If you really want to use subroutines, a better candidate would be
lines 140 to 210.
Also, you should use a FOR loop instead of GO TO. For example
(untested and with new line numbers):
...
200 REM == Vertical lines. ==
210 FOR x=1 TO w STEP l
220 GO SUB 500
230 NEXT x
300 REM == Horizontal lines. ==
310 FOR y=1 TO h STEP l
320 GO SUB 600
330 NEXT y
...
500 REM == Do one vertical line. ==
510 LET dp=INT (2*RND)
520 FOR y=1 TO h STEP l
530 IF dp=0 THEN GO TO 560
540 PLOT l*x, l*y
550 DRAW 0, l
560 LET dp=1-dp
570 NEXT y
580 RETURN
600 REM == Do one horizontal line. ==
610 LET dp=INT (2*RND)
620 FOR x=1 TO w STEP l
630 IF dp=0 THEN GO TO 660
640 PLOT l*x, l*y
650 DRAW l, 0
660 LET dp=1-dp
670 NEXT x
680 RETURN
But this simple program doesn't really need subroutines at all. A
nested pair of FOR loops will suffice.
Also, notice how I've used more meaningful variable names, x and y
instead of i and j, to better indicate the intention.
> 220 LET i=i+1
> 230 IF i*l<=w THEN GO TO 140
> 240 REM === Horizontal ====
> 250 LET j=1
> 260 GO SUB 370
> 270 LET i=0
> 280 IF dp=0 THEN GO TO 310
> 290 PLOT l*i,l*j
> 300 DRAW l,0
> 310 LET dp=1-dp
> 320 LET i=i+1
> 330 IF i*l<=w THEN GO TO 280
> 340 LET j=j+1
> 350 IF j*l<=h THEN GO TO 260
> 360 STOP
> 370 REM === Startpunt =====
The above comment is basically pretty useless. It doesn't explain
what's going on nor help me understand the intent. It would better have
said "Randomiser" or something like that. Not that it makes much
difference in this case, since the single statement is pretty obvious.
But, as stated above, this whole subroutine is pointless anyhow.
> 380 LET dp=INT (2*RND)
> 390 RETURN
Suggestions for future extension/improvement of this program follow.
1) Write it in assembly. I tried a version in C, using the z88sdk
toolset, and it ran as slowly as the BASIC version. YIKES! Hand written
assembly would no doubt be faster.
2) Have a way to enter values to control the generated pattern,
instead of just a completely random sequence. The video showed a couple
of ways; using a written phrase or passage, with consonants and vowels
representing your binary values; and using some kind of numeric
sequence, like the digits of pi. Other methods could be found. The
article I've linked above suggests using ASCII values in a string, for
example. Or have the user enter a series of binary digits.
3) Instead of generating your bits on the fly as you're drawing the
pattern, you could pre-generate these bits and store them in an array.
This may even speed up the pattern generation. And you could redraw the
pattern any time just by using the same sequence. You could even save
the sequence to cassette to be loaded in at a later time.
4) The article discusses a number of traditional and new hitomezashi
patterns and how to generate them from predefined sequences of bits.
Selecting from these predefined patterns would be cool. Use arrays and
READ and DATA for this.
5) Allow the selection of paper and ink colours for your pattern.
White on blue is traditional, so you could make that the default,
maybe.
6) The article talks about "duality". Hitomezashi is a tradition of
fabric stitching, after all. For each pattern of stitches there is a
complementary pattern on the back of the fabric. You could, after
generating a pattern, generate its dual pattern (complement). You could
switch between the two with the press of a key.
7) A menu to select from various options would be nice. You could
change colours, select a predefined pattern, then when bored with that,
press a key to bring up the menu. Then select the option to generate a
new pattern from an entered string of binary digits, etc.
8) Save the pattern to cassette for future viewing. Or if you have a
printer attached to your speccy, make a hard copy.
9) Whatever else you can think of.
--
----- Dig the NEW and IMPROVED news sig!! -----
-------------- Shaggy was here! ---------------
Ain't I'm a dawg!!
Back to comp.sys.sinclair | Previous | Next — Previous in thread | Next in thread | Find similar
Hitomezashi balglaas@xs4all.nl (Jan van den Broek) - 2026-03-02 21:09 +0100
Re: Hitomezashi Damian Murphy <murf@the177project.org> - 2026-03-06 15:43 +0000
Re: Hitomezashi Jan van den Broek <balglaas@dds.nl> - 2026-03-07 16:02 +0000
Re: Hitomezashi Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> - 2026-03-13 00:11 +1100
Re: Hitomezashi Jan van den Broek <balglaas@dds.nl> - 2026-03-12 21:10 +0000
csiph-web