#color #image #colored-text #multi-line #text

image_colored_text

A basic extension of the image/imageproc crates for writing multiline colored text

4 releases

0.1.3 Jan 3, 2025
0.1.2 Apr 16, 2023
0.1.1 Mar 25, 2023
0.1.0 Mar 20, 2023

#233 in Images

Download history 20/week @ 2024-12-07 1/week @ 2024-12-14 85/week @ 2024-12-28 59/week @ 2025-01-04 2/week @ 2025-01-11

146 downloads per month
Used in 4 crates

Apache-2.0

260KB
462 lines

A basic extension of the image/imageproc crates for writing multiline colored text

I initially wrote this code for this project: hibou.

Since then it has evolved a bit and I decided to repackage it on its own as a library.

Single line colored text

In the example below some colored text is written on a single line at different positions. In each of the three example, the little cross corresponds to the anchor position on which the text is written, with different options on how to use this position:

  • in the first example the text is written below and on the right of the anchor
  • in the second the text is centered around the anchor
  • in the third example, it is written above and on the left

The horizontal lines correspond to the expected width of the text.

drawing single line colored text

Multiline colored text

In the example below we have a similar example except that the input text is formatted in several lines. We also provide a means to specify the text alignment which is:

  • on the left for the first example
  • centered for the second
  • on the right for the third
drawing multi lines colored text

It is also possible to specify a background color:

drawing multi lines colored text with background color

And borders that can also be colored (here black) :

drawing multi lines colored text with background color and border

Dependencies

~10MB
~200K SLoC