Skip to content
[~]drawing-functions.md: updated box() authored by cactusfluo's avatar cactusfluo
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
- [line](#line) - [line](#line)
- [set_line_char](#set_line_char) - [set_line_char](#set_line_char)
- [line_func](#line_func) - [line_func](#line_func)
- [Rectangle](#rectangle) - [Box](#box)
- [rect](#rect) - [box](#box)
- [set_rect_border](#set_rect_border) - [set_box_border](#set_box_border)
- [set_rect_mode](#set_rect_mode) - [set_box_mode](#set_box_mode)
- [Text](#text) - [Text](#text)
- [text](#text) - [text](#text)
- [set_text_mode](#set_text_mode) - [set_text_mode](#set_text_mode)
...@@ -122,80 +122,123 @@ function (x, y, is_on_layer) { ...@@ -122,80 +122,123 @@ function (x, y, is_on_layer) {
# Rectangle # Box
## rect ## box
```javascript ```javascript
> rect(x, y, width, height); > box(x, y, width, height);
> rect(x, y, width, height, border); > box(x, y, width, height, border);
``` ```
Draws a rectangle on the active layer. `x`, `y`, `width` and `height` are passed Draws a box on the active layer. `x`, `y`, `width` and `height` are passed to
to position and dimension the rectangle. A `border` string can be passed to position and dimension the box. A `border` string can be passed to style the
style the rectangle. Here is how the border string works: box. Here is how the border string works:
``` ```
with "012345678" with "012345678"
0: top-left corn 0: center
1: top side 1: vertical line
2: top-right corner 2: horizontal line
3: left side 3: top-left corner
4: center 4: top-right corner
5: right side 5: bottom-left corner
6: botton-left corner 6: bottom-right corner
7: bottom side 7: top + bottom + right intersection
8: bottom-right corner 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 The border string can also be set through `set_box_border()` (see
[set_rect_border()](#set_rect_border)). [set_box_border()](#set_box_border)).
By default, the top-left corner of the rectangle is placed at the passed By default, the top-left corner of the boxangle is placed at the passed
coordinates, but it can also be placed differently via `set_rect_mode()` (see coordinates, but it can also be placed differently via `set_box_mode()` (see
[set_rect_mode()](#set_rect_mode)). [set_box_mode()](#set_box_mode)).
### Parameters: ### Parameters:
- `x` Number: x coordinate of the rectangle - `x` Number: x coordinate of the box
- `y` Number: y coordinate of the rectangle - `y` Number: y coordinate of the box
- `width` Number: Width of the rectangle - `width` Number: Width of the box
- `height` Number: Height of the rectangle - `height` Number: Height of the box
- `border` String: String border of the rectangle - `border` String: String border of the box
## set_rect_border ## set_box_border
```javascript ```javascript
> set_rect_border(); > set_box_border();
> set_rect_border(characters); > set_box_border(characters);
``` ```
Sets the `rect()` border string. Next calls of `rect()` will automatically use Sets the `box()` border string. Next calls of `box()` will automatically use
this string if not passed into `rect()` itself. 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. string to it's default value.
## Parameter: ### Parameter:
- `characters` String: String border of `rect()` - `characters` String: String border of `box()`
## set_rect_mode ## set_box_mode
```javascript ```javascript
> set_rect_mode(); > set_box_mode();
> set_rect_mode(mode); > set_box_mode(mode);
``` ```
Sets the `rect()` placement mode. By default, the top-left corner of the drawn Sets the `box()` placement mode. By default, the top-left corner of the drawn
rectangle is placed at the passed cordinates. box is placed at the passed cordinates.
Calling `set_rect_rect()` without any parameter resets the `rect()` border Calling `set_box_mode()` without any parameter resets the `box()` placement
string to it's default value. mode to it's default value.
### Parameter: ### Parameter:
- `mode` Mode: Mode of `rect()` - `mode` Mode: Mode of `box()`
### Modes: ### Modes:
- `RECT_CORNER` Default value, passed coordinates are used for the top-left corner. - `BOX_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_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 # Text
... ...
......