Let's continue talking about the other functions of graphics.
PSET/PRESET
The two commands are practically the same, they draw a point at the specified coordinate. The only difference between the two is that if the color code is omitted, the first, i.e. PSET, will use the foreground color, while the second uses the background color. As if to say one draws and the other erases. X and Y are the horizontal and vertical coordinates. We can only use them in graphic screens (SCREEN 2 and 3). If we enter values greater than the maximum size of the SCREEN, no error message will be displayed.
Syntax: PSET(X,Y)[,ColorCode]/PRESET(X,Y)[,ColorCode]
POINT
Returns the color code to the entered coordinates. If we want to know the color at a given point on the screen, we will write: A=POINT(X,Y). The variable A will store the color code that is at that particular point on the screen at that moment. It can't be used alone, plus it wouldn't make sense.
The MSX will not report an error if you exceed the limits of the screen, but its result will be incorrect. As mentioned above, the X and Y are the horizontal and vertical coordinates.
Syntax: VARIABLE=POINT(X,Y)
LINE
Draw a line or rectangle between the start and end coordinates.
To give an example, if we want to draw a diagonal line that takes up the entire screen, we would write: LINE(0,0)-(255,191),15. The point 0.0 is the first coordinate of the graphic screen, while 255.191 is the last. It will draw a line that
will cross the entire screen in white. Let's explain better, the 0.0 point is the starting point of the line, while the 255.191 is the arrival point. 15 is the color code we want to draw it with. If the latter is omitted, it will use the foreground color code from the COLOR command (if you remember, I said this in the last lesson). If instead of a straight line we want to draw a rectangle or square, just add the letter B after the color code. The LINE function will understand that it will have to draw a Box using the first data as the upper left vertex and the second as the lower right vertex: LINE(0,0)-(255,191),15,B.
If we want to color the rectangle we have drawn, just add the letter F after the B: LINE(0,0)-(255,191),15,BF, it will be colored using the same color. We can also continue drawing a picture from the previous point,
instead of using starting point, we will use STEP. Let's take an example by drawing a rhombus:
10 SCREEN 2: COLOR 1,15,15:CLS
20 LINE (50,50)-(75,75),6: LINE -(50,100),6
30 LINE -(25,75),6: LINE -(50,50),6
40 GOTO 40
Instead of the STEP statement I used the minus sign (-) which is the same thing.
One thing I forgot to mention at the beginning of the graphics lessons.
When working on graphical screens, at the end of the program it will return to
text mode, that's why I blocked the program at line 40, if I wouldn't have it
Once done, the program would exit without showing us the created design.
SYNTAX: LINE [STEP][(X1,Y1)]-(X2,Y2)[,ColorCode][,B[F]]
CIRCLE
Draw circles, ellipses and curved lines, using the point with X and Y coordinates and indicated radius as the center. In a nutshell: CIRCLE (X,Y), Radius, color. As mentioned above, if you omit the color it will use the foreground color. Also for command
CIRCLE we can use STEP. To make it clearer I will take the program written before adding the one mentioned above.
10 SCREEN 2: COLOR 1,15,15:CLS
20 LINE (50,50)-(75,75),6: LINE -(50,100),6
30 LINE -(25,75),6: LINE -(50,50),6
40 CIRCLE STEP(0,25),25,6
50 GOTO 50
Since the diamond uses 50 pixels per side and the last printed point is the top vertex, we told it to move 25 pixels down.
As we know a circle is composed of 360 degrees i.e. 2P Greek radians. Pgreco is equal to 3.14159, so 2Pgreco is 6.28318 radians. If we want to draw a curve just specify the start and end point. These two options come
insert immediately after the color code: CIRCLE(X,Y),Radius, Color, start, end.
We could do the calculation in 2 ways: degrees * radians (1 Radian=0.01745) or using Greek. For convenience I will use the second saying. To give an example, we want to draw the top of the circle: CIRCLE(100,100),30,1,0,3.14159.
Point 0 is the rightmost part of the circle, in fact it will trace from right to left, while the second which is 1Pgreco, will stop at the leftmost point of the circle, i.e. in the middle. If we want to draw the bottom part, just vary the 0 with 3.14159 and the 3.14159 with 0 or 6.28318 which is the same thing, since the end point is 2Pgreco is the starting point 0*Pgreco. There is one last option to complete the command; the report. If this is greater than 1, the circle will be elongated, i.e. high and narrow, if it is less than 1 it will be flattened, low and wide. If we want to omit some options that are before others, just enter the blank field. For example, we want to use Ratio by drawing a full circle:
CIRCLE (100,100),30,,,,.5. By doing so we have omitted the color and the starting and ending points of the ellipse. If we draw a circle larger than the screen there will be no error message, we will only see the part that falls within it.
Syntax: CIRCLE [STEP] (X,Y), Radius [,Color][, Start, End][,Ratio]
That's all for this lesson too. Next I will conclude the graphic part with the DRAW command also called GML (Graphic Macro Language), Paint and how to write on graphic screens, then we will start with the Sprites.
Thank you all and have a good weekend.


0 Comments