mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
Rename ImageDrawOption -> ImageDrawOptions
This commit is contained in:
parent
742c7ad854
commit
90665944b9
@ -60,7 +60,7 @@ func drawText(rt *ebiten.Image, images *Images, str string, ox, oy, scale int, c
|
||||
b := float64(c2.B) / max
|
||||
a := float64(c2.A) / max
|
||||
clr := ebiten.ScaleColor(r, g, b, a)
|
||||
rt.DrawImage(fontImageId, &ebiten.ImageDrawOption{
|
||||
rt.DrawImage(fontImageId, &ebiten.ImageDrawOptions{
|
||||
DstParts: dsts,
|
||||
SrcParts: srcs,
|
||||
GeometryMatrix: &geo,
|
||||
|
@ -115,7 +115,7 @@ func (s *GameScene) Draw(r *ebiten.Image, images *Images) {
|
||||
geo := ebiten.ScaleGeometry(float64(fieldWidth)/float64(w), float64(fieldHeight)/float64(h))
|
||||
geo.Concat(ebiten.TranslateGeometry(20, 20)) // TODO: magic number?
|
||||
clr := ebiten.ScaleColor(0.0, 0.0, 0.0, 0.5)
|
||||
r.DrawImage(field, &ebiten.ImageDrawOption{
|
||||
r.DrawImage(field, &ebiten.ImageDrawOptions{
|
||||
GeometryMatrix: &geo,
|
||||
ColorMatrix: &clr,
|
||||
})
|
||||
|
@ -75,7 +75,7 @@ func (s *SceneManager) Draw(r *ebiten.Image, images *Images) {
|
||||
|
||||
alpha := float64(s.transitionCount) / float64(transitionMaxCount)
|
||||
clr := ebiten.ScaleColor(1, 1, 1, alpha)
|
||||
op := &ebiten.ImageDrawOption{
|
||||
op := &ebiten.ImageDrawOptions{
|
||||
ColorMatrix: &clr,
|
||||
}
|
||||
r.DrawImage(to, op)
|
||||
|
@ -35,12 +35,12 @@ var (
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
geo := ebiten.ScaleGeometry(1.0/mosaicRatio, 1.0/mosaicRatio)
|
||||
gophersRenderTarget.DrawImage(gophersImage, &ebiten.ImageDrawOption{
|
||||
gophersRenderTarget.DrawImage(gophersImage, &ebiten.ImageDrawOptions{
|
||||
GeometryMatrix: &geo,
|
||||
})
|
||||
|
||||
geo = ebiten.ScaleGeometry(mosaicRatio, mosaicRatio)
|
||||
screen.DrawImage(gophersRenderTarget, &ebiten.ImageDrawOption{
|
||||
screen.DrawImage(gophersRenderTarget, &ebiten.ImageDrawOptions{
|
||||
GeometryMatrix: &geo,
|
||||
})
|
||||
return nil
|
||||
|
@ -43,7 +43,7 @@ func update(screen *ebiten.Image) error {
|
||||
maxWidth := float64(w) + float64(h)*0.75
|
||||
geo := ebiten.TranslateGeometry(-maxWidth/2, -float64(h)/2)
|
||||
geo.Concat(ebiten.TranslateGeometry(screenWidth/2, screenHeight/2))
|
||||
screen.DrawImage(gophersImage, &ebiten.ImageDrawOption{
|
||||
screen.DrawImage(gophersImage, &ebiten.ImageDrawOptions{
|
||||
DstParts: dsts,
|
||||
SrcParts: srcs,
|
||||
GeometryMatrix: &geo,
|
||||
|
@ -56,7 +56,7 @@ func update(screen *ebiten.Image) error {
|
||||
geo.Concat(ebiten.ScaleGeometry(scaleX, scaleY))
|
||||
geo.Concat(ebiten.RotateGeometry(float64(count%720) * 2 * math.Pi / 720))
|
||||
geo.Concat(ebiten.TranslateGeometry(screenWidth/2, screenHeight/2))
|
||||
if err := screen.DrawImage(gophersImage, &ebiten.ImageDrawOption{
|
||||
if err := screen.DrawImage(gophersImage, &ebiten.ImageDrawOptions{
|
||||
GeometryMatrix: &geo,
|
||||
}); err != nil {
|
||||
return err
|
||||
|
@ -68,7 +68,7 @@ func (c *graphicsContext) postUpdate() error {
|
||||
scale := float64(c.screenScale)
|
||||
geo := ScaleGeometry(scale, scale)
|
||||
clr := ColorMatrixI()
|
||||
option := &ImageDrawOption{
|
||||
option := &ImageDrawOptions{
|
||||
GeometryMatrix: &geo,
|
||||
ColorMatrix: &clr,
|
||||
}
|
||||
|
14
image.go
14
image.go
@ -52,9 +52,9 @@ func (i *innerImage) Fill(clr color.Color) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *innerImage) drawImage(img *innerImage, option *ImageDrawOption) error {
|
||||
func (i *innerImage) drawImage(img *innerImage, option *ImageDrawOptions) error {
|
||||
if option == nil {
|
||||
option = &ImageDrawOption{}
|
||||
option = &ImageDrawOptions{}
|
||||
}
|
||||
dsts := option.DstParts
|
||||
srcs := option.SrcParts
|
||||
@ -159,11 +159,11 @@ func (i *Image) Fill(clr color.Color) (err error) {
|
||||
// After determining parts to draw, this applies the geometry matrix geo and the color matrix color.
|
||||
//
|
||||
// If you want to draw a whole image simply, use DrawWholeImage.
|
||||
func (i *Image) DrawImage(image *Image, option *ImageDrawOption) (err error) {
|
||||
func (i *Image) DrawImage(image *Image, option *ImageDrawOptions) (err error) {
|
||||
return i.drawImage(image.inner, option)
|
||||
}
|
||||
|
||||
func (i *Image) drawImage(image *innerImage, option *ImageDrawOption) (err error) {
|
||||
func (i *Image) drawImage(image *innerImage, option *ImageDrawOptions) (err error) {
|
||||
i.pixels = nil
|
||||
i.syncer.Sync(func() {
|
||||
err = i.inner.drawImage(image, option)
|
||||
@ -202,16 +202,16 @@ func (i *Image) At(x, y int) color.Color {
|
||||
return color.RGBA{r, g, b, a}
|
||||
}
|
||||
|
||||
type ImageDrawOption struct {
|
||||
type ImageDrawOptions struct {
|
||||
DstParts []image.Rectangle
|
||||
SrcParts []image.Rectangle
|
||||
GeometryMatrix *GeometryMatrix
|
||||
ColorMatrix *ColorMatrix
|
||||
}
|
||||
|
||||
func At(x, y int) *ImageDrawOption {
|
||||
func At(x, y int) *ImageDrawOptions {
|
||||
geo := TranslateGeometry(float64(x), float64(y))
|
||||
return &ImageDrawOption{
|
||||
return &ImageDrawOptions{
|
||||
GeometryMatrix: &geo,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user