Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Changes
Page history
[~]drawing-functions.md: updated box()
authored
Mar 16, 2020
by
cactusfluo
Show whitespace changes
Inline
Side-by-side
api/drawing-functions.md
View page @
6e368e66
...
...
@@ -12,10 +12,10 @@
-
[
line
](
#line
)
-
[
set_line_char
](
#set_line_char
)
-
[
line_func
](
#line_func
)
-
[
Rectangle
](
#rectangle
)
-
[
rect
](
#rect
)
-
[
set_
rect
_border
](
#set_
rect
_border
)
-
[
set_
rect
_mode
](
#set_
rect
_mode
)
-
[
Box
](
#box
)
-
[
box
](
#box
)
-
[
set_
box
_border
](
#set_
box
_border
)
-
[
set_
box
_mode
](
#set_
box
_mode
)
-
[
Text
](
#text
)
-
[
text
](
#text
)
-
[
set_text_mode
](
#set_text_mode
)
...
...
@@ -122,80 +122,123 @@ function (x, y, is_on_layer) {
#
Rectangle
#
Box
##
rect
##
box
```
javascript
>
rect
(
x
,
y
,
width
,
height
);
>
rect
(
x
,
y
,
width
,
height
,
border
);
>
box
(
x
,
y
,
width
,
height
);
>
box
(
x
,
y
,
width
,
height
,
border
);
```
Draws a
rectangle
on the active layer.
`x`
,
`y`
,
`width`
and
`height`
are passed
to
position and dimension the
rectangle
. A
`border`
string can be passed to
style the rectangle
. Here is how the border string works:
Draws a
box
on the active layer.
`x`
,
`y`
,
`width`
and
`height`
are passed
to
position and dimension the
box
. A
`border`
string can be passed to
style the
box
. Here is how the border string works:
```
with "012345678"
0: top-left corn
1: top side
2: top-right corner
3: left side
4: center
5: right side
6: botton-left corner
7: bottom side
8: bottom-right corner
0: center
1: vertical line
2: horizontal line
3: top-left corner
4: top-right corner
5: bottom-left corner
6: bottom-right corner
7: top + bottom + right intersection
8: top + bottom + left intersection
9: left + right + top intersection
10: left + right + bottom intersection
11: left + right + top + bottom intersection
```
The border string can also be set through
`set_
rect
_border()`
(see
[
set_
rect
_border()
](
#set_
rect
_border
)
).
By default, the top-left corner of the
rect
angle is placed at the passed
coordinates, but it can also be placed differently via
`set_
rect
_mode()`
(see
[
set_
rect
_mode()
](
#set_
rect
_mode
)
).
The border string can also be set through
`set_
box
_border()`
(see
[
set_
box
_border()
](
#set_
box
_border
)
).
By default, the top-left corner of the
box
angle is placed at the passed
coordinates, but it can also be placed differently via
`set_
box
_mode()`
(see
[
set_
box
_mode()
](
#set_
box
_mode
)
).
### Parameters:
-
`x`
Number: x coordinate of the
rectangle
-
`y`
Number: y coordinate of the
rectangle
-
`width`
Number: Width of the
rectangle
-
`height`
Number: Height of the
rectangle
-
`border`
String: String border of the
rectangle
-
`x`
Number: x coordinate of the
box
-
`y`
Number: y coordinate of the
box
-
`width`
Number: Width of the
box
-
`height`
Number: Height of the
box
-
`border`
String: String border of the
box
## set_
rect
_border
## set_
box
_border
```
javascript
>
set_
rect
_border
();
>
set_
rect
_border
(
characters
);
>
set_
box
_border
();
>
set_
box
_border
(
characters
);
```
Sets the
`
rect
()`
border string. Next calls of
`
rect
()`
will automatically use
this string if not passed into
`
rect
()`
itself.
Sets the
`
box
()`
border string. Next calls of
`
box
()`
will automatically use
this string if not passed into
`
box
()`
itself.
Calling
`set_
rect
_border()`
without any parameter resets the
`
rect
()`
border
Calling
`set_
box
_border()`
without any parameter resets the
`
box
()`
border
string to it's default value.
## Parameter:
-
`characters`
String: String border of
`
rect
()`
##
#
Parameter:
-
`characters`
String: String border of
`
box
()`
## set_
rect
_mode
## set_
box
_mode
```
javascript
>
set_
rect
_mode
();
>
set_
rect
_mode
(
mode
);
>
set_
box
_mode
();
>
set_
box
_mode
(
mode
);
```
Sets the
`
rect
()`
placement mode. By default, the top-left corner of the drawn
rectangle
is placed at the passed cordinates.
Sets the
`
box
()`
placement mode. By default, the top-left corner of the drawn
box
is placed at the passed cordinates.
Calling
`set_
rect_rect
()`
without any parameter resets the
`
rect()`
border
string
to it's default value.
Calling
`set_
box_mode
()`
without any parameter resets the
`
box()`
placement
mode
to it's default value.
### Parameter:
-
`mode`
Mode: Mode of
`
rect
()`
-
`mode`
Mode: Mode of
`
box
()`
### Modes:
-
`RECT_CORNER`
Default value, passed coordinates are used for the top-left corner.
-
`RECT_CENTER`
Passed coordinates are used for the center of the rectangle.
-
`BOX_CORNER`
Default value, passed coordinates are used for the top-left corner.
-
`BOX_CENTER`
Passed coordinates are used for the center of the box.
## set_box_alpha
```
javascript
>
set_box_alpha
();
>
set_box_alpha
(
mode
);
```
Sets the
`box()`
alpha mode. By default, empty areas (defined by space
character) of the box will not cover up the active layer. To make the empty
areas cover up the active layer, use the
`BOX_COVER`
mode.
Calling
`set_box_alpha()`
without any parameter resets the
`box()`
alpha mode to
it's default value.
### Parameter:
-
`mode`
Mode: Alpha mode of
`box()`
### Modes:
-
`BOX_TRANSPARENT`
Default value, box's empty areas will not cover up background
-
`BOX_COVER`
Empty areas will cover up background
## set_box_intersection
```
javascript
>
set_box_intersection
();
>
set_box_intersection
(
mode
);
```
Set the
`box()`
intersection behavior. By default, boxes are drawn covering
previous ones without any intersection computing. To use intersection computing,
use the
`BOX_INTERSECTION`
mode.
Calling
`set_box_intersection()`
without any parameter resets the
`box()`
intersection mode to it's default value.
### Parameter:
-
`mode`
Mode: Intersection mode of
`box()`
### Modes:
-
`BOX_HOVER`
Default value, no intersection is computed
-
`BOX_INTERSECTION`
Intersections betweens boxes are computed
# Text
...
...
...
...