Resize gophers.jpg

This commit is contained in:
Hajime Hoshi 2014-12-24 09:52:17 +09:00
parent 642d77bb11
commit 6b0ae1cd18
4 changed files with 9 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -35,11 +35,11 @@ var (
gophersRenderTarget *ebiten.Image
)
func Update(screen *ebiten.Image) error {
func update(screen *ebiten.Image) error {
geo := ebiten.ScaleGeometry(1.0/mosaicRatio, 1.0/mosaicRatio)
ebiten.DrawImageGeometry(gophersRenderTarget, gophersImage, geo)
geo = ebiten.ScaleGeometry(mosaicRatio/2.0, mosaicRatio/2.0)
geo = ebiten.ScaleGeometry(mosaicRatio, mosaicRatio)
ebiten.DrawImageGeometry(screen, gophersRenderTarget, geo)
return nil
}
@ -55,7 +55,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if err := ebiten.Run(Update, screenWidth, screenHeight, 2, "Mosaic (Ebiten Demo)"); err != nil {
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Mosaic (Ebiten Demo)"); err != nil {
log.Fatal(err)
}
}

View File

@ -33,7 +33,7 @@ var (
gophersImage *ebiten.Image
)
func Update(screen *ebiten.Image) error {
func update(screen *ebiten.Image) error {
dsts, srcs := []image.Rectangle{}, []image.Rectangle{}
w, h := gophersImage.Size()
for i := 0; i < h; i++ {
@ -44,7 +44,6 @@ func Update(screen *ebiten.Image) error {
}
maxWidth := float64(w) + float64(h)*0.75
geo := ebiten.TranslateGeometry(-maxWidth/2, -float64(h)/2)
geo.Concat(ebiten.ScaleGeometry(0.4, 0.4))
geo.Concat(ebiten.TranslateGeometry(screenWidth/2, screenHeight/2))
ebiten.DrawImagePartsGeometry(screen, dsts, gophersImage, srcs, geo)
return nil
@ -56,7 +55,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if err := ebiten.Run(Update, screenWidth, screenHeight, 2, "Perspective (Ebiten Demo)"); err != nil {
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Perspective (Ebiten Demo)"); err != nil {
log.Fatal(err)
}
}

View File

@ -36,7 +36,7 @@ var (
gophersImage *ebiten.Image
)
func Update(screen *ebiten.Image) error {
func update(screen *ebiten.Image) error {
count++
if ebiten.IsKeyPressed(ebiten.KeyLeft) {
horizontalCount--
@ -53,8 +53,8 @@ func Update(screen *ebiten.Image) error {
w, h := gophersImage.Size()
geo := ebiten.TranslateGeometry(-float64(w)/2, -float64(h)/2)
scaleX := 0.5 * math.Pow(1.05, float64(horizontalCount))
scaleY := 0.5 * math.Pow(1.05, float64(verticalCount))
scaleX := math.Pow(1.05, float64(horizontalCount))
scaleY := math.Pow(1.05, float64(verticalCount))
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))
@ -70,7 +70,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if err := ebiten.Run(Update, screenWidth, screenHeight, 2, "Image (Ebiten Demo)"); err != nil {
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Image (Ebiten Demo)"); err != nil {
log.Fatal(err)
}
}