Pixel art tool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
515 B

package application
import (
"image"
"math"
"github.com/hajimehoshi/ebiten/v2"
)
type canvas struct {
w, h int
img *ebiten.Image
scale float64
}
func NewCanvas(w, h int) *canvas {
return &canvas{
w: w,
h: h,
img: ebiten.NewImage(w, h),
scale: 1,
}
}
func (c *canvas) pixelScreenRect(x, y int) image.Rectangle {
return image.Rect(int(math.Floor(float64(x)*c.scale)), int(math.Floor(float64(y)*c.scale)), int(math.Ceil(float64(x+1)*c.scale)), int(math.Ceil(float64(y+1)*c.scale)))
}