From bc16b75ff5d2c81bde18e54a1ad24519b0594aa1 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 9 Mar 2016 23:42:29 -0500 Subject: [PATCH] shape: Add parallelogram shape --- lib/gears/shape.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/gears/shape.lua b/lib/gears/shape.lua index 9ee7d4b8..552fe0ed 100644 --- a/lib/gears/shape.lua +++ b/lib/gears/shape.lua @@ -249,6 +249,21 @@ function module.rectangle(cr, width, height) cr:rectangle(0, 0, width, height) end +--- A diagonal parallelogram with the bottom left corner at x=0 and top right +-- at x=width. +-- @param cr A cairo context +-- @tparam number width The shape width +-- @tparam number height The shape height +-- @tparam[opt=width/3] number base_width The parallelogram base width +function module.parallelogram(cr, width, height, base_width) + base_width = base_width or width/3 + cr:move_to(width-base_width, 0 ) + cr:line_to(width , 0 ) + cr:line_to(base_width , height ) + cr:line_to(0 , height ) + cr:close_path() +end + --- Ajust the shape using a transformation object -- -- Apply various transformations to the shape