mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Rename ImageDrawOptions -> DrawImageOptions (#43)
This commit is contained in:
parent
389b2b75f2
commit
f2fbd991d2
@ -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.ImageDrawOptions{
|
||||
rt.DrawImage(fontImageId, &ebiten.DrawImageOptions{
|
||||
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.ImageDrawOptions{
|
||||
r.DrawImage(field, &ebiten.DrawImageOptions{
|
||||
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.ImageDrawOptions{
|
||||
op := &ebiten.DrawImageOptions{
|
||||
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.ImageDrawOptions{
|
||||
gophersRenderTarget.DrawImage(gophersImage, &ebiten.DrawImageOptions{
|
||||
GeometryMatrix: &geo,
|
||||
})
|
||||
|
||||
geo = ebiten.ScaleGeometry(mosaicRatio, mosaicRatio)
|
||||
screen.DrawImage(gophersRenderTarget, &ebiten.ImageDrawOptions{
|
||||
screen.DrawImage(gophersRenderTarget, &ebiten.DrawImageOptions{
|
||||
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.ImageDrawOptions{
|
||||
screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{
|
||||
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.ImageDrawOptions{
|
||||
if err := screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{
|
||||
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 := &ImageDrawOptions{
|
||||
option := &DrawImageOptions{
|
||||
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 *ImageDrawOptions) error {
|
||||
func (i *innerImage) drawImage(img *innerImage, option *DrawImageOptions) error {
|
||||
if option == nil {
|
||||
option = &ImageDrawOptions{}
|
||||
option = &DrawImageOptions{}
|
||||
}
|
||||
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 *ImageDrawOptions) (err error) {
|
||||
func (i *Image) DrawImage(image *Image, option *DrawImageOptions) (err error) {
|
||||
return i.drawImage(image.inner, option)
|
||||
}
|
||||
|
||||
func (i *Image) drawImage(image *innerImage, option *ImageDrawOptions) (err error) {
|
||||
func (i *Image) drawImage(image *innerImage, option *DrawImageOptions) (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 ImageDrawOptions struct {
|
||||
type DrawImageOptions struct {
|
||||
DstParts []image.Rectangle
|
||||
SrcParts []image.Rectangle
|
||||
GeometryMatrix *GeometryMatrix
|
||||
ColorMatrix *ColorMatrix
|
||||
}
|
||||
|
||||
func At(x, y int) *ImageDrawOptions {
|
||||
func At(x, y int) *DrawImageOptions {
|
||||
geo := TranslateGeometry(float64(x), float64(y))
|
||||
return &ImageDrawOptions{
|
||||
return &DrawImageOptions{
|
||||
GeometryMatrix: &geo,
|
||||
}
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ func DrawTexture(native gl.Texture, projectionMatrix [4][4]float64, quads []Text
|
||||
}()
|
||||
|
||||
// TODO: Fix this dirty hack after fixing https://github.com/go-gl/gl/issues/174
|
||||
v := (*int)(unsafe.Pointer(uintptr(4 * 0)))
|
||||
t := (*int)(unsafe.Pointer(uintptr(4 * 2)))
|
||||
v := (*int)(unsafe.Pointer(uintptr(short32Size * 0)))
|
||||
t := (*int)(unsafe.Pointer(uintptr(short32Size * 2)))
|
||||
vertexAttrLocation.AttribPointer(2, gl.FLOAT, false, stride, v)
|
||||
texCoordAttrLocation.AttribPointer(2, gl.FLOAT, false, stride, t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user