downgrade ebiten/v2 v2.5.9

This commit is contained in:
2026-05-22 17:23:02 +02:00
parent 190e67d050
commit 87541071aa
3 changed files with 83 additions and 21 deletions

View File

@ -5,8 +5,8 @@ import (
"math"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
"github.com/hajimehoshi/ebiten/v2/text"
"github.com/hajimehoshi/ebiten/v2/vector"
"golang.org/x/image/font/basicfont"
)
@ -17,19 +17,68 @@ var whitePixel = func() *ebiten.Image {
}()
func Rect(screen *ebiten.Image, x, y, w, h float32, clr color.Color) {
vector.FillRect(screen, x, y, w, h, clr, true)
ebitenutil.DrawRect(screen, float64(x), float64(y), float64(w), float64(h), clr)
}
func RectOutline(screen *ebiten.Image, x, y, w, h, stroke float32, clr color.Color) {
vector.StrokeRect(screen, x, y, w, h, stroke, clr, true)
if w <= 0 || h <= 0 || stroke <= 0 {
return
}
if stroke > w {
stroke = w
}
if stroke > h {
stroke = h
}
Rect(screen, x, y, w, stroke, clr)
Rect(screen, x, y+h-stroke, w, stroke, clr)
Rect(screen, x, y, stroke, h, clr)
Rect(screen, x+w-stroke, y, stroke, h, clr)
}
func Line(screen *ebiten.Image, x1, y1, x2, y2, width float32, clr color.Color) {
vector.StrokeLine(screen, x1, y1, x2, y2, width, clr, true)
dx := x2 - x1
dy := y2 - y1
length := float32(math.Hypot(float64(dx), float64(dy)))
if length <= 0 || width <= 0 {
return
}
r, g, b, a := clr.RGBA()
op := &ebiten.DrawImageOptions{}
op.GeoM.Scale(float64(length), float64(width))
op.GeoM.Translate(0, -float64(width)/2)
op.GeoM.Rotate(math.Atan2(float64(dy), float64(dx)))
op.GeoM.Translate(float64(x1), float64(y1))
op.ColorM.Scale(
float64(r)/0xffff,
float64(g)/0xffff,
float64(b)/0xffff,
float64(a)/0xffff,
)
screen.DrawImage(whitePixel, op)
}
func Circle(screen *ebiten.Image, x, y, r float32, clr color.Color) {
vector.FillCircle(screen, x, y, r, clr, true)
if r <= 0 {
return
}
ri := int(math.Ceil(float64(r)))
for dy := -ri; dy <= ri; dy++ {
fy := float64(dy)
if math.Abs(fy) > float64(r) {
continue
}
halfWidth := math.Sqrt(float64(r)*float64(r) - fy*fy)
ebitenutil.DrawRect(
screen,
float64(x)-halfWidth,
float64(y)+fy,
halfWidth*2,
1,
clr,
)
}
}
func Triangle(screen *ebiten.Image, x1, y1, x2, y2, x3, y3 float32, clr color.Color) {