diff options
author | Soumith Chintala <soumith@gmail.com> | 2016-02-25 09:31:42 +0300 |
---|---|---|
committer | Soumith Chintala <soumith@fb.com> | 2016-02-26 20:52:59 +0300 |
commit | 57cbbceb7ff2d071cdbfbad8eb01d0247aa632bf (patch) | |
tree | a2c72aabe1d820ff9d41c7da69ee5cb8cfc1c4bd /doc | |
parent | 5daa4afc01a8ce67eed6a44aacbbe5be68568bbd (diff) |
add a simple font drawing function
Diffstat (limited to 'doc')
-rw-r--r-- | doc/drawing.md | 24 | ||||
-rw-r--r-- | doc/index.md | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/doc/drawing.md b/doc/drawing.md new file mode 100644 index 0000000..8bfe6bb --- /dev/null +++ b/doc/drawing.md @@ -0,0 +1,24 @@ +<a name="image.drawing"></a> +## Simple Drawing Routines ## +This section includes simple routines to draw on images. + +<a name="image.drawText"></a> +### [res] image.drawText(src, x, y, [options]) ### +Draws text onto a 3-channel Tensor (C x H x W) at the x-offset `x` and y-offset `y`. + +The `options` table can be passed in to set color, background color, in-place etc. + +Options: +* `color` - [table] The text color. A table of 3 numbers `{R, G, B}`, each number scaled between 0 and 255. For example, `red` is `{255, 0, 0}` +* bg - [table] The background color where text is drawn. Same format as color. +* size - [number] Size of the text to be drawn. `Default value = 1`. +* wrap - [boolean] If the text goes out of bounds, wrap it with a newline automatically. `default value = true` +* inplace - [boolean] If true, draws directly on the input tensor and returns it. `default value = false` + +Example: + +```lua +image.drawText(image.lena(), "hello\nworld", 10, 10) +image.drawText(image.lena(), "hello\nworld", 10, 20,{color = {0, 255, 0}, size = 5}) +image.drawText(image.lena(), "hello\nworld", 10, 20,{color = {0, 255, 0}, bg = {255, 0, 0}, size = 5}) +```
\ No newline at end of file diff --git a/doc/index.md b/doc/index.md index bf2a3a3..62a987d 100644 --- a/doc/index.md +++ b/doc/index.md @@ -6,6 +6,7 @@ images. It contains a wide variety of functions divided into the following categ * [Saving and loading](saveload.md) images as JPEG, PNG, PPM and PGM; * [Simple transformations](simpletransform.md) like translation, scaling and rotation; * [Parameterized transformations](paramtransform.md) like convolutions and warping; + * [Simple Drawing Routines](doc/drawing.md) like drawing text on an image; * [Graphical user interfaces](gui.md) like display and window; * [Color Space Conversions](colorspace.md) from and to RGB, YUV, Lab, and HSL; * [Tensor Constructors](tensorconstruct.md) for creating Lenna, Fabio and Gaussian and Laplacian kernels; |