Write a program to draw a black colour line in QBASIC?
Answers
Answer:
In computer graphics, a line is made by setting many adjacent pixels to the same color. You could draw a line by using the PSET statement many times. But there is an easier way. To draw a line of pixels all of the same color use the LINE statement:
LINE (startX, startY)-(endX, endY)
This statement:
Uses the current pen color.
Sets all the pixels along a line starting at (startX, startY) and ending at (endX, endY)
If a pixel along the line has already been set, it is set to the current pen color.
Here is a program that does the same as the previous program, except using a LINE statement:
' Setting 10 pixels in row 3
' to color 4 (Red)
'
SCREEN 12
COLOR 4
LINE (1, 3) - (10, 3) ' draw a line from (1,3) to (16,3)
END
The program is much shorter than the one that uses PSET. The picture on the graphics screen will look like this (slightly enlarged):
Explanation:
Answer: