bbox

package
v0.0.0-...-2eabe60 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package bbox provides utilities for managing various types of bounding boxes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoundingBox

type BoundingBox struct {
	// contains filtered or unexported fields
}

BoundingBox is a bounding box for a board, which provides a top-left and bottom-right.

func New

func New(tl, br *point.Point) (*BoundingBox, error)

New creates a new bounding box.

func (*BoundingBox) BotRight

func (b *BoundingBox) BotRight() *point.Point

BotRight point of the bounding box.

func (*BoundingBox) Bottom

func (b *BoundingBox) Bottom() int

Bottom side of the bounding box.

func (*BoundingBox) Height

func (b *BoundingBox) Height() int

Height of the bounding box.

func (*BoundingBox) Left

func (b *BoundingBox) Left() int

Left side of the bounding box

func (*BoundingBox) Right

func (b *BoundingBox) Right() int

Right side of the bounding box.

func (*BoundingBox) Top

func (b *BoundingBox) Top() int

Top side of the bounding box.

func (*BoundingBox) TopLeft

func (b *BoundingBox) TopLeft() *point.Point

TopLeft point of the bounding box.

func (*BoundingBox) Width

func (b *BoundingBox) Width() int

Width of the bounding box.

type CropBox

type CropBox struct {
	BBox         *BoundingBox
	OriginalSize int
}

A CropBox is a bounding box that contains a strict subset of a board.

func CropBoxFromPreset

func CropBoxFromPreset(p CroppingPreset, boardSize int) (*CropBox, error)

CropBoxFromPreset creates a cropping box from the original board size (typically 9, 13, 19). Note that the integer points in the crop box are 0 indexed, but originalSize is 1-indexed. In other words, we would typically expect the max ints to range from 9 to 19.

Following the SGF covention, we consider the topleft to be 0,0

type CroppingPreset

type CroppingPreset int

CroppingPreset is a convenience enum for specifying a cropping direction.

const (
	//TopLeft see below
	// X -
	// - -
	TopLeft CroppingPreset = iota

	//TopRight see below
	// - X
	// - -
	TopRight

	//BottomRight see below
	// - -
	// - X
	BottomRight

	//BottomLeft see below
	// - -
	// X -
	BottomLeft

	//Top see below
	// X X
	// - -
	Top

	//Left see below
	// X -
	// X -
	Left

	//Right see below
	// - X
	// - X
	Right

	//Bottom see below
	// - -
	// X X
	Bottom

	//All see below
	// X X
	// X X
	All
)

Jump to

Keyboard shortcuts

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