fff00000ff00fe0080555000a7f ^7*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF ^3 T R I G S C R E E N E F F E C T S ^2 An Insight By Paul Townsend ^7*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF ^4 So you want to know how to produce those Sin and Cos generated ^4effects that keep appearing from Technical Fred Software. This short ^4introduction should give you an idea on how to get started. I get ^4the impression that many people seem to have a fear of using Sin and ^4Cos in their programs (Trigophobia ?), this is not too suprising ^4really as their seems to be very little explanation of what they ^4really do, so here I am to try to make sense of it all. ^2 First Steps ^5 When you run my programs that use Sin and Cos, if you look carefully ^5then you will realize that most of the effects are based upon the ^5circle, or multiple circles interacting with each other. The reason ^5for this is that I use Sin and Cos to produce circles, with is what ^5they are good at (They probably have many other uses, but I haven't ^5found any that are interesting enough to bother about). ^2 The Theory ^4 The circle can be split up into 360 points which can be imagined to ^4be positioned, equally spaced around the circumference. So if you ^4start at any place on the circumference and move 360 points in any ^4direction, you will end up back where you started from. ^5 What we need to know is how to work out where all these points are ^5so that we can do something at that particular point on the screen, ^5i.e plot a point, paste a bob etc. ^4 When typing in these examples, dont type in the <---- and comments ^4or the computer will spit them back at you, (You could use Rems if ^4you want, but I'm just too lazy !), Just type in the bits before them ^4and press RETURN ^5 The way to do this is to choose which points on the circle you want, ^5for our purposes we will just plot the entire circle, a program to do ^5this could be: ^7Screen Open 0,320,256,32,Lowres ^7Degree <----Tell the computer we want to work in degrees ^7For F=0 To 360 <----Set up a loop ^7X#=Sin(F) <----Work out the Co-ords ^7Y#=Cos(F) <---- " " " " " ^7Plot X#,Y# <----Plot the point ^7Next F <----Loop ? ^4If you try it, don't be surprised if you get nothing at all on ^4screen, the reason for this is that ^4 1) The co-ords are just off screen at the top left and ^4 2) the circle is only 1 pixel wide. ^5This calls for some minor changes to the above program :- ^4Firstly let's add the centre of the screen to the points plotted. ^7Screen Open 0,320,256,32,Lowres ^7Degree <----Tell the computer we want to work in degrees ^7For F=0 To 360 <----Set up a loop ^7X#=160+Sin(F) <----Work out the Co-ords ^7Y#=128+Cos(F) <---- " " " " " ^7Plot X#,Y# <----Plot the point ^7Next F <----Loop ? ^5 This program will appear to plot a point in the centre of the ^5screen, this is because the circle is still only 1 pixel wide, ^5therefore one final change is needed to get the circle to look like a ^5circle. ^7Screen Open 0,320,256,32,Lowres ^7Degree <----Tell the computer we want to work in degrees ^7For F=0 To 360 <----Set up a loop ^7X#=160+(100*Sin(F)) <----Work out the Co-ords ^7Y#=128+(100*Cos(F)) <---- " " " " " ^7Plot X#,Y# <----Plot the point ^7Next F <----Loop ? ^4 This program should now work, it should draw a circle that is 100 ^4pixels wide. (Why not try other numbers other than 100 for different ^4sizes of circles) ^5 Hopefully you should now have a circle on the screen, it may not ^5look much, but if you can understand why the circle is there, then ^5that is the first hurdle over with. ^4 OK, I think we should make this program a little more interesting, ^4what about making the circle appear to move. ^5The method I will use is a palette switch, try this, don't type in ^5the comments though ^7Screen Open 0,320,256,32,Lowres ^7Flash off <----Needed for Shift Up to work ^7Degree <----Tell the computer we want to work in degrees ^7For F=0 To 360 <----Set up a loop ^7Add rgb,1,1 to 31 ^7X#=160+(100*Sin(F)) <----Work out the Co-ords ^7Y#=128+(100*Cos(F)) <---- " " " " " ^7Plot X#,Y#,RGB <----Plot the point in the selected colour. ^7Next F <------Loop ? ^7Shift Up 2,1,31,1 <------set up a palette switch (or colour cycle) ^7Direct ^4 If you run this program you should have a revolving circle. ^5 You can now plot a circle, each point in a different colour, and ^5then to make it move. ^4 In the next part of this tutorial, we will try to use what we have ^4learned to produce some more interesting effects, but until then ^4please don't be afraid to experiment, try changing any of the numbers ^4in the above programs, just to see what happens. After all, that's ^4how all of the effects I have written in the past started off. (i.e. ^4see Screen Wipes in previous editions of TA) I just guess at a number ^4to change in a program run it and hope for the best. If the effect ^4looks good then I save the program, if not, I change it to something ^4else. (How's that for a structured approach to programming?) ^5 So until next time, have fun. If you have anything you would like ^5to see in these tutorials, why not drop a line to Totally Amos at the ^5usual address. ^3T T F N ^2Paul (Technical Fred) Townsend. ^7*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF*TF \