From d11b8498af8beaa4b79a2cc7382190fe5c32a7b1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 28 Dec 2016 11:37:49 +0900 Subject: [PATCH] Updated Tutorial:Screen, colors and squares (markdown) --- Tutorial:Screen,-colors-and-squares.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Tutorial:Screen,-colors-and-squares.md b/Tutorial:Screen,-colors-and-squares.md index 484d4f4..d383bf0 100644 --- a/Tutorial:Screen,-colors-and-squares.md +++ b/Tutorial:Screen,-colors-and-squares.md @@ -186,21 +186,21 @@ Our text is covered by the new image. We'll need to set the position of the imag # Image transforming -There's no position configuration in Ebiten, but you can get the same result by transforming your images. There are many ways to transform your images in Ebiten, but we'll only talk the basic `x`, `y` position translate in this chapter. +To put an image at a position as you like, there's only one way to specify geometry matrix when drawing an image. The geometry matrix is affine matrix and you can translate, enlarge or rotate the image with it. -What we need is to add the `translate` effect to the `option struct` by using `Translate(tx, ty float64)` function, `float64` is the floating point data type, and here're the two parameters that you'll need to pass to the function: +What we need is to add the `translate` effect to the `DrawImageOptions` struct by using `Translate(tx, ty float64)` function. `float64` is the floating point data type, and here're the two parameters that you'll need to pass to the function: -* `tx` Is the distance from the left, it's also called as the x offset. -* `ty` Is the distance from the top, and it's also called as the y offset. +* `tx` Is the distance from the left. It's also called as the x offset. +* `ty` Is the distance from the top. It's also called as the y offset. So right now, let's add another code to tell the render function that we want to translate the new image while rendering it. ```go -// The previous empty option struct -opts := &ebiten.DrawImageOptions{} + // The previous empty option struct + opts := &ebiten.DrawImageOptions{} -// Add the Translate effect to the option struct. -opts.GeoM.Translate(64, 64) + // Add the Translate effect to the option struct. + opts.GeoM.Translate(64, 64) ``` Save your file, execute your game, and you'll see the new image is 64 pixels far from the top and the left of the screen.