BS2 CodingHelp DRAW
From FSG Wiki
Contents |
Draw Command
The draw function is used in conjunction with many other sub-functions like RECT, CIRCLE, FILLEDRECT, LINE, and more. There are many of them. It also uses some parameters, but they changes depending on the sub-functions. Let's see how to call the DRAW command:
Syntax:
DRAW element subfunctions
Draw Sub-Functions
In all following examples I will use the element earth as the element parameters. It will be shown as ELEMENT:Earth
All X and Y coordinate will be based on cursor position. Cursor position in BS2 are X,Y.
POINT
Syntax:
DRAW ELEMENT:Earth POINT X Y
RECT, FILLEDRECT
Syntax:
DRAW ELEMENT:Earth RECT X Y WIDTH HEIGHT DRAW ELEMENT:Earth FILLEDRECT X Y WIDTH HEIGHT
REPLACEFILLEDRECT
Just a little note for this function, until alpha 3 its included with BS2. It was not before. Syntax:
DRAW ELEMENT:Earth REPLACEFILLEDRECT 'X Y WIDTH HEIGHT REPLACE_ELEMENT
The REPLACE_ELEMENT correspond to an element you want to replace by earth (in this example).
So if i want to replace the Clear by Earth, i would just replace REPLACE_ELEMENT by ELEMENT:Clear
CIRCLE, FILLEDCIRCLE, RANDOMFILLEDCIRCLE
Syntax:
DRAW ELEMENT:Earth CIRCLE X Y RADIUS DRAW ELEMENT:Earth FILLEDCIRCLE X Y RADIUS DRAW ELEMENT:Earth RANDOMFILLEDCIRCLE X Y RADIUS RATE
REPLACEFILLEDCIRCLE
Syntax:
DRAW ELEMENT:Earth FILLEDCIRCLE X Y RADIUS REPLACE_ELEMENT
Again this is the same as REPLACEFILLEDRECT but for a filled circle.
LINE, REPLACELINE
Syntax:
DRAW ELEMENT:Earth LINE X Y DX DY DRAW ELEMENT:Earth LINE X Y DX DY REPLACE_ELEMENT
Ok here the DX,DY parameters need a little explanation. You can go here for a visual explication.
Basically the DX,DY are the distance from the starting point.
So let's say X=100 Y=100 DX=10 DY=-10.
This mean that the line will start at 100,100 and end at 110,90.
Why 110,90 because it like drawing a line from X Y (X + DX) (Y + DY).
Since (X + DX) is (100 + 10) then the result is 110.
Since (Y + DY) is (100 + -10) then the result is 90.
This is how we get a line from 100,100 to 110,90.
FILL
Syntax:
DRAW ELEMENT:Earth FILL X Y DX DY
This work the same way as the LINE function except it will fill anything it cross with the choosen element (Earth).
ROTATE
Syntax:
DRAW 0 ROTATE X Y WIDTH HEIGHT 1 DRAW 0 ROTATE X Y WIDTH HEIGHT -1
First the 0, is because we dont really need an element here, as it will rotate anything in given coordinate.
Then the first line is to rotate clockwise (1) and the second line to rotate counterclockwise (-1).
* Note that this will work only with square, not with rectangle.
COPYRECT
Syntax:
DRAW 0 COPYRECT X Y WIDTH HEIGHT ToX ToY
Again the 0 mean we dont need to send an element, but there must be one so put at least 0 or any element.
Copyrect work like a rect, so first 4 parameters work the same.
ToX,ToY correspond to where you want to copy the RECT. It will copy the rect you selected starting at those coordinate.
COPYSTAMP, PASTSTAMP
This work almost the same way as the COPYRECT except that instead of copying the rect to a coordinate on the screen, it copy the rect to the memory, and you give it an ID to be able to PASTE where you want, when you need.
Syntax:
DRAW 0 COPYSTAMP X Y WIDTH HEIGHT STAMPID DRAW 0 PASTESTAMP X Y WIDTH HEIGHT STAMPID
Same as above for the 0. The STAMPID is a number you give to your stamp so you can paste it after.
SWAPPOINTS
Syntax:
DRAW 0 SWAPPOINTS X1 Y1 X2 Y2
This will, like it say, swap two points. So X1,Y1 are the first point, X2,Y2 is the second point. What are at both coordinate will be exchanged with the other.
So if you have Earth at the fist coordinate and TNT at the second coordinate, after the function is executed you will have TNT at first coordinate and Earth at second coodinate.
