gears.shape: Add arrow shape
This commit is contained in:
parent
1060a3487e
commit
a89b21ba2f
|
@ -101,6 +101,30 @@ function module.rectangular_tag(cr, width, height)
|
||||||
cr:close_path()
|
cr:close_path()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- A simple arrow shape
|
||||||
|
-- @param cr A cairo context
|
||||||
|
-- @tparam number width The shape with
|
||||||
|
-- @tparam number height The shape height
|
||||||
|
-- @tparam[opt=head_width] number head_width The width of the head (/\) of the arrow
|
||||||
|
-- @tparam[opt=width /2] number shaft_width The width of the shaft of the arrow
|
||||||
|
-- @tparam[opt=height/2] number shaft_length The head_length of the shaft (the rest is the head)
|
||||||
|
function module.arrow(cr, width, height, head_width, shaft_width, shaft_length)
|
||||||
|
local shaft_length = shaft_length or height / 2
|
||||||
|
local shaft_width = shaft_width or width / 2
|
||||||
|
local head_width = head_width or width
|
||||||
|
local head_length = height - shaft_length
|
||||||
|
|
||||||
|
cr:move_to ( width/2 , 0 )
|
||||||
|
cr:rel_line_to( head_width/2 , head_length )
|
||||||
|
cr:rel_line_to( -(head_width-shaft_width)/2 , 0 )
|
||||||
|
cr:rel_line_to( 0 , shaft_length )
|
||||||
|
cr:rel_line_to( -shaft_width , 0 )
|
||||||
|
cr:rel_line_to( 0 , -shaft_length )
|
||||||
|
cr:rel_line_to( -(head_width-shaft_width)/2 , 0 )
|
||||||
|
|
||||||
|
cr:close_path()
|
||||||
|
end
|
||||||
|
|
||||||
--- Ajust the shape using a transformation object
|
--- Ajust the shape using a transformation object
|
||||||
--
|
--
|
||||||
-- Apply various transformations to the shape
|
-- Apply various transformations to the shape
|
||||||
|
|
Loading…
Reference in New Issue