This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
tomo-old/elements/basic/image.go

26 lines
677 B
Go
Raw Normal View History

2023-02-09 16:34:53 -07:00
package basicElements
import "image"
2023-02-26 20:20:17 -07:00
import "git.tebibyte.media/sashakoshka/tomo/canvas"
2023-02-09 16:34:53 -07:00
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
2023-02-26 20:20:17 -07:00
import "git.tebibyte.media/sashakoshka/tomo/artist/patterns"
2023-02-09 16:34:53 -07:00
type Image struct {
*core.Core
core core.CoreControl
2023-02-26 20:20:17 -07:00
buffer canvas.Canvas
2023-02-09 16:34:53 -07:00
}
func NewImage (image image.Image) (element *Image) {
2023-02-26 20:20:17 -07:00
element = &Image { buffer: canvas.FromImage(image) }
2023-03-14 23:41:23 -06:00
element.Core, element.core = core.NewCore(element, element.draw)
2023-02-09 16:34:53 -07:00
bounds := image.Bounds()
element.core.SetMinimumSize(bounds.Dx(), bounds.Dy())
return
}
func (element *Image) draw () {
2023-02-26 20:20:17 -07:00
(patterns.Texture { Canvas: element.buffer }).
Draw(element.core, element.Bounds())
2023-02-09 16:34:53 -07:00
}