MCPcopy
hub / github.com/g3n/engine / SetImage

Method SetImage

gui/image_button.go:135–149  ·  view source on GitHub ↗

SetImage sets the button left image from the specified filename If there is currently a selected icon, it is removed

(state ButtonState, imgfile string)

Source from the content-addressed store, hash-verified

133// SetImage sets the button left image from the specified filename
134// If there is currently a selected icon, it is removed
135func (b *ImageButton) SetImage(state ButtonState, imgfile string) error {
136
137 tex, err := texture.NewTexture2DFromImage(imgfile)
138 if err != nil {
139 return err
140 }
141
142 if b.stateImages[state] != nil {
143 b.stateImages[state].Dispose()
144 }
145 b.stateImages[state] = tex
146 b.update()
147
148 return nil
149}
150
151// Dispose releases resources used by this widget
152func (b *ImageButton) Dispose() {

Callers

nothing calls this directly

Calls 3

updateMethod · 0.95
NewTexture2DFromImageFunction · 0.92
DisposeMethod · 0.65

Tested by

no test coverage detected