diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-10-07 21:35:16 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-10-08 10:48:55 +0200 |
| commit | 0bc5bd306f274aa60b075fd8e0167e1ee4f28845 (patch) | |
| tree | 9ebe8abd51efb2653212ddab91179bb51614b064 /go/ui/mapView.go | |
| parent | d4a314f5e2e0e11a1bb30728b47d70ea56a75771 (diff) | |
| download | muhqs-game-0bc5bd306f274aa60b075fd8e0167e1ee4f28845.tar.gz muhqs-game-0bc5bd306f274aa60b075fd8e0167e1ee4f28845.zip | |
switch to new vector API for drawing paths
Diffstat (limited to 'go/ui/mapView.go')
| -rw-r--r-- | go/ui/mapView.go | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/go/ui/mapView.go b/go/ui/mapView.go index 169aaaf3..051c216f 100644 --- a/go/ui/mapView.go +++ b/go/ui/mapView.go @@ -2,7 +2,6 @@ package ui import ( "fmt" - "image" "image/color" "math" "unicode" @@ -14,20 +13,6 @@ import ( "muhq.space/muhqs-game/go/log" ) -var ( - // No idea why image.DrawTrianglesOptions needs this it is copied from - // the ebiten vector example. - whiteImage = ebiten.NewImage(3, 3) - - // whiteSubImage is an internal sub image of whiteImage. - // Use whiteSubImage at DrawTriangles instead of whiteImage in order to avoid bleeding edges. - whiteSubImage = whiteImage.SubImage(image.Rect(1, 1, 2, 2)).(*ebiten.Image) -) - -func init() { - whiteImage.Fill(color.White) -} - const ( PERMANENT_WIDTH int = 40 PERMANENT_HEIGHT int = 40 @@ -353,25 +338,9 @@ func drawPileHint(screen *ebiten.Image) { path.LineTo(PILE_HINT_STARTX+PILE_HINT_LENGTH, y) path.Close() } - - var vs []ebiten.Vertex - var is []uint16 - { - op := &vector.StrokeOptions{Width: PILE_HINT_WIDTH} - vs, is = path.AppendVerticesAndIndicesForStroke(nil, nil, op) - } - - for i := range vs { - vs[i].SrcX = 1 - vs[i].SrcY = 1 - vs[i].ColorR = 0 - vs[i].ColorG = 0 - vs[i].ColorB = 0 - vs[i].ColorA = 1 - } - - op := &ebiten.DrawTrianglesOptions{AntiAlias: true} - screen.DrawTriangles(vs, is, whiteSubImage, op) + strokeOp := &vector.StrokeOptions{Width: PILE_HINT_WIDTH} + drawOp := &vector.DrawPathOptions{AntiAlias: true} + vector.StrokePath(screen, &path, strokeOp, drawOp) } func (vw *MapView) Draw(screen *ebiten.Image) { |
