Skip to content

Commit

Permalink
remove return value
Browse files Browse the repository at this point in the history
  • Loading branch information
JiepengTan committed Jul 3, 2024
1 parent 283112a commit e7b8b95
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions spgdi.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (p *spriteDrawInfo) getUpdateRotateRect(x, y float64) *math32.RotatedRect {
c := p.sprite.costumes[p.sprite.costumeIndex_]

img, centerX, centerY := c.needImage(p.sprite.g.fs)
centerX, centerY = p.sprite.applyImagePivot(c, centerX, centerY)
p.sprite.applyPivot(c, &centerX, &centerY)
rect := image.Rectangle{}
rect.Min.X = 0
rect.Min.Y = 0
Expand All @@ -135,7 +135,7 @@ func (p *spriteDrawInfo) updateMatrix() {
c := p.sprite.costumes[p.sprite.costumeIndex_]

img, centerX, centerY := c.needImage(p.sprite.g.fs)
centerX, centerY = p.sprite.applyImagePivot(c, centerX, centerY)
p.sprite.applyPivot(c, &centerX, &centerY)
rect := image.Rectangle{}
rect.Min.X = 0
rect.Min.Y = 0
Expand Down Expand Up @@ -219,7 +219,7 @@ func (p *Sprite) touchPoint(x, y float64) bool {
}
c := p.costumes[p.costumeIndex_]
img, cx, cy := c.needImage(p.g.fs)
cx, cy = p.applyImagePivot(c, cx, cy)
p.applyPivot(c, &cx, &cy)
geo := p.getDrawInfo().getPixelGeo(cx, cy)

pixel, _ := p.getDrawInfo().getPixel(pos, img, geo)
Expand Down Expand Up @@ -252,7 +252,7 @@ func (p *Sprite) touchRotatedRect(dstRect *math32.RotatedRect) bool {
}
c := p.costumes[p.costumeIndex_]
img, cx, cy := c.needImage(p.g.fs)
cx, cy = p.applyImagePivot(c, cx, cy)
p.applyPivot(c, &cx, &cy)
geo := p.getDrawInfo().getPixelGeo(cx, cy)

//check boun rect pixel
Expand Down Expand Up @@ -289,12 +289,12 @@ func (p *Sprite) touchedColor_(dst *Sprite, color Color) bool {

c := p.costumes[p.costumeIndex_]
pimg, cx, cy := c.needImage(p.g.fs)
cx, cy = p.applyImagePivot(c, cx, cy)
p.applyPivot(c, &cx, &cy)
geo := p.getDrawInfo().getPixelGeo(cx, cy)

c2 := dst.costumes[dst.costumeIndex_]
dstimg, cx2, cy2 := c2.needImage(p.g.fs)
cx2, cy2 = dst.applyImagePivot(c2, cx2, cy2)
dst.applyPivot(c2, &cx2, &cy2)
geo2 := dst.getDrawInfo().getPixelGeo(cx2, cy2)

cr, cg, cb, ca := color.RGBA()
Expand Down Expand Up @@ -339,12 +339,12 @@ func (p *Sprite) touchingSprite(dst *Sprite) bool {

c := p.costumes[p.costumeIndex_]
pimg, cx, cy := c.needImage(p.g.fs)
cx, cy = p.applyImagePivot(c, cx, cy)
p.applyPivot(c, &cx, &cy)
geo := p.getDrawInfo().getPixelGeo(cx, cy)

c2 := dst.costumes[dst.costumeIndex_]
dstimg, cx2, cy2 := c2.needImage(p.g.fs)
cx2, cy2 = dst.applyImagePivot(c2, cx2, cy2)
dst.applyPivot(c2, &cx2, &cy2)
geo2 := dst.getDrawInfo().getPixelGeo(cx2, cy2)
//check boun rect pixel
for x := boundRect.X; x < boundRect.Width+boundRect.X; x++ {
Expand Down Expand Up @@ -419,7 +419,7 @@ func (p *Sprite) hit(hc hitContext) (hr hitResult, ok bool) {
}
c := p.costumes[p.costumeIndex_]
img, cx, cy := c.needImage(p.g.fs)
cx, cy = p.applyImagePivot(c, cx, cy)
p.applyPivot(c, &cx, &cy)
geo := p.getDrawInfo().getPixelGeo(cx, cy)
color1, pos := p.getDrawInfo().getPixel(pos, img, geo)
if debugInstr {
Expand All @@ -432,8 +432,7 @@ func (p *Sprite) hit(hc hitContext) (hr hitResult, ok bool) {
return hitResult{Target: p}, true
}

func (p *Sprite) applyImagePivot(c *costume, cx, cy float64) (float64, float64) {
cx += p.pivot.X * float64(c.bitmapResolution)
cy -= p.pivot.Y * float64(c.bitmapResolution)
return cx, cy
func (p *Sprite) applyPivot(c *costume, cx, cy *float64) {
*cx += p.pivot.X * float64(c.bitmapResolution)
*cy -= p.pivot.Y * float64(c.bitmapResolution)
}

0 comments on commit e7b8b95

Please sign in to comment.