shape: Add cross shape

This commit is contained in:
Emmanuel Lepage Vallee 2016-03-09 23:41:32 -05:00
parent 5dbffc73c1
commit f0bf642f32
1 changed files with 24 additions and 0 deletions

View File

@ -187,6 +187,30 @@ function module.isosceles_triangle(cr, width, height)
cr:close_path()
end
--- A cross (**+**) symbol
-- @param cr A cairo context
-- @tparam number width The shape width
-- @tparam number height The shape height
-- @tparam[opt=width/3] number thickness The cross section thickness
function module.cross(cr, width, height, thickness)
thickness = thickness or width/3
local xpadding = (width - thickness) / 2
local ypadding = (height - thickness) / 2
cr:move_to(xpadding, 0)
cr:line_to(width - xpadding, 0)
cr:line_to(width - xpadding, ypadding)
cr:line_to(width , ypadding)
cr:line_to(width , height-ypadding)
cr:line_to(width - xpadding, height-ypadding)
cr:line_to(width - xpadding, height )
cr:line_to(xpadding , height )
cr:line_to(xpadding , height-ypadding)
cr:line_to(0 , height-ypadding)
cr:line_to(0 , ypadding )
cr:line_to(xpadding , ypadding )
cr:close_path()
end
--- Ajust the shape using a transformation object
--
-- Apply various transformations to the shape