From 0bf76dc984f01fb5b5c0acca57c8d7e89ea7ac58 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 26 Jan 2016 02:39:48 -0500 Subject: [PATCH] gears.shape: Add powerline shape --- lib/gears/shape.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/gears/shape.lua b/lib/gears/shape.lua index 453e9753e..cc6b4339b 100644 --- a/lib/gears/shape.lua +++ b/lib/gears/shape.lua @@ -140,6 +140,23 @@ function module.hexagon(cr, width, height) cr:close_path() end +--- Double arrow popularized by the vim-powerline module +-- @param cr A cairo context +-- @tparam number width The shape with +-- @tparam number height The shape height +-- @tparam[opt=height/2] number arrow_depth The width of the arrow part of the shape +function module.powerline(cr, width, height, arrow_depth) + local arrow_depth = arrow_depth or height/2 + cr:move_to(0 , 0 ) + cr:line_to(width - arrow_depth , 0 ) + cr:line_to(width , height/2 ) + cr:line_to(width - arrow_depth , height ) + cr:line_to(0 , height ) + cr:line_to(arrow_depth , height/2 ) + + cr:close_path() +end + --- Ajust the shape using a transformation object -- -- Apply various transformations to the shape