@@ -3,8 +3,6 @@ package tmx
3
3
import (
4
4
"image"
5
5
"path/filepath"
6
-
7
- "github.com/disintegration/imaging"
8
6
)
9
7
10
8
//Renderer renders
@@ -17,6 +15,7 @@ type fullRenderer struct {
17
15
canvas Canvas
18
16
m Map
19
17
loader ResourceLocator
18
+ tf TileFlipper
20
19
}
21
20
22
21
//NewRenderer lets you draw the map on a custom canvas
@@ -27,7 +26,18 @@ func NewRenderer(m Map, c Canvas) Renderer {
27
26
28
27
//NewRendererWithResourceLocator return a new renderer
29
28
func NewRendererWithResourceLocator (m Map , c Canvas , locator ResourceLocator ) Renderer {
30
- return & fullRenderer {m : m , canvas : c , loader : locator }
29
+ return NewRendererWithResourceLocatorAndTileFlipper (m , c , locator , & imagingFlipper {})
30
+ }
31
+
32
+ //NewRendererWithResourceLocatorAndTileFlipper allows you to specify
33
+ //a custom canvas, locator and TileFlipper
34
+ func NewRendererWithResourceLocatorAndTileFlipper (
35
+ m Map ,
36
+ c Canvas ,
37
+ locator ResourceLocator ,
38
+ tf TileFlipper ,
39
+ ) Renderer {
40
+ return & fullRenderer {m : m , canvas : c , loader : locator , tf : tf }
31
41
}
32
42
33
43
//Render will generate a preview image of the tmx map provided
@@ -90,15 +100,15 @@ func (t *tilemap) renderLayer(r fullRenderer) error {
90
100
tile := ptileset .SubImage (tileBounds )
91
101
92
102
if dt .DiagonalFlip {
93
- tile = imaging . FlipH ( imaging . Rotate270 (tile ) )
103
+ tile = r . tf . FlipDiagonal (tile )
94
104
}
95
105
96
106
if dt .HorizontalFlip {
97
- tile = imaging . FlipH (tile )
107
+ tile = r . tf . FlipHorizontal (tile )
98
108
}
99
109
100
110
if dt .VerticalFlip {
101
- tile = imaging . FlipV (tile )
111
+ tile = r . tf . FlipVertical (tile )
102
112
}
103
113
104
114
x := (i % l .Width ) * t .subject .TileWidth
0 commit comments