06 March 2022

Pentagram - as an 8-bit scalable vector

When you want to summon a demon, but he demon is fussy about the precision of your pentagram! 😉  Drawing an inverted pentagram on a ZX Sprectrum as a scalable vector 'graphic' using the PLOT and DRAW commands. The idea is to denote the centre of the pentagram / circle as x, y co-ordinates (in pixels) represented with the variables x and y, and the radius (also in pixels) and represented with the variable r. Changing the x, y starting position and/or the radius (r) will redraw the pentagram according to the new values. To do this, each point on the pentagram, and hence each line can be represented as vectors.

If x and y are the centre of the cricle, the the first starting point, i.e., the bottom point of the pentagram can be stated as x, y-r, this is the first point to be PLOTted. Each subsequent move along the x axis (minus for left, plus for right) and y axis (minus for down, plus for up) can be measured and then shown by its relationship to the length of the radius (i.e., the number it is either multiplied or divided by to be the same as the radius). This will result in scaling the lateral and vertical DRAW x,y points along with the radius.

If we take the radius to be 50px, then the first movement is 29px left and 90px up. Therefore;

-29/r => -29/50 = -0.58 => -0.58r
90/r => 90/50 = 0.555' => r/0.555'

So the first DRAWn x, y co-ordinates are;  -0.58r, r/0.555'

The same method is then repeated for a further four times for each side / point of the pentagram. 

Left: The starting point (bottom of pentagram) and fixe x, y co-ordinates for each subsequent line / point of the pentagram. 
Right: The same implemented in BASIC on the ZX Spectrum 128k (Fuse Emulator) 


The additional circle, 1105 CIRCLE x,y,r+(r/6) draws an additional (scalable) circle outside the pentagram with a diameter one sixth longer than the inner circle. The above code, when run will display the pentagram (right) along with the inner and outer circles. The calculations are certainly NOT super accurate, it was worked out with graph paper, a protractor, compass and ruler but it's close enough for the low resolution graphics of an 8-bit computer. Note: negating all the numbers above (with the exception of the starting x co-ordinate) will result in a graphic of a non-inverted pentagram. The basic graphic can be used in other functions, loops etc. to create different effects.