Documentation ¶
Index ¶
- Constants
- func Area(sz image.Point) int
- func PointsClone(pts []image.Point) []image.Point
- func SizeGroups(sizes []int, maxN int) []int
- func UniqSortedInts(vals []int) []int
- func XYfmGpi(gi, nxi int) (xi, yi int)
- type Idxs
- type SzAlloc
- func (sa *SzAlloc) Alloc()
- func (sa *SzAlloc) AllocGpItems()
- func (sa *SzAlloc) AllocGps(xgpi, ygpi []int) (allocs [][]int, maxItems int)
- func (sa *SzAlloc) AllocItemsNoGps()
- func (sa *SzAlloc) AllocItemsUniqGps()
- func (sa *SzAlloc) LimitGpNs()
- func (sa *SzAlloc) PrintGps()
- func (sa *SzAlloc) SetSizes(gps image.Point, itmsPerGp int, itms []image.Point)
- func (sa *SzAlloc) SizesFmIdxs(xgpi, ygpi []int) []image.Point
- func (sa *SzAlloc) UniqSz()
- func (sa *SzAlloc) UpdateGpMaxSz()
- func (sa *SzAlloc) XYSizeFmIdx(idx image.Point) image.Point
Constants ¶
const MaxIters = 100
MaxIters is maximum number of iterations for adapting sizes to fit constraints
Variables ¶
This section is empty.
Functions ¶
func PointsClone ¶
PointsClone returns clone of []image.Point list
func SizeGroups ¶
SizeGroups returns evenly-spaced size groups of max N -- could be less
func UniqSortedInts ¶
UniqSortedInts returns the ints in sorted order with only unique vals
Types ¶
type Idxs ¶
type Idxs struct { // percent size of this image relative to max size allocated PctSize mat32.Vec2 `desc:"percent size of this image relative to max size allocated"` // group index GpIdx int `desc:"group index"` // item index within group (e.g., Layer) ItemIdx int `desc:"item index within group (e.g., Layer)"` }
Idxs contains the indexes where a given item image size is allocated there is one of these per each ItemSizes
type SzAlloc ¶
type SzAlloc struct { // true if configured and ready to use On bool `desc:"true if configured and ready to use"` // maximum number of groups in X and Y dimensions MaxGps image.Point `desc:"maximum number of groups in X and Y dimensions"` // maximum number of groups = X * Y MaxNGps int `desc:"maximum number of groups = X * Y"` // maximum number of items per group -- constraint is enforced in addition to MaxGps MaxItemsPerGp int `desc:"maximum number of items per group -- constraint is enforced in addition to MaxGps"` // original list of item sizes to be allocated ItemSizes []image.Point `desc:"original list of item sizes to be allocated"` // list of all unique sizes -- operate on this for grouping UniqSizes []image.Point `desc:"list of all unique sizes -- operate on this for grouping"` // map of all unique sizes, with group index as value UniqSzMap map[image.Point]int `desc:"map of all unique sizes, with group index as value"` // indexes into UniqSizes slice, ordered by ItemSizes indexes UniqSzItems []int `desc:"indexes into UniqSizes slice, ordered by ItemSizes indexes"` // list of allocated group sizes GpSizes []image.Point `desc:"list of allocated group sizes"` // allocation of image indexes by group -- first index is group, second is list of items for that group GpAllocs [][]int `desc:"allocation of image indexes by group -- first index is group, second is list of items for that group"` // allocation image value indexes to image indexes ItemIdxs []*Idxs `desc:"allocation image value indexes to image indexes"` // sorted list of all unique sizes XSizes []int `desc:"sorted list of all unique sizes"` // sorted list of all unique sizes YSizes []int `desc:"sorted list of all unique sizes"` // number of items in each dimension group (X, Y) GpNs image.Point `desc:"number of items in each dimension group (X, Y)"` // list of x group indexes XGpIdxs []int `desc:"list of x group indexes"` // list of y group indexes YGpIdxs []int `desc:"list of y group indexes"` }
SzAlloc manages allocation of sizes to a spec'd maximum number of groups. Used for allocating texture images to image arrays under the severe constraints of only 16 images. Only a maximum of MaxItemsPerGp items can be allocated per grouping.
func (*SzAlloc) AllocGpItems ¶
func (sa *SzAlloc) AllocGpItems()
AllocGpItems allocates items in groups based on final GpAllocs
func (*SzAlloc) AllocGps ¶
AllocGps allocates groups based on given indexes into XSizes, YSizes. returns allocs = indexes of items per each group, and max number of items per group
func (*SzAlloc) AllocItemsNoGps ¶
func (sa *SzAlloc) AllocItemsNoGps()
AllocItemsNoGps directly allocate items each to their own group -- all fits
func (*SzAlloc) AllocItemsUniqGps ¶ added in v1.0.7
func (sa *SzAlloc) AllocItemsUniqGps()
AllocItemsUniqGps directly allocate items each to their own unique-sized group
func (*SzAlloc) LimitGpNs ¶
func (sa *SzAlloc) LimitGpNs()
LimitGpNs updates group sizes to ensure that the MaxItemsPerGp limit is not exceeded.
func (*SzAlloc) SetSizes ¶
SetSizes sets the max number of groups along each dimension (X, Y), so total number of groups is X*Y, and max items per group, and item sizes to organize -- directly uses the given slice so it should not be something that is reallocated.
func (*SzAlloc) SizesFmIdxs ¶
SizesFmIdxs returns X,Y sizes from X,Y indexes in image.Point into XSizes, YSizes arrays
func (*SzAlloc) UpdateGpMaxSz ¶
func (sa *SzAlloc) UpdateGpMaxSz()
UpdateGpMaxSz updates the group sizes based on actual max sizes of items