Chapter 11 153
Using HP Instrument BASIC
Displaying Graphics
11. Using HP Instrument
2. Chapter Title 3. Chapter Title
4. Chapter Title
5. Chapter Title
BASIC
Hard copy
You can produce hard copy output of graphics by use of the printing feature. Press the
START key located under the [Copy] key.
Default setting
The default setting when the power is turned on is as follows.
• MOVE 0,0
A sample graphics program
Here follows a simple example to draw a line on the graphics screen.
Drawing a straight line
The program below draws a straight line from the point (50, 200) to another (300, 200).
GCLEAR ! Initializes the graphics screen.
MOVE 50,200 ! Moves the pen to the point (50, 200).
DRAW 300,200 ! Draws a straight line to the point (300, 200).
END
Drawing a circle
Here follows an example of sub-program for drawing a circle. Giving coordinates of the
center and a radius to this sub-programs as arguments allows you to draw a circle.
Changing the start value and the end value of the parameter Theta in this sub-program
allows you to draw a circular arc too.
SUB Drawcircle(Centx,Centy,R) !
DEG ! Uses "°" has the unit of agnle.
X=Centx+R !
Y=Centy !
MOVE X,Y ! Moves the pen to the start point.
For Theta=1 to 360 !
X=INT(COS(Theta)*R+Centx) ! Calculates the x coordinate of a
point on the circle
Y=INT(SIN(Theta)*R+Centy) ! Calculates the y coordinate of a
point on the circle.
DRAW X,Y ! Draws a line to the point (X, Y)
NEXT Theta !
SUBEND !