Upgrade tomo version
This commit is contained in:
parent
11a14431be
commit
af6aa2c463
@ -1,6 +1,8 @@
|
||||
package xcanvas
|
||||
|
||||
import "image"
|
||||
import "image/color"
|
||||
import "github.com/jezek/xgbutil/xgraphics"
|
||||
import "git.tebibyte.media/tomo/tomo/canvas"
|
||||
|
||||
// Texture is a read-only image texture that can be quickly written to a canvas.
|
||||
@ -40,16 +42,43 @@ func NewTextureFrom (source image.Image) *Texture {
|
||||
return texture
|
||||
}
|
||||
|
||||
func (this *Texture) BGRAAt (x, y int) xgraphics.BGRA {
|
||||
if !(image.Point{ x, y }.In(this.rect)) {
|
||||
return xgraphics.BGRA { }
|
||||
}
|
||||
index := this.PixOffset(x, y)
|
||||
return xgraphics.BGRA {
|
||||
B: this.pix[index ],
|
||||
G: this.pix[index + 1],
|
||||
R: this.pix[index + 2],
|
||||
A: this.pix[index + 3],
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Texture) At (x, y int) color.Color {
|
||||
return this.BGRAAt(x, y)
|
||||
}
|
||||
|
||||
// Bounds returns the bounding rectangle of this texture.
|
||||
func (this *Texture) Bounds () image.Rectangle {
|
||||
return this.rect
|
||||
}
|
||||
|
||||
func (this *Texture) ColorModel () color.Model {
|
||||
return xgraphics.BGRAModel
|
||||
}
|
||||
|
||||
// Opaque reports whether or not the texture is fully opaque.
|
||||
func (this *Texture) Opaque () bool {
|
||||
return !this.transparent
|
||||
}
|
||||
|
||||
func (this *Texture) PixOffset (x, y int) int {
|
||||
x = wrap(x, this.rect.Min.X, this.rect.Max.X)
|
||||
y = wrap(y, this.rect.Min.Y, this.rect.Max.Y)
|
||||
return x * 4 + y * this.stride
|
||||
}
|
||||
|
||||
// Close frees the texture from memory.
|
||||
func (this *Texture) Close () error {
|
||||
// i lied we dont actually need to close this, but we will once this
|
||||
@ -64,12 +93,6 @@ func (this *Texture) Clip (bounds image.Rectangle) canvas.Texture {
|
||||
return &clipped
|
||||
}
|
||||
|
||||
func (this *Texture) PixOffset (x, y int) int {
|
||||
x = wrap(x, this.rect.Min.X, this.rect.Max.X)
|
||||
y = wrap(y, this.rect.Min.Y, this.rect.Max.Y)
|
||||
return x * 4 + y * this.stride
|
||||
}
|
||||
|
||||
// AssertTexture checks if a given canvas.Texture is a texture from this package.
|
||||
func AssertTexture (unknown canvas.Texture) *Texture {
|
||||
if tx, ok := unknown.(*Texture); ok {
|
||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module git.tebibyte.media/tomo/x
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
git.tebibyte.media/tomo/tomo v0.27.0
|
||||
git.tebibyte.media/tomo/tomo v0.28.0
|
||||
git.tebibyte.media/tomo/typeset v0.5.2
|
||||
git.tebibyte.media/tomo/xgbkb v1.0.1
|
||||
github.com/jezek/xgb v1.1.0
|
||||
|
4
go.sum
4
go.sum
@ -1,6 +1,6 @@
|
||||
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
|
||||
git.tebibyte.media/tomo/tomo v0.27.0 h1:gCwxQe0qm1hZLfHkMI3OccNMC/lB1cfs4BbaMz/bXug=
|
||||
git.tebibyte.media/tomo/tomo v0.27.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
|
||||
git.tebibyte.media/tomo/tomo v0.28.0 h1:wB+RpYw48Jn2DUQhXwdUe54BnYJf/79On3jxnBYvQ1Q=
|
||||
git.tebibyte.media/tomo/tomo v0.28.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
|
||||
git.tebibyte.media/tomo/typeset v0.5.2 h1:qHxN62/VDnrAouOuzxLmLleQNwAebshrfVYvtoOnAG4=
|
||||
git.tebibyte.media/tomo/typeset v0.5.2/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g=
|
||||
git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE=
|
||||
|
@ -4,6 +4,6 @@ import "image"
|
||||
import "git.tebibyte.media/tomo/x/canvas"
|
||||
import "git.tebibyte.media/tomo/tomo/canvas"
|
||||
|
||||
func (backend Backend) NewTexture (source image.Image) canvas.Texture {
|
||||
func (backend Backend) NewTexture (source image.Image) canvas.TextureCloser {
|
||||
return xcanvas.NewTextureFrom(source)
|
||||
}
|
||||
|
Reference in New Issue
Block a user