mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-09-12 08:08:30 +02:00
Add //convolve documentation to README & aliases
This commit is contained in:
parent
2b32385fdf
commit
da1c56cc23
28
README.md
28
README.md
@ -199,6 +199,34 @@ Here are all the above examples together:
|
||||
//replacemix dirt 3 sandstone 10 dry_dirt cobble 2
|
||||
```
|
||||
|
||||
### `//convolve <kernel> [<width>[,<height>]] [<sigma>]`
|
||||
Advanced version of `//smooth` from we_env, and so far the _only_ WorldEditAdditions command to have any aliases (`//smoothadv` and `//conv`).
|
||||
|
||||
Extracts a heightmap from the defined region and then proceeds to [convolve](https://en.wikipedia.org/wiki/Kernel_(image_processing)) over it with the specified kernel. The kernel can be thought of as the filter that will be applied to the heightmap. Once done, the newly convolved heightmap is applied to the terrain.
|
||||
|
||||
Possible kernels:
|
||||
|
||||
Kernel | Description
|
||||
----------------|------------------------------
|
||||
[`box`](https://en.wikipedia.org/wiki/Box_blur) | A simple uniform box blur.
|
||||
`pascal` | A kernel derived from the odd layers of [Pascal's Triangle](https://en.wikipedia.org/wiki/Pascal%27s_triangle). Slightly less smooth than a Gaussian blur.
|
||||
[`gaussian`](https://en.wikipedia.org/wiki/Gaussian_blur) | The default. A Gaussian blur - should give the smoothest result, and also the most customisable - see below.
|
||||
|
||||
If you can think of any other convolutional filters that would be useful, please [open an issue](https://github.com/sbrl/Minetest-WorldEditAdditions/issues/new). The code backing this command is very powerful and flexible, so adding additional convolutional filters should be pretty trivial.
|
||||
|
||||
The width and height (if specified) refer to the dimensions of the kernel and must be odd integers and are separated by a single comma (and _no_ space). If the height is not specified, it defaults to the width. If using the `gaussian` kernel, the width and height must be identical. Larger kernels are slower, but produce a more smoothed effect and take more nearby nodes into account for every column. Defaults to a 5x5 kernel.
|
||||
|
||||
The sigma value is only applicable to the `gaussian` kernel, and can be thought of as the 'smoothness' to apply. Greater values result in more smoothing. Default: 2
|
||||
|
||||
```
|
||||
//convolve
|
||||
//convolve box 7
|
||||
//convolve pascal 11,3
|
||||
//convolve gaussian 7
|
||||
//convolve gaussian 9 10
|
||||
//convolve gaussian 5 0.2
|
||||
```
|
||||
|
||||
### `//count`
|
||||
Counts all the nodes in the defined region and returns the result along with calculated percentages (note that if the chat window used a monospace font, the returned result would be a perfect table. If someone has a ~~hack~~ solution to make the columns line up neatly, please [open an issue](https://github.com/sbrl/Minetest-WorldEditAdditions/issues/new) :D)
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
-- ██████ ██████ ██ ████ ████ ██████ ███████ ████ ███████
|
||||
worldedit.register_command("convolve", {
|
||||
params = "<kernel> [<width>[,<height>]] [<sigma>]",
|
||||
description = "Advanced version of //smooth from we_env. Convolves over the defined region with the given kernel. Possible kernels: box, pascal, gaussian. The width & height (if specified) must be odd integers. If the height is not specified, it defaults to the width. gaussian should give the smoothest result, but the width & height must be identical. The sigma value is only applicable to gaussian kernels.",
|
||||
description = "Advanced version of //smooth from we_env. Convolves over the defined region with the given kernel. Possible kernels: box, pascal, gaussian. The width & height (if specified) must be odd integers. If the height is not specified, it defaults to the width. gaussian should give the smoothest result, but the width & height must be identical. The sigma value is only applicable to gaussian kernels, and can be thought of as the 'smoothness' to apply.",
|
||||
privs = { worldedit = true },
|
||||
require_pos = 2,
|
||||
parse = function(params_text)
|
||||
@ -72,3 +72,6 @@ worldedit.register_command("convolve", {
|
||||
return true, "Added "..stats.added.." and removed "..stats.removed.." nodes"
|
||||
end
|
||||
})
|
||||
|
||||
worldedit.alias_command("smoothadv", "convolve")
|
||||
worldedit.alias_command("conv", "convolve")
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
-- explode(seperator, string)
|
||||
-- From http://lua-users.org/wiki/SplitJoin
|
||||
function explode(delim, str)
|
||||
local function explode(delim, str)
|
||||
local ll, is_done
|
||||
local delim_length = string.len(delim)
|
||||
ll = 0
|
||||
@ -27,13 +27,13 @@ function explode(delim, str)
|
||||
end
|
||||
|
||||
-- From http://lua-users.org/wiki/StringTrim
|
||||
function trim(s)
|
||||
local function trim(s)
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("/multi", {
|
||||
params = "//<command_a> <args> //<command_b> <args> .....",
|
||||
description = "Executes multiple chat commands in sequence.",
|
||||
params = "/<command_a> <args> //<command_b> <args> /<command_c> <args>.....",
|
||||
description = "Executes multiple chat commands in sequence. Just prepend a list of space-separated chat commands with //multi, and you're good to go! The forward slashes at the beginning of each chat command must be the same as if you were executing it normally.",
|
||||
privs = { worldedit = true },
|
||||
func = function(name, params_text)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user