Plotting the right changes Mark Jarrard brings the Spectrum to life with a point-by-point graphic display Fed up with all those stationary graphics? Want a little animation, easily? Well, this is it. All you have to do is type in the program as given, plot the points for a few pictures, and let the program do the rest. The idea can be seen clearly in diagrams one to four. The pentagon in the first diagram consists of five points, labelled 1 to 5, which are joined in sequence. In other words: point 1 is joined to point 2; point 2 is joined to point 3; and so on until point 5 is joined to point 1. The fourth diagram consists of the same points, joined in the same way, but in different positions. Give the program the start and end positions of each point, and tell it which points are joined. The program will then transform the points from the first picture to form the second, with real-time motion on the screen. Diagrams two and three show a couple of the steps in the transformation from the penta- gon into the pentangle. In reality, you specify how many steps the transformation will take, so you can produce smooth on-screen motion. The program can be typed in and run as listed. The shape data included from line 860 will spell out SINCLAIR. It does that by plotting a shape resembling an 'S', then transforming it into an 'I', and so on. When it reaches the end of the sequence it loops around to start again. The program will keep looping through the shapes, but if you want to stop it after a complete cycle, change line 830 to a STOP. Having plotted each shape - not the transfor- mations between shapes - the program waits for a moment so that you can see it. If you don't want that, then just delete line 810. Having tried out the demonstration shape data, you are probably itching to experiment with your own shapes. First you have to plot the shapes you want to draw. That is best done on a piece of graph paper. But notice that the program uses a slightly different coordinate system than you would normally expect on a Spectrum. To make the machine code calculations a little easier, the origin is placed at the top-left of the screen - diagram five. Next, the data can be entered, in the following order. First, the number of steps to transform from one shape to the next. If the number of steps is large, the coordinate change from one point to the next is likely to include fractions. In this program, those have been rounded to the nearest integer, and that can cause a small jerk in the picture when it reaches its target shape. There are two ways of avoiding that, the first being to adapt the routines to handle floating point numbers. An easier method is to ensure that the coordinate changes for every point are divisible by a particular number. In the data given in the program, all the coordinates are multi- ples of 10, and the number of steps is set to 11 - that is, the first shape and 10 steps. Second, the next two figures should be the number of points, followed by the number of lines. In the example data, those are both the same. Including more points than lines would be pointless(!) but there is no reason why each of, say, four points should not be joined to all the rest, giving six lines. There is also no reason for all the points to be joined into a circular sequence - the middle 'hole' in the 'A' and the 'R' show that quite nicely, being three points sepa- rated from the rest. Those are normally plotted at location (0,0) and brought onto the main screen when needed. That has a tendency to plot a small dot in the top left hand corner, but you can easily avoid that by plotting the points entirely off the screen. If you need a large number of points for one shape, but fewer for other shapes, simply hide some of the points along the lines joining the points in the new shape. Those will show up as tiny dots where the machine code performs OVER 1 plotting. That has been done in the demonstration data, because 16 points are needed for shapes such as 'S' and 'C' but far fewer for 'L'. Then comes the number of shapes in the sequence - nothing complicated here. The point coordinates themselves take up the most room. If we label the shapes s1,s2,s3,... and the coordinates (x1,y1),(x2,y2),(x3,y3),..., then the coordinates of the third point in the first shape would be s1(x3,y3). Based upon that notation, the data should be as follows: s1(x1,y1), s2(x1,y1), s3(x1,y1), ..., sn(x1,y1); s1(x2,y2), s2(x2,y2), s3(x2,y2), ..., sn(x2,y2); and so on until s1(xp,yp), s2(xp,yp), s3(xp,yp), ..., sn(xp,yp); where 'n' is the number of shapes and 'p' is the number of points. Finally comes the data to inform the program which points are connected. It is not necessary to have the first point connected to the second, the second to the third, and so on, as long as the number of line data items is twice the number of lines given. One further note, the points are listed as: point 0 to point (number of points-1) and not point 1 to point (number of points). This sort of program is limited only by your imagination. A company title could suddenly transform into the company logo at the start of a title page, large wire-frame ani- mation could be produced to show simple movies, or you could simply use it to draw pretty pictures. The more tech- nically minded will no doubt want to alter and improve the program. One improvement which has already been mentioned is to implement floating-point arithmetic to ensure greater accuracy when transforming one picture to the next. Another alteration which may appeal to some is to imple- ment 'line transformation'. The routine described here produces 'point transformations', in that each point travels in a straight line to its new destination. With line transformation, all the lines are of the same length in each shape. To move a line, its mid-point travels in a direct line to the mid-point in the new shape, and the gradient changes as it goes. That has the effect of moving the points from one shape to the next in an arc. That is somewhat akin to the Channel 4 symbol, where all the lines remain the same length, and spin into their correct positions. [ Diagrams 1-4 can't be reasonably drawn in ASCII art. Picture Transformation.png contains them all. Diagram 5 was simply: ] ################################################# ################################################# ###(0,0) (255,0)### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###(0,191) (255,191)### ################################################# #################################################