2021-07-23 17:05:05 +10:00
|
|
|
package engine
|
|
|
|
|
2021-08-01 20:28:33 +10:00
|
|
|
import (
|
2021-08-05 10:26:45 +10:00
|
|
|
"image/color"
|
2021-08-01 20:28:33 +10:00
|
|
|
"unsafe"
|
|
|
|
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
|
|
)
|
|
|
|
|
2021-08-01 17:08:26 +10:00
|
|
|
// ID implements Identifier directly (as a string value).
|
|
|
|
type ID string
|
|
|
|
|
|
|
|
// Ident returns id as a string.
|
|
|
|
func (id ID) Ident() string { return string(id) }
|
|
|
|
|
2021-07-31 19:49:24 +10:00
|
|
|
// ZPos implements ZPositioner directly (as a float64 value).
|
2021-07-23 17:05:05 +10:00
|
|
|
type ZPos float64
|
|
|
|
|
2021-07-31 19:49:24 +10:00
|
|
|
// Z returns z as a float64.
|
2021-07-23 17:05:05 +10:00
|
|
|
func (z ZPos) Z() float64 { return float64(z) }
|
2021-08-01 20:28:33 +10:00
|
|
|
|
2021-08-02 12:28:02 +10:00
|
|
|
// GeoMDef is a serialisable form of ebiten.GeoM.
|
2021-08-01 20:28:33 +10:00
|
|
|
type GeoMDef [6]float64 // Assumption: this has identical memory layout to GeoM
|
|
|
|
|
|
|
|
// ToGeoMDef translates a GeoM to a GeoMDef using unsafe.Pointer.
|
|
|
|
func ToGeoMDef(m *ebiten.GeoM) *GeoMDef {
|
|
|
|
return (*GeoMDef)(unsafe.Pointer(m))
|
|
|
|
}
|
|
|
|
|
|
|
|
// GeoM translates a GeoMDef to a GeoM using unsafe.Pointer.
|
|
|
|
func (d *GeoMDef) GeoM() *ebiten.GeoM {
|
|
|
|
return (*ebiten.GeoM)(unsafe.Pointer(d))
|
|
|
|
}
|
2021-08-05 10:26:45 +10:00
|
|
|
|
|
|
|
// Fill fills the image with a colour.
|
|
|
|
type Fill struct {
|
|
|
|
Color color.Color
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f Fill) Draw(screen *ebiten.Image, _ ebiten.GeoM) {
|
|
|
|
screen.Fill(color.Color(f.Color))
|
|
|
|
}
|