mirror of
https://github.com/airstruck/luigi.git
synced 2026-02-22 03:46:52 -07:00
word wrap
This commit is contained in:
@@ -14,10 +14,12 @@ end })
|
||||
|
||||
function Image:constructor (renderer, path)
|
||||
self.sdlRenderer = renderer
|
||||
self.sdlSurface = SDL2_image.IMG_Load(path)
|
||||
ffi.gc(self.sdlSurface, sdl.freeSurface)
|
||||
self.sdlTexture = sdl.createTextureFromSurface(renderer, self.sdlSurface)
|
||||
ffi.gc(self.sdlTexture, sdl.destroyTexture)
|
||||
self.sdlSurface = ffi.gc(
|
||||
SDL2_image.IMG_Load(path),
|
||||
sdl.freeSurface)
|
||||
self.sdlTexture = ffi.gc(
|
||||
sdl.createTextureFromSurface(renderer, self.sdlSurface),
|
||||
sdl.destroyTexture)
|
||||
self.width = self.sdlSurface.w
|
||||
self.height = self.sdlSurface.h
|
||||
end
|
||||
@@ -30,17 +32,4 @@ function Image:getHeight ()
|
||||
return self.height
|
||||
end
|
||||
|
||||
function Image:draw (x, y, sx, sy)
|
||||
local w = self.width * (sx or 1)
|
||||
local h = self.height * (sy or 1)
|
||||
|
||||
-- HACK. Somehow drawing something first prevents renderCopy from
|
||||
-- incorrectly scaling up in some cases (after rendering slices).
|
||||
-- For example http://stackoverflow.com/questions/28218906
|
||||
sdl.renderDrawPoint(self.sdlRenderer, -1, -1)
|
||||
|
||||
-- Draw the image.
|
||||
sdl.renderCopy(self.sdlRenderer, self.sdlTexture, nil, sdl.Rect(x, y, w, h))
|
||||
end
|
||||
|
||||
return Image
|
||||
|
||||
Reference in New Issue
Block a user