MCPcopy Create free account
hub / github.com/cogentcore/core / allocSizes

Method allocSizes

core/sprite.go:166–183  ·  view source on GitHub ↗

allocSizes allocates the sprites by size to fixed set of images and layers

()

Source from the content-addressed store, hash-verified

164
165// allocSizes allocates the sprites by size to fixed set of images and layers
166func (ss *Sprites) allocSizes() {
167 ns := ss.Names.Len()
168 szs := make([]image.Point, ns)
169 idx := 0
170 for _, kv := range ss.Names.Order {
171 sp := kv.Value
172 if sp.Geom.Size == (image.Point{}) {
173 continue
174 }
175 szs[idx] = sp.Geom.Size
176 idx++
177 }
178 if idx != ns {
179 szs = szs[:idx]
180 }
181 ss.szAlloc.SetSizes(image.Point{4, 4}, system.MaxImageLayers, szs)
182 ss.szAlloc.Alloc()
183}
184
185// Add adds sprite to list, and returns the image index and
186// layer index within that for given sprite. If name already

Callers 1

configSpritesMethod · 0.95

Calls 3

LenMethod · 0.65
SetSizesMethod · 0.45
AllocMethod · 0.45

Tested by

no test coverage detected