automated snapshot

This commit is contained in:
sumi
2026-01-10 16:03:24 -06:00
parent 90e36425ff
commit 0ce5df85aa
5 changed files with 145 additions and 88 deletions

View File

@@ -31,15 +31,35 @@ type Style struct {
Stroke, Fill bool
}
func BeginDrawing() {
rl.BeginDrawing()
}
func EndDrawing() {
rl.EndDrawing()
}
func (g *Graphics) Center() Point {
return g.Bounds.Center()
}
func (g *Graphics) Begin() {
rl.BeginBlendMode(rl.BlendAlphaPremultiply)
g.PushMatrix()
g.Translate(g.Bounds.UL())
g.BeginClip(g.Bounds)
g.Translate(g.Bounds.UL())
}
func (g *Graphics) BeginPremultiplyBlend() {
rl.BeginBlendMode(rl.BlendAlphaPremultiply)
}
func (g *Graphics) EndPremultiplyBlend() {
rl.EndBlendMode()
}
func (g *Graphics) End() {
g.PopMatrix()
g.EndClip()
}
func (g *Graphics) Clear() {
@@ -50,12 +70,6 @@ func (g *Graphics) Background(c color.RGBA) {
rl.ClearBackground(c)
}
func (g *Graphics) End() {
g.EndBlend()
g.EndClip()
g.PopMatrix()
}
func (g *Graphics) Width() float32 {
return g.Bounds.Width
}
@@ -133,13 +147,14 @@ func (g *Graphics) BeginTexture(t rl.RenderTexture2D) {
rl.BeginTextureMode(t)
}
func (g *Graphics) DrawTexture(t rl.Texture2D, p Point, c color.RGBA) {
rl.DrawTexture(t, int32(p.X), int32(p.Y), c)
}
func (g *Graphics) TransferTexture(t rl.Texture2D, src Rect, dst Rect, tint color.RGBA) {
// flip source since textures are upside down on GPU
//src.Y += src.Height
src.Height = -src.Height
rl.DrawTexturePro(t, src.ToRL(), dst.ToRL(), rl.Vector2{}, 0, tint)
}
@@ -185,7 +200,16 @@ type Rect rl.Rectangle
func (r *Rect) Center() Point {
return Point {
X: r.X + r.Width / 2,
Y: r.X + r.Height / 2,
Y: r.Y + r.Height / 2,
}
}
func (r *Rect) ContractByAbs(px float32) Rect {
return Rect {
X: r.X + px,
Y: r.Y + px,
Width: r.Width - 2*px,
Height: r.Height - 2*px,
}
}