mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
Resize gophers.jpg
This commit is contained in:
parent
642d77bb11
commit
6b0ae1cd18
Binary file not shown.
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 16 KiB |
@ -35,11 +35,11 @@ var (
|
|||||||
gophersRenderTarget *ebiten.Image
|
gophersRenderTarget *ebiten.Image
|
||||||
)
|
)
|
||||||
|
|
||||||
func Update(screen *ebiten.Image) error {
|
func update(screen *ebiten.Image) error {
|
||||||
geo := ebiten.ScaleGeometry(1.0/mosaicRatio, 1.0/mosaicRatio)
|
geo := ebiten.ScaleGeometry(1.0/mosaicRatio, 1.0/mosaicRatio)
|
||||||
ebiten.DrawImageGeometry(gophersRenderTarget, gophersImage, geo)
|
ebiten.DrawImageGeometry(gophersRenderTarget, gophersImage, geo)
|
||||||
|
|
||||||
geo = ebiten.ScaleGeometry(mosaicRatio/2.0, mosaicRatio/2.0)
|
geo = ebiten.ScaleGeometry(mosaicRatio, mosaicRatio)
|
||||||
ebiten.DrawImageGeometry(screen, gophersRenderTarget, geo)
|
ebiten.DrawImageGeometry(screen, gophersRenderTarget, geo)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
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)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ var (
|
|||||||
gophersImage *ebiten.Image
|
gophersImage *ebiten.Image
|
||||||
)
|
)
|
||||||
|
|
||||||
func Update(screen *ebiten.Image) error {
|
func update(screen *ebiten.Image) error {
|
||||||
dsts, srcs := []image.Rectangle{}, []image.Rectangle{}
|
dsts, srcs := []image.Rectangle{}, []image.Rectangle{}
|
||||||
w, h := gophersImage.Size()
|
w, h := gophersImage.Size()
|
||||||
for i := 0; i < h; i++ {
|
for i := 0; i < h; i++ {
|
||||||
@ -44,7 +44,6 @@ func Update(screen *ebiten.Image) error {
|
|||||||
}
|
}
|
||||||
maxWidth := float64(w) + float64(h)*0.75
|
maxWidth := float64(w) + float64(h)*0.75
|
||||||
geo := ebiten.TranslateGeometry(-maxWidth/2, -float64(h)/2)
|
geo := ebiten.TranslateGeometry(-maxWidth/2, -float64(h)/2)
|
||||||
geo.Concat(ebiten.ScaleGeometry(0.4, 0.4))
|
|
||||||
geo.Concat(ebiten.TranslateGeometry(screenWidth/2, screenHeight/2))
|
geo.Concat(ebiten.TranslateGeometry(screenWidth/2, screenHeight/2))
|
||||||
ebiten.DrawImagePartsGeometry(screen, dsts, gophersImage, srcs, geo)
|
ebiten.DrawImagePartsGeometry(screen, dsts, gophersImage, srcs, geo)
|
||||||
return nil
|
return nil
|
||||||
@ -56,7 +55,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
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)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ var (
|
|||||||
gophersImage *ebiten.Image
|
gophersImage *ebiten.Image
|
||||||
)
|
)
|
||||||
|
|
||||||
func Update(screen *ebiten.Image) error {
|
func update(screen *ebiten.Image) error {
|
||||||
count++
|
count++
|
||||||
if ebiten.IsKeyPressed(ebiten.KeyLeft) {
|
if ebiten.IsKeyPressed(ebiten.KeyLeft) {
|
||||||
horizontalCount--
|
horizontalCount--
|
||||||
@ -53,8 +53,8 @@ func Update(screen *ebiten.Image) error {
|
|||||||
|
|
||||||
w, h := gophersImage.Size()
|
w, h := gophersImage.Size()
|
||||||
geo := ebiten.TranslateGeometry(-float64(w)/2, -float64(h)/2)
|
geo := ebiten.TranslateGeometry(-float64(w)/2, -float64(h)/2)
|
||||||
scaleX := 0.5 * math.Pow(1.05, float64(horizontalCount))
|
scaleX := math.Pow(1.05, float64(horizontalCount))
|
||||||
scaleY := 0.5 * math.Pow(1.05, float64(verticalCount))
|
scaleY := math.Pow(1.05, float64(verticalCount))
|
||||||
geo.Concat(ebiten.ScaleGeometry(scaleX, scaleY))
|
geo.Concat(ebiten.ScaleGeometry(scaleX, scaleY))
|
||||||
geo.Concat(ebiten.RotateGeometry(float64(count%720) * 2 * math.Pi / 720))
|
geo.Concat(ebiten.RotateGeometry(float64(count%720) * 2 * math.Pi / 720))
|
||||||
geo.Concat(ebiten.TranslateGeometry(screenWidth/2, screenHeight/2))
|
geo.Concat(ebiten.TranslateGeometry(screenWidth/2, screenHeight/2))
|
||||||
@ -70,7 +70,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
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)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user