May 04, 2012

Color statement and color codes

The color statement is used to change the color of the text or graphics.
COLOR <Color code>

where , 

Color-code = the number that sets the color.


The number that sets the color are as follows-

 Color                                 Color code

      1                                                              Dark blue
      2                                                              Dark green
      3                                                              Dark cyan
      4                                                              Dark red
     5                                                               Dark magenta
     6                                                                Magenta
     7                                                                White
     8                                                                Grey
     9                                                               Light blue
   10                                                               Light green
   11                                                               Light cyan 
   12                                                               Light red
   13                                                               Light magenta
   14                                                               Yellow 
   15                                                              Bright white                                                                                                        

Screen modes

You may have got the doubt of the statement 'SCREEN X' in my commands.Normally,  Q basic is in default the screen 0, which is text mode. The other screens from  1 to 13 are in increasing resolution as follows-


          Screen 0                      -                  80*25 -Text mode only
          Screen 1                      -                  320*200 -graphics
          Screen 2                      -                  640*200 -graphics
          Screen 7                      -                  320*200 -graphics
          Screen 8                      -                  640*200 -graphics
          Screen 9                      -                  640*350 -graphics
          Screen 10                    -                  640*350 -graphics
          Screen 12                    -                  640*480 -graphics
          Screen 13                    -                  320*200 -graphics 


Screen statement- 
                SCREEN < MODE >
   where, 
 MODE = the number that sets the screen mode

March 19, 2012

Finding a square root of a number

Normally, you may had come across situations in which you may have to find square roots of some 10 digit numbers.The syntax of finding a square root -
                                                    SQR ( N )
where,
         N = the number of which you need to find the square root.

Example-
1)  Finding square root of 25
      CLS
      PRINT SQR (25)
      END

  Rejoice !!!
  You can also find square roots of non-square numbers upto four decimal digits.

March 07, 2012

Drawing a circle

Let's learn how to draw a circle and arcs-
              First of all, don't forget to type " Screen 9" because normally Q basic is in default screen 1 in which figures cannot be drawn.

The syntax for drawing a circle or an arc-
                     CIRCLE ( X, Y ) , R , C , SA , EA
where,
         ( X , Y ) =  the coordinate of the center of the circle.
         R           =  the radius of the circle
         C           =  the colour code which is optional
         SA         =  the starting angle if you want to draw an arc
         EA         = the ending angle of the arc

Examples-
1. Drawing a circle-
                         CLS
                        SCREEN  9
                        CIRCLE  ( 60 , 60 ), 20 , 9
                        END
This draws a circle with radius 20 pixels at the pixel pointed (60,60)  in blue.

               Don't just draw circles, try concentric circles, intersecting circles and complex figures and pictures using circle and line commands.

Drawing a Line

Today, let's learn to draw a line -

        Before all , remember that you have to type "SCREEN 9" in the type area of Q basic.
The syntax of the command to draw a line-
                 LINE  ( X1 , Y1 ) - ( X2 , Y2 ), C , ( B , (F))
Where,
      ( X1 , Y1 ) = the coordinate of the starting point of line
      ( X2 , Y2 ) = the coordinate of the ending point of line
       C = the color code
       B and BF = used to draw an empty or filled rectangle respectively in which ( X1 , Y1)-( X2, Y2) specify diagonally opposite corners.

   X1, X2 represent the column number
   Y1, Y2 represent the row number.

Examples-
     1.  Drawing a line-
                   CLS
                   SCREEN 9
                   LINE (10,10)-(100,100), 9
                   END
            This draws a line from the pixel pointed 10,10 to the pixel pointed 100,100 in blue.  

               Don't just draw a line and feel happy seeing it.
               Try complex figures and matrixes.