Skip to content

Instantly share code, notes, and snippets.

@Elv13
Created April 16, 2018 19:09
Show Gist options
  • Save Elv13/d86bb320c9fc9e14f8a6fbcc0af8e625 to your computer and use it in GitHub Desktop.
Save Elv13/d86bb320c9fc9e14f8a6fbcc0af8e625 to your computer and use it in GitHub Desktop.
local function draw(self, content, cr, width, height)
local c = self._private.client[1]
local s = surface(c.content)
local geo = c:geometry()
local scale = math.min(width/geo.width, height/geo.height)
local w, h = geo.width*scale, geo.height*scale
local dx, dy = (width-w)/2, (height-h)/2
cr:translate(dx, dy)
shape.rounded_rect(cr, w, h)
cr:clip()
cr:scale(scale, scale)
cr:set_source_surface(s)
cr:paint()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment