Documentation ¶
Index ¶
- Variables
- func IterateLine(x0, y0, x1, y1 int, callBack BresenhamCallBack)
- func IterateLineOrdered(x0, y0, x1, y1 int, callBack BresenhamCallBack)
- type Alignment
- type BresenhamCallBack
- type FitMode
- type FreeRectChoiceHeuristic
- type Insets
- type MaxRectsBinPacker
- type MaxRectsBinResult
- type Point
- type Rect
- func (r Rect) AlignIn(b Rect, alignment Alignment) Rect
- func (r Rect) Bottom() int
- func (r Rect) Center() Point
- func (r Rect) CenterIn(o Rect) Rect
- func (r Rect) CenterX() int
- func (r Rect) CenterY() int
- func (r Rect) ContainsPoint(pointX, pointY int) bool
- func (r Rect) Empty() bool
- func (r Rect) EqualsTo(other Rect) bool
- func (r Rect) FitIn(b Rect, mode FitMode, alignment Alignment) Rect
- func (r Rect) Intersect(r2 Rect) bool
- func (r Rect) IntersectWithCircle(circleX, circleY, circleRadius int) bool
- func (r Rect) Intersection(s Rect) Rect
- func (r Rect) IsContainedIn(b Rect) bool
- func (r Rect) Left() int
- func (r Rect) MaxPoint() Point
- func (r Rect) MinPoint() Point
- func (r Rect) MoveTo(x, y int) Rect
- func (r Rect) ResizeTo(w, h int) Rect
- func (r Rect) Right() int
- func (r Rect) Scale(factor float32) Rect
- func (r Rect) ShrinkByInsets(i Insets) Rect
- func (r Rect) ShrinkByInt(i int) Rect
- func (r Rect) Size() Size
- func (r Rect) String() string
- func (r Rect) ToRectangle() image.Rectangle
- func (r Rect) Top() int
- func (r Rect) Translate(x, y int) Rect
- func (r Rect) TranslateFloat(x, y float32) Rect
- func (r Rect) TranslatePoint(point Point) Rect
- func (r Rect) UnionWith(other Rect) Rect
- type RectNode
- type Segment
- type Size
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func IterateLine ¶
func IterateLine(x0, y0, x1, y1 int, callBack BresenhamCallBack)
IterateLine from x0,y0 to x1,y1. For each point on the line it calls the callBack function. Note: The order of the points is not preserved.
func IterateLineOrdered ¶
func IterateLineOrdered(x0, y0, x1, y1 int, callBack BresenhamCallBack)
IterateLineOrdered from x0,y0 to x1,y1. For each point on the line it calls the callBack function. Note: The order of the points is preserved, use IterateLineOrdered if speed is more important.
Types ¶
type Alignment ¶
type Alignment uint32
const ( AlignmentHCenter Alignment = 1 << iota AlignmentHLeft AlignmentHRight AlignmentVCenter AlignmentVTop AlignmentVBottom AlignmentNone Alignment = 0 AlignmentCenter = AlignmentHCenter | AlignmentVCenter )
type BresenhamCallBack ¶
The BresenhamCallBack function should return true if the iteration needs to stop. x,y are the current iteration coordinates.
type FreeRectChoiceHeuristic ¶
type FreeRectChoiceHeuristic int
const ( // BSSF: Positions the rectangle against the short side of a free rectangle into which it fits the best. RectBestShortSideFit FreeRectChoiceHeuristic = iota // BAF: Positions the rectangle into the smallest free rect into which it fits. RectBestAreaFit // BL: Does the Tetris placement. RectBottomLeftRule )
type MaxRectsBinPacker ¶
type MaxRectsBinPacker struct {
// contains filtered or unexported fields
}
func NewMaxRectsBinPacker ¶
func NewMaxRectsBinPacker(width, height int, paddingX, paddingY int, allowRotation bool) *MaxRectsBinPacker
Create a new MaxRectsBinPacker packer
func (*MaxRectsBinPacker) Occupancy ¶
func (mr *MaxRectsBinPacker) Occupancy() float32
Computes the ratio of used surface area
func (*MaxRectsBinPacker) Pack ¶
func (mr *MaxRectsBinPacker) Pack(inputRects []RectNode, method FreeRectChoiceHeuristic) *MaxRectsBinResult
Packs the passed rects with the chosen heuristic. The dimensions of the returned rects will include the padding.
type MaxRectsBinResult ¶
type MaxRectsBinResult struct { PlacedRects []RectNode // Rects that have been placed NotPlacedRects []RectNode // Rects that didn't fit in the provided area Width int // Total Width used by the rects Height int // Total Height used by the rects Method FreeRectChoiceHeuristic // Method used to pack the rects }
type Rect ¶
type Rect struct {
X, Y, W, H int
}
func RectFromArray ¶
func RectFromFloat ¶
func RectFromRectangle ¶
func (Rect) ContainsPoint ¶
func (Rect) IntersectWithCircle ¶
func (Rect) Intersection ¶
func (Rect) IsContainedIn ¶
func (Rect) ShrinkByInsets ¶
func (Rect) ShrinkByInt ¶
func (Rect) ToRectangle ¶
func (Rect) TranslateFloat ¶
func (Rect) TranslatePoint ¶
type RectNode ¶
type RectNode struct { Rect // Width and Height include padding Index int // This index is used to keep track of which of the input rects this is Rotated bool // True if the rect has been rotated 90 degrees }
func NewRectNode ¶
func NewRectNodeFrom ¶
Click to show internal directories.
Click to hide internal directories.