Skip to content

Commit

Permalink
accessors from common types
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jun 21, 2024
1 parent 5c226cc commit 5520d6f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/stretchr/testify v1.9.0
)

require github.com/minetest-go/types v1.0.1
require github.com/minetest-go/types v1.0.3

require (
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ github.com/minetest-go/mapparser v0.1.3 h1:mjQ+dXiLd3PPwtsf9QOQY6ZN16dHmFwC/eHyn
github.com/minetest-go/mapparser v0.1.3/go.mod h1:TcjEkPY9n0rBM+beSstw+Jje8nGl+LqFhiC00J6ihNw=
github.com/minetest-go/types v1.0.1 h1:vGNyfmdgOEDAy2HVMCjQ2AU/FlmxfZ0IFre6FQKVvfY=
github.com/minetest-go/types v1.0.1/go.mod h1:QS2q8tKAiuBe2Rin880ARFt9VokYIJNZV4Z4kHAChU0=
github.com/minetest-go/types v1.0.2 h1:lHU9frnlgtWO3XFIVxO5X3Gi+y07gV+guREglqnwDJM=
github.com/minetest-go/types v1.0.2/go.mod h1:QS2q8tKAiuBe2Rin880ARFt9VokYIJNZV4Z4kHAChU0=
github.com/minetest-go/types v1.0.3 h1:FepTTIbfvNDhg1VbualcBhayK2p8bJK6TokLnp8xDMU=
github.com/minetest-go/types v1.0.3/go.mod h1:QS2q8tKAiuBe2Rin880ARFt9VokYIJNZV4Z4kHAChU0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
Expand Down
2 changes: 1 addition & 1 deletion isorenderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewDefaultIsoRenderOpts() *IsoRenderOpts {
}
}

func RenderIsometric(na NodeAccessor, cr ColorResolver, from, to *types.Pos, opts *IsoRenderOpts) (image.Image, error) {
func RenderIsometric(na types.NodeAccessor, cr types.ColorResolver, from, to *types.Pos, opts *IsoRenderOpts) (image.Image, error) {
if opts == nil {
opts = NewDefaultIsoRenderOpts()
}
Expand Down
2 changes: 1 addition & 1 deletion maprenderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
type MapRenderOpts struct {
}

func RenderMap(na NodeAccessor, cr ColorResolver, from, to *types.Pos, opts *MapRenderOpts) (*image.NRGBA, error) {
func RenderMap(na types.NodeAccessor, cr types.ColorResolver, from, to *types.Pos, opts *MapRenderOpts) (*image.NRGBA, error) {
// from = lowest, to = highest
from, to = types.SortPos(from, to)
search_dir := &types.Pos{0, -1, 0}
Expand Down
2 changes: 1 addition & 1 deletion probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/minetest-go/types"
)

func Probe(min, max, pos, ipos *types.Pos, na NodeAccessor, cr ColorResolver, skip_alpha bool) ([]*NodeWithColor, error) {
func Probe(min, max, pos, ipos *types.Pos, na types.NodeAccessor, cr types.ColorResolver, skip_alpha bool) ([]*NodeWithColor, error) {
nodes := []*NodeWithColor{}

cpos := pos
Expand Down
6 changes: 0 additions & 6 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@ type NodeWithColor struct {
*types.Node
Color *color.RGBA
}

// returns the node at the given position, nil if no node found
type NodeAccessor func(pos *types.Pos) (*types.Node, error)

// resolves the node-name and param2 to a color, nil if no color-mapping found
type ColorResolver func(name string, param2 int) *color.RGBA

0 comments on commit 5520d6f

Please sign in to comment.