aboutsummaryrefslogtreecommitdiff
path: root/engine/image.go
blob: 07cac55089dd382ee1fd650013e6928ed4795507 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

package engine

import (
	"age_of_empires/physics"
	"image/color"

	"github.com/hajimehoshi/ebiten/v2"
	"github.com/hajimehoshi/ebiten/v2/vector"
)

func NewFilledRectangleImage(size physics.Point, color color.Color) *ebiten.Image {
	image := ebiten.NewImage(size.X, size.Y)
	image.Fill(color)
	return image
}

func NewStrokeRectangleImage(size physics.Point, strokeWidth float32, color color.Color) *ebiten.Image {
	image := ebiten.NewImage(size.X, size.Y)
	vector.StrokeRect(image, 0, 0, float32(size.X), float32(size.Y), float32(strokeWidth), color, true)
	return image
}

func NewFilledCircleImage(width int, color color.Color) *ebiten.Image {
	image := ebiten.NewImage((width), (width))
	vector.DrawFilledCircle(image, float32(width/2), float32(width/2), float32(width/2), color, true)
	return image
}

func NewStrokeCircleImage(width int, strokeWidth int, color color.Color) *ebiten.Image {
	image := ebiten.NewImage((width), (width))
	vector.StrokeCircle(image, float32(width/2), float32(width/2), float32(width/2), float32(strokeWidth), color, true)
	return image
}