toi

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

TOI (Text on Image)

Introduction

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseHexToRGBA

func ParseHexToRGBA(s string) (c color.RGBA, err error)

ParseHexToRGBA converts a hexadecimal color string to an RGBA color. The color string should be in the format "#RRGGBB" or "#RGB". Returns the corresponding color.RGBA struct and an error if the format is invalid.

func ParseRGBAToHex

func ParseRGBAToHex(c color.RGBA) string

ParseRGBAToHex converts an RGBA color to a hexadecimal color string. Returns the corresponding hexadecimal color string.

Types

type Color

type Color struct {
	Hex  string     // Hexadecimal representation of the color.
	RGBA color.RGBA // RGBA representation of the color.
}

Color represents a color with both hexadecimal and RGBA representations.

func (*Color) Init

func (c *Color) Init() error

Init initializes the Color struct by parsing the hexadecimal representation and converting it to the RGBA representation.

type Doodle

type Doodle struct {
	Arabic bool        // Indicates whether the text is Arabic or not.
	Text   string      // The text to be drawn.
	Dst    draw.Image  // The destination image onto which the text will be drawn.
	Src    image.Image // The source image from which the text color will be picked.
	Face   font.Face   // The font face used for rendering the text.
	X, Y   int         // The coordinates where the text will be drawn.
}

Doodle represents a text doodle that can be drawn onto an image.

func (*Doodle) Draw

func (d *Doodle) Draw()

Draw draws the text onto the destination image.

type Font

type Font struct {
	Face font.Face // Face represents the font face that can be used for rendering text.
	Path string    // Path is the file path to the font file.
	Size uint64    // Size is the font size.
	DPI  uint64    // DPI is the dots per inch (resolution) of the font.
}

Font represents a font file and its properties.

func (*Font) Init

func (f *Font) Init() error

Init initializes the font by loading the font file and creating a font face. It returns any error encountered during the process.

type Image

type Image struct {
	Path       string     // Path is the file path of the image.
	Data       draw.Image // Data is the image data in draw.Image format.
	Format     string     // Format is the format of the image (e.g., "jpeg" or "png").
	ImageBytes []byte     // ImageBytes is the byte slice representing the image.
}

Image represents an image with associated data and format.

func (*Image) Init

func (i *Image) Init() error

Init initializes the Image struct by loading image data from either a file or bytes. It converts the image to RGBA format and sets the format. It returns any error encountered during the process.

func (*Image) Save

func (i *Image) Save() error

Save encodes and saves the image to the specified file path. It returns any error encountered during the process.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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