util

package
v1.30.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Overview

Copyright © 2021 Brian Longmore branodev@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	DefaultMode    = "ascii"
	DefaultPattern = " .,:(/*%&#@"
	DefaultWidth   = 100
)

Variables

This section is empty.

Functions

func DrawPixels

func DrawPixels(c DrawConfig) (string, error)

DrawPixels is the low level method for generating a print. It typically uses inputs that would be returned by ProcessImage and is called by OutputImage.

func GetFileByPath added in v1.25.0

func GetFileByPath(filePath string) (io.ReadCloser, error)

GetFileByPath returns the file contents from filePath. Make sure you close the file after calling.

func GetFileByUrl added in v1.25.0

func GetFileByUrl(url string) (io.ReadCloser, error)

GetFileByUrl returns the http response body from url. Make sure you close the body after calling.

func OutputImage

func OutputImage(c OutputConfig) (string, error)

OutputImage is the high level and preferred method for generating a print. It calls both ProcessImage and OutputImage.

func ProcessFilePath added in v1.25.0

func ProcessFilePath(filePath string) string

ProcessFilePath returns the path of a unique destination file in the directory of filePath. If filePath does not already exist, it will just return filePath. Otherwise it would return a unique path in the form of "n_fileName" where n is a positive integer.

func ProcessImage

func ProcessImage(c ProcessConfig) (image.Image, int, int, error)

ProcessImage returns the decoded image and its new dimensions. It is called by OutputImage.

func ScaleValue

func ScaleValue(value, lowerI, upperI, lowerF, upperF float64) (int, error)

ScaleValue takes value and transforms(translation and scaling) it according to its new, transformed bounds.

Types

type DrawConfig added in v1.22.0

type DrawConfig struct {
	ImgData      image.Image
	ImgWidth     int
	ImgHeight    int
	Src          string
	Dst          string
	OutputMode   string
	AsciiPattern string
	OutputWidth  int
	IsUseWeb     bool
	IsPrinted    bool
	IsSaved      bool
	IsQuiet      bool
	IsInverted   bool
}

type OutputConfig added in v1.11.0

type OutputConfig struct {
	Src          string
	Dst          string
	OutputMode   string
	AsciiPattern string
	OutputWidth  int
	IsUseWeb     bool
	IsPrinted    bool
	IsSaved      bool
	IsQuiet      bool
	IsInverted   bool
	IsSrcBytes   bool
}

type ProcessConfig added in v1.22.0

type ProcessConfig struct {
	Src         string
	IsUseWeb    bool
	OutputWidth int
	IsSrcBytes  bool
}

Jump to

Keyboard shortcuts

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