area

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package area provides functions working with image areas.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExcludeBorder

func ExcludeBorder(area image.Rectangle) image.Rectangle

ExcludeBorder returns a new area created by subtracting a border around the provided area. Return the zero area if there isn't enough space to exclude the border.

func FromSize

func FromSize(size image.Point) (image.Rectangle, error)

FromSize returns the corresponding area for the provided size.

func HSplit

func HSplit(area image.Rectangle, heightPerc int) (top image.Rectangle, bottom image.Rectangle, err error)

HSplit returns two new areas created by splitting the provided area at the specified percentage of its width. The percentage must be in the range 0 <= heightPerc <= 100. Can return zero size areas.

func Shrink added in v0.8.0

func Shrink(area image.Rectangle, topCells, rightCells, bottomCells, leftCells int) (image.Rectangle, error)

Shrink returns a new area whose size is reduced by the specified amount of cells. Can return a zero area if there is no space left in the area. The values must be zero or positive integers.

func ShrinkPercent added in v0.8.0

func ShrinkPercent(area image.Rectangle, topPerc, rightPerc, bottomPerc, leftPerc int) (image.Rectangle, error)

ShrinkPercent returns a new area whose size is reduced by percentage of its width or height. Can return a zero area if there is no space left in the area. The topPerc and bottomPerc indicate the percentage of area's height. The rightPerc and leftPerc indicate the percentage of area's width. The percentages must be in range 0 <= v <= 100.

func Size

func Size(area image.Rectangle) image.Point

Size returns the size of the provided area.

func VSplit

func VSplit(area image.Rectangle, widthPerc int) (left image.Rectangle, right image.Rectangle, err error)

VSplit returns two new areas created by splitting the provided area at the specified percentage of its width. The percentage must be in the range 0 <= widthPerc <= 100. Can return zero size areas.

func WithRatio

func WithRatio(area image.Rectangle, ratio image.Point) image.Rectangle

WithRatio returns the largest area that has the requested ratio but is either equal or smaller than the provided area. Returns zero area if the area or the ratio are zero, or if there is no such area.

Types

This section is empty.

Jump to

Keyboard shortcuts

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