mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
vector: rename functions
Fill* was confusing especially when the color is a transparent color. Closes #2403
This commit is contained in:
parent
c79b2c793a
commit
6ba14fdb00
@ -44,16 +44,16 @@ func DrawLine(dst *ebiten.Image, x1, y1, x2, y2 float64, clr color.Color) {
|
||||
//
|
||||
// DrawRect is intended to be used mainly for debugging or prototyping purpose.
|
||||
//
|
||||
// Deprecated: as of v2.5. Use vector.FillRect instead.
|
||||
// Deprecated: as of v2.5. Use vector.DrawFilledRect instead.
|
||||
func DrawRect(dst *ebiten.Image, x, y, width, height float64, clr color.Color) {
|
||||
vector.FillRect(dst, float32(x), float32(y), float32(width), float32(height), clr)
|
||||
vector.DrawFilledRect(dst, float32(x), float32(y), float32(width), float32(height), clr)
|
||||
}
|
||||
|
||||
// DrawCircle draws a circle on given destination dst.
|
||||
//
|
||||
// DrawCircle is intended to be used mainly for debugging or prototyping purpose.
|
||||
//
|
||||
// Deprecated: as of v2.5. Use vector.FillCircle instead.
|
||||
// Deprecated: as of v2.5. Use vector.DrawFilledCircle instead.
|
||||
func DrawCircle(dst *ebiten.Image, cx, cy, r float64, clr color.Color) {
|
||||
vector.FillCircle(dst, float32(cx), float32(cy), float32(r), clr)
|
||||
vector.DrawFilledCircle(dst, float32(cx), float32(cy), float32(r), clr)
|
||||
}
|
||||
|
@ -339,13 +339,13 @@ func (p *Player) seekBarIfNeeded() error {
|
||||
func (p *Player) draw(screen *ebiten.Image) {
|
||||
// Draw the bar.
|
||||
x, y, w, h := playerBarRect()
|
||||
vector.FillRect(screen, float32(x), float32(y), float32(w), float32(h), playerBarColor)
|
||||
vector.DrawFilledRect(screen, float32(x), float32(y), float32(w), float32(h), playerBarColor)
|
||||
|
||||
// Draw the cursor on the bar.
|
||||
c := p.current
|
||||
cx := float32(x) + float32(w)*float32(p.current)/float32(p.total)
|
||||
cy := float32(y) + float32(h)/2
|
||||
vector.FillCircle(screen, cx, cy, 12, playerCurrentColor)
|
||||
vector.DrawFilledCircle(screen, cx, cy, 12, playerCurrentColor)
|
||||
|
||||
// Compose the curren time text.
|
||||
m := (c / time.Minute) % 100
|
||||
|
@ -107,7 +107,7 @@ func init() {
|
||||
}
|
||||
|
||||
func drawWindow(r *ebiten.Image, x, y, width, height int) {
|
||||
vector.FillRect(r, float32(x), float32(y), float32(width), float32(height), color.RGBA{0, 0, 0, 0xc0})
|
||||
vector.DrawFilledRect(r, float32(x), float32(y), float32(width), float32(height), color.RGBA{0, 0, 0, 0xc0})
|
||||
}
|
||||
|
||||
var fontColor = color.NRGBA{0x40, 0x40, 0xff, 0xff}
|
||||
|
@ -51,7 +51,7 @@ func (g *Game) Update() error {
|
||||
|
||||
func (g *Game) Draw(screen *ebiten.Image) {
|
||||
for r, c := range g.gridColors {
|
||||
vector.FillRect(screen, float32(r.Min.X), float32(r.Min.Y), float32(r.Dx()), float32(r.Dy()), c)
|
||||
vector.DrawFilledRect(screen, float32(r.Min.X), float32(r.Min.Y), float32(r.Dx()), float32(r.Dy()), c)
|
||||
}
|
||||
|
||||
switch ebiten.CursorShape() {
|
||||
|
@ -150,7 +150,7 @@ func init() {
|
||||
for i, k := range whiteKeys {
|
||||
x := i*keyWidth + 36
|
||||
height := 112
|
||||
vector.FillRect(pianoImage, float32(x), float32(y), float32(keyWidth-1), float32(height), color.White)
|
||||
vector.DrawFilledRect(pianoImage, float32(x), float32(y), float32(keyWidth-1), float32(height), color.White)
|
||||
text.Draw(pianoImage, k, arcadeFont, x+8, y+height-8, color.Black)
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ func init() {
|
||||
}
|
||||
x := i*keyWidth + 24
|
||||
height := 64
|
||||
vector.FillRect(pianoImage, float32(x), float32(y), float32(keyWidth-1), float32(height), color.Black)
|
||||
vector.DrawFilledRect(pianoImage, float32(x), float32(y), float32(keyWidth-1), float32(height), color.Black)
|
||||
text.Draw(pianoImage, k, arcadeFont, x+8, y+height-8, color.White)
|
||||
}
|
||||
}
|
||||
|
@ -267,8 +267,8 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
}
|
||||
|
||||
// Draw player as a rect
|
||||
vector.FillRect(screen, float32(g.px)-2, float32(g.py)-2, 4, 4, color.Black)
|
||||
vector.FillRect(screen, float32(g.px)-1, float32(g.py)-1, 2, 2, color.RGBA{255, 100, 100, 255})
|
||||
vector.DrawFilledRect(screen, float32(g.px)-2, float32(g.py)-2, 4, 4, color.Black)
|
||||
vector.DrawFilledRect(screen, float32(g.px)-1, float32(g.py)-1, 2, 2, color.RGBA{255, 100, 100, 255})
|
||||
|
||||
if g.showRays {
|
||||
ebitenutil.DebugPrintAt(screen, "R: hide rays", padding, 0)
|
||||
|
@ -48,10 +48,10 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
vector.StrokeLine(screen, 50, 150, 50, 350, 1, color.RGBA{0xff, 0xff, 0x00, 0xff})
|
||||
vector.StrokeLine(screen, 50, 100+cf, 200+cf, 250, 4, color.RGBA{0x00, 0xff, 0xff, 0xff})
|
||||
|
||||
vector.FillRect(screen, 50+cf, 50+cf, 100+cf, 100+cf, color.RGBA{0x80, 0x80, 0x80, 0xc0})
|
||||
vector.DrawFilledRect(screen, 50+cf, 50+cf, 100+cf, 100+cf, color.RGBA{0x80, 0x80, 0x80, 0xc0})
|
||||
vector.StrokeRect(screen, 300-cf, 50, 120, 120, 10+cf/4, color.RGBA{0x00, 0x80, 0x00, 0xff})
|
||||
|
||||
vector.FillCircle(screen, 400, 400, 100, color.RGBA{0x80, 0x00, 0x80, 0x80})
|
||||
vector.DrawFilledCircle(screen, 400, 400, 100, color.RGBA{0x80, 0x00, 0x80, 0x80})
|
||||
vector.StrokeCircle(screen, 400, 400, 10+cf, 10+cf/2, color.RGBA{0xff, 0x80, 0xff, 0xff})
|
||||
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.ActualTPS()))
|
||||
|
@ -175,9 +175,9 @@ func (g *Game) Update() error {
|
||||
|
||||
func (g *Game) Draw(screen *ebiten.Image) {
|
||||
for _, v := range g.snakeBody {
|
||||
vector.FillRect(screen, float32(v.X*gridSize), float32(v.Y*gridSize), gridSize, gridSize, color.RGBA{0x80, 0xa0, 0xc0, 0xff})
|
||||
vector.DrawFilledRect(screen, float32(v.X*gridSize), float32(v.Y*gridSize), gridSize, gridSize, color.RGBA{0x80, 0xa0, 0xc0, 0xff})
|
||||
}
|
||||
vector.FillRect(screen, float32(g.apple.X*gridSize), float32(g.apple.Y*gridSize), gridSize, gridSize, color.RGBA{0xFF, 0x00, 0x00, 0xff})
|
||||
vector.DrawFilledRect(screen, float32(g.apple.X*gridSize), float32(g.apple.Y*gridSize), gridSize, gridSize, color.RGBA{0xFF, 0x00, 0x00, 0xff})
|
||||
|
||||
if g.moveDirection == dirNone {
|
||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("Press up/down/left/right to start"))
|
||||
|
@ -96,13 +96,13 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
{
|
||||
const x, y = 20, 40
|
||||
b := text.BoundString(mplusNormalFont, sampleText)
|
||||
vector.FillRect(screen, float32(b.Min.X+x), float32(b.Min.Y+y), float32(b.Dx()), float32(b.Dy()), gray)
|
||||
vector.DrawFilledRect(screen, float32(b.Min.X+x), float32(b.Min.Y+y), float32(b.Dx()), float32(b.Dy()), gray)
|
||||
text.Draw(screen, sampleText, mplusNormalFont, x, y, color.White)
|
||||
}
|
||||
{
|
||||
const x, y = 20, 140
|
||||
b := text.BoundString(mplusBigFont, sampleText)
|
||||
vector.FillRect(screen, float32(b.Min.X+x), float32(b.Min.Y+y), float32(b.Dx()), float32(b.Dy()), gray)
|
||||
vector.DrawFilledRect(screen, float32(b.Min.X+x), float32(b.Min.Y+y), float32(b.Dx()), float32(b.Dy()), gray)
|
||||
text.Draw(screen, sampleText, mplusBigFont, x, y, color.White)
|
||||
}
|
||||
{
|
||||
@ -117,7 +117,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
const x, y = 160, 240
|
||||
const lineHeight = 80
|
||||
b := text.BoundString(text.FaceWithLineHeight(mplusBigFont, lineHeight), sampleText)
|
||||
vector.FillRect(screen, float32(b.Min.X+x), float32(b.Min.Y+y), float32(b.Dx()), float32(b.Dy()), gray)
|
||||
vector.DrawFilledRect(screen, float32(b.Min.X+x), float32(b.Min.Y+y), float32(b.Dx()), float32(b.Dy()), gray)
|
||||
text.Draw(screen, sampleText, text.FaceWithLineHeight(mplusBigFont, lineHeight), x, y, color.White)
|
||||
}
|
||||
{
|
||||
|
@ -60,8 +60,8 @@ func StrokeLine(dst *ebiten.Image, x0, y0, x1, y1 float32, strokeWidth float32,
|
||||
drawVerticesForUtil(dst, vs, is, clr)
|
||||
}
|
||||
|
||||
// FillRect fills a rectangle with the specified width and color.
|
||||
func FillRect(dst *ebiten.Image, x, y, width, height float32, clr color.Color) {
|
||||
// DrawFilledRect fills a rectangle with the specified width and color.
|
||||
func DrawFilledRect(dst *ebiten.Image, x, y, width, height float32, clr color.Color) {
|
||||
var path Path
|
||||
path.MoveTo(x, y)
|
||||
path.LineTo(x, y+height)
|
||||
@ -91,8 +91,8 @@ func StrokeRect(dst *ebiten.Image, x, y, width, height float32, strokeWidth floa
|
||||
drawVerticesForUtil(dst, vs, is, clr)
|
||||
}
|
||||
|
||||
// FillCircle filles a circle with the specified center position (cx, cy), the radius (r), width and color.
|
||||
func FillCircle(dst *ebiten.Image, cx, cy, r float32, clr color.Color) {
|
||||
// DrawFilledCircle filles a circle with the specified center position (cx, cy), the radius (r), width and color.
|
||||
func DrawFilledCircle(dst *ebiten.Image, cx, cy, r float32, clr color.Color) {
|
||||
var path Path
|
||||
path.Arc(float32(cx), float32(cy), float32(r), 0, 2*math.Pi, Clockwise)
|
||||
vs, is := path.AppendVerticesAndIndicesForFilling(nil, nil)
|
||||
|
Loading…
Reference in New Issue
Block a user