123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package gg
- import (
- "github.com/hajimehoshi/ebiten/v2"
- "image"
- _ "image/png"
- "io"
- "math"
- )
- import "surdeus.su/core/gg/mx"
- type Image = ebiten.Image
- type ImageRect = image.Rectangle
- type ImagePoint = image.Point
- type ColorValue uint32
- type ColorMode = ebiten.ColorM
- type Color struct {
- R, G, B, A ColorValue
- }
- const (
- MaxColorValue = math.MaxUint32
- )
- // The wrapper to make RGBA color via
- // values from 0 to 1 (no value at all and the max value).
- func RGBA(r, g, b, a mx.Float) Color {
- return Color {
- ColorValue(r*MaxColorValue),
- ColorValue(g*MaxColorValue),
- ColorValue(b*MaxColorValue),
- ColorValue(a*MaxColorValue),
- }
- }
- // Read an image from Reader and return
- // a new *Image.
- func LoadImage(input io.Reader) (*Image, error) {
- img, _, err := image.Decode(input)
- if err != nil {
- return nil, err
- }
- ret := ebiten.NewImageFromImage(img)
- return ret, nil
- }
- // Returns a new empty image
- // with specified with and height.
- func NewImage(w, h int) (*Image) {
- return ebiten.NewImage(w, h)
- }
- func NewImageFromImage(img image.Image) *Image {
- return ebiten.NewImageFromImage(img)
- }
- func (c Color) RGBA() (r, g, b, a uint32) {
- return uint32(c.R), uint32(c.G), uint32(c.B), uint32(c.A)
-
- }
|