A downloadable project

The Great Wave

==============

entry for Schau category, Basic 10-liner 2026.

BBC Basic, should work on any BBC Micro.


Program size

============

Line count and longest line character count.

; wc -lL wave/wave.bas

       9     102 wave/wave.bas


Description

===========

I did a series of bbcmicrobot toots like this of famous artworks.

Hokusai's The Great Wave off Kanagawa has always been a favourite.

Benoit Mandelbrot frequently cited it as being an example of fractals in art (eg in The Fractal Geometry of Nature) however no-one seemed to have followed up and tried to generate it; fractals can often be coded compactly so are good candidates for coding challenges.

I've made a few versions of this; the one I posted to bbcmicrobot has fewer iterations to fit in a 30s runtime, so was less detailed.

MODE1:VDU19,1,4,0,0,0,5:GCOL48,0

The VDU 19 command here switches the 3 colour palette to black,blue,yellow,white.

GCOL48,0 sets the foreground to be a yellow-blue grid fill, softening the strident yellow.

MOVE1280,1024:PLOT&65,0,800:PLOT&65,220,580:MOVE950,550:PLOT&99,300,0

MOVE1000,650:PLOT&99,380,0:MOVE950,495:MOVE835,285:PLOT&AB,230,0:PLOT87,950,400

I block out the shape of the sky using geometric shapes. The shape of Mt. Fuji is left black.

GCOL16,0:PLOT&85,0,0

The sea is then easily done with a flood fill. I use a blue-yellow grid to soften this a bit.

GCOL0,3:FORI=1TO20:MOVE950,400:DRAW860+8*I,330-RND(1)*20:NEXT

To suggest snow on the mountain, I sketch in some white lines.

Only the y coordinaate is random so the snow stretches side to side.

MOVE550,200:MOVE620,930:PLOT&AD,-100,340

The top of the wave, a broad white section of a circle.

FORJ=0TO200:A=620:B=930:C=0:D=480:IFJ AND1MOVERND(1000),RND(800):PLOT&99,RND(4),0

A common way of shrinking programs is to repurpose loops. Here I'm drawing a random small circle each time I draw part of the wave, giving the impression of flecks of foam in the air, a detail from the original.

FORI=0TO6:K=RND(3):X=C-A:Y=D-B:P=A-Y*.3:Q=B+X*.3:R=A+X*.4:S=B+Y*.4

MOVEC,D:DRAWR,S:DRAWP,Q:PLOT85,A,B:IFK=1:C=P:D=Q

IFK=2:A=P:B=Q:C=R:D=S

IFK=3:A=R:B=S

NEXT,

And now the fractal. It's a variation on a Koch snowflake. With L-system fractals instead of finding all the points and connecting them, a low-memory technique is just to apply the rules at random; with enough iterations and depth the whole fractal appears. In this case, I start with lines like _/\ and expand each into a smaller set of lines with the same shape, and so on. When developing this I applied the targetimage as a semi-transparent overlay and chose parameters that best resembled that image.

Download

Download
wave.bas 546 bytes
Download
wave.ssd 200 kB
Download
wave.txt 3.7 kB

Install instructions

Instructions

============

Emulator for example at https://bbc.xania.org

Go to the Discs menu, choose From examples or local, upload the ssd.

Type:

LOAD "PROGRAM"

LIST

RUN

You can also more conveniently open it in owlet:

https://bbcmic.ro/#%7B%22v%22%3A1%2C%22program%22%3A%22MODE1%3AVDU19%2C1%2C4%2C0...

And click the play button. In either case, the program takes around 70 seconds to complete.

Comments

Log in with itch.io to leave a comment.

very good