Along with few of my friends I started learning programming with a language called BASIC.It seems to be a very long long time from now.But that was fun..real & honest.That was one of the few things, like learning to play chess, algebra, geometry.. etc, whenever I remember about it I feel happy.Last week I came across the new version of Small Basic in a blog post, old memories sparked,I downloaded and started playing with it.
Small Basic is introduced by Microsoft to help people learn and enjoy programming.The first thing that drew my attention was it’s plain and minimalist IDE.
Next thing I liked is the Intellisense support.It’s plain simple and beautiful.
The language is also pretty straightforward and lucid without much frills.
- It does not have any explicit typing, you do not have to define any types for the variables.
- It support the basic array data structure.
- If-Else & Goto
- For & While Loops
- Ability to read & write from command line
- Shapes & GraphicsWindow object to support GUI based programming
- Events & Event Handler
I was not satisfied just by looking at the IDE and going through the specs.Some program had to be written.. like old days.But what would be that?
Currently I am reading “The Tao of Physics: An Exploration of the Parallels Between Modern Physics and Eastern Mysticism” by Fritjof Kapra.Here I had read about the Yin Yang symbol.The original meaning of the word is shady and sunny side of a mountain.But this is used in Chinese philosophy to symbolize the opposing forces of nature and their harmony or balance.Anyway’s let’s not get into these philosophical details.The Yin Yang symbol looks like:
So how to draw these in SmallBasic.We will do this by drawing three circles and filling them partly with black as shown below:
We will use the GraphicsWindow object to draw a circle as shown below:
Now I have to fill one part this circle with black.But Small Basic does not have any Arc or Semi Circle kind of object which I can fill with black.So I thought of filling out the area within one half of the circle with straight lines in black.To draw a straight line I need two points, here one will be on center of the circle and one on the circumference.XII standard coordinate geometry came to rescue.I computed the coordinates on the circumference using simple polar coordinates as shown below:
The circle now looks like:
Now I add two more smaller circles and one in the upper half of the outer circle is filled with white.
The shape now appears as:
Now the two smaller circles is added as shown below:
The finally the symbol appears to be all perfect: