imageutil

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2022 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Overview

Package imageutil contains utility function to create/manipulate images.

Asciiraster contains support for raster fonts for images. Using RenderSymbols you can add text and symbols to an image. By specifying a symbol map containing ASCII art it is possible to define how each rune should be rendered.

Index

Constants

This section is empty.

Variables

View Source
var Basic1CharMap = map[rune]string{

	':': `


**

**
`[1:],

	'_': `




*******
`[1:],

	'a': `
 *****
**   **
*******
**   **
**   **
`[1:],

	'b': `
******
**   **
******
**   **
******
`[1:],

	'c': `
 ******
**
**
**
 ******
`[1:],

	'd': `
******
**   **
**   **
**   **
******
`[1:],

	'e': `
*******
**
*****
**
*******
`[1:],

	'f': `
*******
**
*****
**
**
`[1:],

	'g': `
 ******
**
**   ***
**    **
 ******
`[1:],

	'h': `
**   **
**   **
*******
**   **
**   **
`[1:],

	'i': `
**
**
**
**
**
`[1:],

	'j': `
     **
     **
     **
**   **
 *****
`[1:],

	'k': `
**   **
**  **
*****
**  **
**   **
`[1:],

	'l': `
**
**
**
**
*******
`[1:],

	'm': `
***    ***
****  ****
** **** **
**  **  **
**      **
`[1:],

	'n': `
***    **
****   **
** **  **
**  ** **
**   ****
`[1:],

	'o': `
 ******
**    **
**    **
**    **
 ******
`[1:],

	'p': `
******
**   **
******
**
**
`[1:],

	'q': `
 ******
**    **
**    **
** ** **
 ******
    **
`[1:],

	'r': `
******
**   **
******
**   **
**   **
`[1:],

	's': `
 ******
**
*******
     **
******
`[1:],

	't': `
********
   **
   **
   **
   **
`[1:],

	'u': `
**    **
**    **
**    **
**    **
 ******
`[1:],

	'v': `
**    **
**    **
**    **
 **  **
  ****
`[1:],

	'w': `
**     **
**     **
**  *  **
** *** **
 *** ***
`[1:],

	'x': `
**   **
 ** **
  ***
 ** **
**   **
`[1:],

	'y': `
**    **
 **  **
  ****
   **
   **
`[1:],

	'z': `
*******
   ***
  ***
 ***
*******
`[1:],

	'1': `
 **
***
 **
 **
 **
`[1:],

	'2': `
******
     **
 *****
**
*******
`[1:],

	'3': `
******
     **
 *****
     **
******
`[1:],

	'4': `
**   **
**   **
*******
     **
     **
`[1:],

	'5': `
*******
**
******
     **
******
`[1:],

	'6': `
 ******
**
*******
**    **
 ******
`[1:],

	'7': `
*******
     **
    **
   **
   **
`[1:],

	'8': `
 *****
**   **
 *****
**   **
 *****
`[1:],

	'9': `
 *****
**   **
 ******
     **
 *****
`[1:],

	'0': `
 ******
**  ****
** ** **
****  **
 ******
`[1:],
}

Basic1CharMap is a default character map for RenderSymbols.

It only has uppcase letters, numbers, the underscore and the colon rune.

View Source
var Basic2CharMap = map[rune]string{

	'A': `
   *
  * *
 *   *
*     *
*******
*     *
*     *

`[1:],
	'B': `
******
*     *
*     *
******
*     *
*     *
******

`[1:],
	'C': `
 *****
*     *
*
*
*
*     *
 *****

`[1:],
	'D': `
******
*     *
*     *
*     *
*     *
*     *
******

`[1:],
	'E': `
*******
*
*
*****
*
*
*******

`[1:],
	'F': `
*******
*
*
*****
*
*
*

`[1:],
	'G': `
 *****
*     *
*
*  ****
*     *
*     *
 *****

`[1:],
	'H': `
*     *
*     *
*     *
*******
*     *
*     *
*     *

`[1:],
	'I': `
***
 *
 *
 *
 *
 *
***

`[1:],
	'J': `
      *
      *
      *
      *
*     *
*     *
 *****

`[1:],
	'K': `
*    *
*   *
*  *
***
*  *
*   *
*    *

`[1:],
	'L': `
*
*
*
*
*
*
*******

`[1:],
	'M': `
*     *
**   **
* * * *
*  *  *
*     *
*     *
*     *

`[1:],
	'N': `
*     *
**    *
* *   *
*  *  *
*   * *
*    **
*     *

`[1:],
	'O': `
*******
*     *
*     *
*     *
*     *
*     *
*******

`[1:],
	'P': `
******
*     *
*     *
******
*
*
*

`[1:],
	'Q': `
 *****
*     *
*     *
*     *
*   * *
*    *
 **** *

`[1:],
	'R': `
******
*     *
*     *
******
*   *
*    *
*     *

`[1:],
	'S': `
 *****
*     *
*
 *****
      *
*     *
 *****

`[1:],
	'T': `
*******
   *
   *
   *
   *
   *
   *

`[1:],
	'U': `
*     *
*     *
*     *
*     *
*     *
*     *
 *****

`[1:],
	'V': `
*     *
*     *
*     *
*     *
 *   *
  * *
   *

`[1:],
	'W': `
*     *
*  *  *
*  *  *
*  *  *
*  *  *
*  *  *
 ** **

`[1:],
	'X': `
*     *
 *   *
  * *
   *
  * *
 *   *
*     *

`[1:],
	'Y': `
*     *
 *   *
  * *
   *
   *
   *
   *

`[1:],
	'Z': `
*******
     *
    *
   *
  *
 *
*******

`[1:],
	'a': `

  **
 *  *
*    *
******
*    *
*    *

`[1:],
	'b': `

*****
*    *
*****
*    *
*    *
*****

`[1:],
	'c': `

 ****
*    *
*
*
*    *
 ****

`[1:],
	'd': `

*****
*    *
*    *
*    *
*    *
*****

`[1:],
	'e': `

******
*
*****
*
*
******

`[1:],
	'f': `

******
*
*****
*
*
*

`[1:],
	'g': `

 ****
*    *
*
*  ***
*    *
 ****

`[1:],
	'h': `

*    *
*    *
******
*    *
*    *
*    *

`[1:],
	'i': `

*
*
*
*
*
*

`[1:],
	'j': `

     *
     *
     *
     *
*    *
 ****

`[1:],
	'k': `

*    *
*   *
****
*  *
*   *
*    *

`[1:],
	'l': `

*
*
*
*
*
******

`[1:],
	'm': `

*    *
**  **
* ** *
*    *
*    *
*    *

`[1:],
	'n': `

*    *
**   *
* *  *
*  * *
*   **
*    *

`[1:],
	'o': `

 ****
*    *
*    *
*    *
*    *
 ****

`[1:],
	'p': `

*****
*    *
*    *
*****
*
*

`[1:],
	'q': `

 ****
*    *
*    *
*  * *
*   *
 *** *

`[1:],
	'r': `

*****
*    *
*    *
*****
*   *
*    *

`[1:],
	's': `

 ****
*
 ****
     *
*    *
 ****

`[1:],
	't': `

*****
  *
  *
  *
  *
  *

`[1:],
	'u': `

*    *
*    *
*    *
*    *
*    *
 ****

`[1:],
	'v': `

*    *
*    *
*    *
*    *
 *  *
  **

`[1:],
	'w': `

*    *
*    *
*    *
* ** *
**  **
*    *

`[1:],
	'x': `

*    *
 *  *
  **
  **
 *  *
*    *

`[1:],
	'y': `

*   *
 * *
  *
  *
  *
  *

`[1:],
	'z': `

******
    *
   *
  *
 *
******

`[1:],
	'1': `
  *
 **
* *
  *
  *
  *
*****

`[1:],
	'2': `
 *****
*     *
      *
 *****
*
*
*******

`[1:],
	'3': `
 *****
*     *
      *
 *****
      *
*     *
 *****

`[1:],
	'4': `
*
*    *
*    *
*    *
*******
     *
     *

`[1:],
	'5': `
*******
*
*
******
      *
*     *
 *****

`[1:],
	'6': `
 *****
*     *
*
******
*     *
*     *
 *****

`[1:],
	'7': `
*******
*    *
    *
   *
  *
  *
  *

`[1:],
	'8': `
 *****
*     *
*     *
 *****
*     *
*     *
 *****

`[1:],
	'9': `
 *****
*     *
*     *
 ******
      *
*     *
 *****

`[1:],
	'0': `
  ***
 *   *
*     *
*     *
*     *
 *   *
  ***

`[1:],
	':': `

**
**

**
**


`[1:],
	';': `

***
***

***
***
 *
*
`[1:],

	',': `




***
***
 *
*
`[1:],
	'.': `




***
***
***

`[1:],
	'\'': `
***
***
 *
*




`[1:],
	'_': `







*******
`[1:],
	'(': `
  **
 *
*
*
*
 *
  **

`[1:],
	')': `
**
  *
   *
   *
   *
  *
**

`[1:],
	'!': `
***
***
***
 *

***
***

`[1:],
	'*': `

 *   *
  * *
*******
  * *
 *   *


`[1:],
	'%': `
***   *
* *  *
*** *
   *
  * ***
 *  * *
*   ***

`[1:],
	'?': `
 *****
*     *
      *
   ***
   *

   *

`[1:],
	'/': `
      *
     *
    *
   *
  *
 *
*

`[1:],
	'@': `
 *****
*     *
* *** *
* *** *
* ****
*
 *****

`[1:],
	'#': `
  * *
  * *
*******
  * *
*******
  * *
  * *

`[1:],
	'-': `



*****




`[1:],
	'+': `

  *
  *
*****
  *
  *


`[1:],
	'=': `


*****

*****



`[1:],
	'&': `
  **
 *  *
  **
 ***
*   * *
*    *
 ***  *

`[1:],
	'|': `
*
*
*

*
*
*

`[1:],
	'\\': `
*
 *
  *
   *
    *
     *
      *

`[1:],
	'~': `


 **
*  *  *
    **



`[1:],
}

Basic2CharMap is a default character map for RenderSymbols.

A more elaborage font having Upper and lower case banner text with numbers and some special characters.

View Source
var SpaceSymbolSpacing = 5

SpaceSymbolSpacing defines the space in pixels of a space character if the character is not defined in the font map

View Source
var SymbolSpacing = 1

SymbolSpacing defines the spacing in pixels between two symbols

Functions

func RenderSymbols

func RenderSymbols(img image.Image, p image.Point, str string,
	col color.Color, smap map[rune]string) (image.Image, error)

RenderSymbols renders the symbols in the given string str at the given point p in the given Image img in the color col using smap as symbol mapping.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL