edshot

package
v0.0.0-...-de71bd2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2024 License: ISC Imports: 8 Imported by: 0

Documentation

Overview

edshot contains functions etc for analysing screenshots of the editor

Index

Constants

View Source
const (
	PIXEL_SCALE            = 2 // For hidpi
	SEL_TILE_WIDTH         = 32 * PIXEL_SCALE
	SEL_TILE_HEIGHT        = 32 * PIXEL_SCALE
	SEL_TILE_BORDER        = PIXEL_SCALE
	PADDED_SEL_TILE_WIDTH  = SEL_TILE_WIDTH + 2*SEL_TILE_BORDER
	PADDED_SEL_TILE_HEIGHT = SEL_TILE_HEIGHT + 2*SEL_TILE_BORDER
	SEL_COLUMNS            = 6
	SEL_ROWS               = 6
	MAP_TILE_WIDTH         = 16 * PIXEL_SCALE
	MAP_TILE_HEIGHT        = 15 * PIXEL_SCALE
)

Variables

This section is empty.

Functions

func FindMap

func FindMap(img image.Image, x, y int) (rect image.Rectangle, err error)

FindMap finds the extremities of the map portion of the snapshot. x and y should be on the left edge of the selecter area, approximately halfway down. The result has inclusive Min and exclusive Max.

func FindMapRow

func FindMapRow(img image.Image, x, y int, grey color.Color,
) (minX, maxX int, err error)

FindMapRow finds the extremities of the map portion of the snapshot. x and y should be on the left edge of the selecter area, approximately halfway down. The result has inclusive Min and exclusive Max.

func FindMapTopAndBottom

func FindMapTopAndBottom(img image.Image, x, y int, grey color.Color,
) (minY, maxY int, err error)

func FindSelecters

func FindSelecters(img image.Image) (rect image.Rectangle,
	grey color.Color, err error,
)

FindSelecters finds the extremities of the tile selecter area and also returns the colour of the window background. This is fairly easy because the region has a 1px black border. Each value in rect is the coordinate that the border falls on.

func GetMapColourTheme

func GetMapColourTheme(img image.Image, r image.Rectangle) int

GetMapColourTheme samples a particular pixel from the selecter region (r) to determine the map's colour theme

func HashImage

func HashImage(img image.Image, bounds image.Rectangle) uint32

HashImage computes a hash value for an image based on its RGBA values.

func HashMapTiles

func HashMapTiles(img image.Image, bounds image.Rectangle,
	positions []image.Point,
) (hashes []uint32)

HashMapTiles generates a hash for each tile defined by map tile coordinates in positions in img with map region bounded by bounds.

func LoadMap

func LoadMap(filename string) (img image.Image,
	mapBounds image.Rectangle, selBounds image.Rectangle, e error,
)

LoadMap loads a map, given a filename, makes an Image from it and finds the bounds of the tile selecter region and map region.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL