[~]_sidebar.md: updated authored by cactusfluo's avatar cactusfluo
- base
- [Base](#base)
- [clear](#clear)
- [background](#background)
- line
- [Line](#line)
- [line](#line)
- [set_line_char](#set_line_char)
- [line_func](#line_func)
- rectangle
- [Rectangle](#rectangle)
- [rect](#rect)
- [set_rect_border](#set_rect_border)
- [set_rect_mode](#set_rect_mode)
- text
- [Text](#text)
- [text](#text)
- [set_text_mode](#set_text_mode)
- [set_text_align](#set_text_align)
- [set_text_wrap](#set_text_wrap)
- other
- [Other](#other)
- [shape](#shape)
- [fill](#fill)
- [border](#border)
- [set_draw_mode](#set_draw_mode)
# clear
# Base
## clear
```javascript
> clear();
> clear(layer);
```
Clear the passed layer by putting space characters at each cell. By default, the
cleared layer is the active layer.
## Parameter:
Clears the passed layer by putting space characters at each cell. By default,
the cleared layer is the active layer.
### Parameter:
- `layer` Layer: Layer to be cleared
# background
## background
```javascript
> background(character);
```
Put the passed charater at each cell of the active layer.
## Parameter:
- `character` String: String to be put at each layer cells
# line
Puts the passed charater at each cell of the active layer.
### Parameter:
- `character` Character (string): String to be put at each layer cells
# Line
## line
```javascript
> line(x0, y0, x1, y1);
> line(x0, y0, x1, y1, character);
```
Draw a line from `[x0, y0]` to `[x1, y1]` on the active layer with the passed
Draws a line from `[x0, y0]` to `[x1, y1]` on the active layer with the passed
character. If no character is passed, `line()` will use the set line character
(see [set_line_char](#set_line_char)).
## Parameters:
### Parameters:
- `x0` Number: x coordinate of the first point
- `y0` Number: y coordinate of the first point
- `x1` Number: x coordinate of the second point
- `y1` Number: y coordinate of the second point
- `character` String: Character to be put at each line point
- `character` Character (string): Character to be put at each line point
# set_line_char
## set_line_char
```javascript
> set_line_char();
> set_line_char(character);
```
Set the `line()` character. Next calls of `line()` will use this character if
Sets the `line()` character. Next calls of `line()` will use this character if
not passed into `line()` itself.
Calling `set_line_char()` without any parameter resets the `line()` character to
it's default value.
## Parameter:
- `character` String: Character to be set as default for lines
# line_func
### Parameter:
- `character` Character (string): Character to be set as default for lines
## line_func
```javascript
> line_func(x0, y0, x1, y1, function);
```
Call the passed function for each point of the line formed by `[x0, y0]` and
Calls the passed function for each point of the line formed by `[x0, y0]` and
`[x1, y1]`. The called function takes 3 parameters, `x` and `y` coordinates
of the current point and a boolean variable which is set to `true` when the
coordinates are inside the active layer.
......@@ -89,20 +106,26 @@ function (x, y, is_on_layer) {
}
}
```
## Parameters:
### Parameters:
- `x0` Number: x coordinate of the first point
- `y0` Number: y coordinate of the first point
- `x1` Number: x coordinate of the second point
- `y1` Number: y coordinate of the second point
- `function` Function: Function to be called at each line point
# rect
# Rectangle
## rect
```javascript
> rect(x, y, width, height);
> rect(x, y, width, height, border);
```
Draw a rectangle on the active layer. `x`, `y`, `width` and `height` are passed
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:
```
......@@ -122,114 +145,142 @@ The border string can also be set through `set_rect_border()` (see
By default, the top-left corner of the rectangle is placed at the passed
coordinates, but it can also be placed differently via `set_rect_mode()` (see
[set_rect_mode](#set_rect_mode)).
## Parameters:
### 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
# set_rect_border
## set_rect_border
```javascript
> set_rect_border();
> set_rect_border(characters);
```
Set the `rect()` border string. Next calls of `rect()` will automatically use
Sets the `rect()` border string. Next calls of `rect()` will automatically use
this string if not passed into `rect()` itself.
Calling `set_rect_border()` without any parameter resets the `rect()` border
string to it's default value.
# Parameter:
## Parameter:
- `characters` String: String border of `rect()`
# set_rect_mode
## set_rect_mode
```javascript
> set_rect_mode();
> set_rect_mode(mode);
```
Set the `rect()` placement mode. By default, the top-left corner of the drawn
Sets the `rect()` placement mode. By default, the top-left corner of the drawn
rectangle is placed at the passed cordinates.
Calling `set_rect_rect()` without any parameter resets the `rect()` border
string to it's default value.
## Parameter:
### Parameter:
- `mode` Mode: Mode of `rect()`
## Modes:
### 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.
# text
# Text
## text
```javascript
> text(string, x, y);
> text(string, x, y, paragraph_width);
```
Write the passed `string` on the active layer at [`x`, `y`] coordinates. A
Writes the passed `string` on the active layer at [`x`, `y`] coordinates. A
paragraph width can be passed for wrap modes. In this way, the text will wrap to
avoid paragraph width overflow.
## Parameters:
### Parameters:
- `string` String: Text to be drawn
- `x` Number: x coordinate of the text
- `y` Number: y coordinate of the text
- `paragraph_width` Number: Width of the paragraph
# set_text_mode
### Returns:
- Array: An array composed of the `x` and `y` coordinates of the end of the text / paragraph
## set_text_mode
```javascript
> set_text_mode();
> set_text_mode(mode);
```
Set the `text()` placement mode. By default, passed coordinates of `text()` are
Sets the `text()` placement mode. By default, passed coordinates of `text()` are
defining left side of the text. But it can also be the center or the right side
of the text / paragraph.
## Parameter:
### Parameter:
- `mode` Mode: Mode of `text()`
## Modes:
### Modes:
- `TEXT_LEFT` Default value
- `TEXT_CENTER`
- `TEXT_RIGHT`
# set_text_align
## set_text_align
```javascript
> set_text_align();
> set_text_align(align_mode);
```
Set the `text()` alignement mode. By default, the paragraph is aligned to left
Sets the `text()` alignement mode. By default, the paragraph is aligned to left
but it can be set to center or right. The alignement works when wrap mode
Modes:
### Parameter:
- `align_mode` Mode: Aligning mode of `text()`
### Modes:
- `TEXT_ALIGN_LEFT` Default value.
- `TEXT_ALIGN_CENTER`
- `TEXT_ALIGN_RIGHT`
# set_text_wrap
## set_text_wrap
```javascript
> set_text_wrap();
> set_text_wrap(wrap_mode);
```
Set the `text()` wrapping mode. By default, the text does not wrap, it is
Sets the `text()` wrapping mode. By default, the text does not wrap, it is
trimmed once it got out of the active layer.
Modes:
### Parameter:
- `wrap_mode` Mode: Wrapping mode of `text()`
### Modes:
- `TEXT_TRIM` Default value, text is trimmed out of the active layer.
- `TEXT_WRAP_HARD` Wrap text. Split words if necessary.
- `TEXT_WRAP` Wrap text without splitting words (exept if the word is bigger
than the text / paragraph width).
# shape
# Other
## shape
```javascript
> shape(x, y, radius_x, radius_y, vertices, character);
> shape(x, y, radius_x, radius_y, vertices, character, linked);
> shape(x, y, radius_x, radius_y, vertices, character, linked, rotation_offset);
```
Draw a shape on the active layer. The shape is positioned at `x` and `y` passed
Draws a shape on the active layer. The shape is positioned at `x` and `y` passed
coordinates. The value of `vertices` defines the number of sides of the shape.
With 3 vertices, the shape would be a **triangle**, with 4, a **square** etc.
The bigger this value is, the nearer the shape would be to a **circle**.
......@@ -244,19 +295,47 @@ If `linked` (`true` by default) is set to `false`, sides of the shape will not
be drawn. Only the corners will.
`rotation_offset` (`0` by default) is a number value (between `0` and `1`) which
set the shape rotation offset. At `0`,
sets the shape rotation offset between 2 corners. Looping from `0` to `1` would
make the shape rotate continually.
# fill
### Parameters:
- `x` Number: x coordinate of the shape center
- `y` Number: y coordinate of the shape center
- `radius_x` Number: Width of the shape
- `radius_y` Number: Height of the shape
- `vertices` Number: Number of vertices of the shape
- `character` Characters (string): Character used to draw the shape
- `linked` Boolean: If `true`, vertices are drawn. If not, only corners are
- `rotation_offset` Number: Between `0` and `1`, set the shape angle based on the difference between two corners
## fill
```javascript
> fill(x, y, character);
```
# border
Fill the area selected via `x` and `y` with `character` on the active layer. The
area is defined by the designated cell and it's contiguous cells with the same
content (same character as original cell).
This function acts like filling tools of drawing softwares.
### Parameters:
- `x` Number: x coordinate of the area
- `y` Number: y coordinate of the area
- `character` Character (string): Character used to fill area.
# set_draw_mode
## border
## set_draw_mode
```javascript
> set_draw_mode();
> set_draw_mode(mode);
```
Sets the drawing mode.
### Modes:
- `DRAW_TEXT` Mode:
- `DRAW_HTML` Mode: