implement circle arc feature, no tests
parent
599e363e38
commit
573a1e9e30
|
|
@ -1,7 +1,7 @@
|
||||||
circle
|
circle
|
||||||
------
|
------
|
||||||
|
|
||||||
Draw a circle centered at the given coordinates
|
Draw a partial or complete circle centered at the given coordinates
|
||||||
|
|
||||||
Options
|
Options
|
||||||
^^^^^^^
|
^^^^^^^
|
||||||
|
|
@ -14,6 +14,26 @@ radius
|
||||||
|
|
||||||
radius of the circle. Supports :doc:`/units`.
|
radius of the circle. Supports :doc:`/units`.
|
||||||
|
|
||||||
|
arc_start
|
||||||
|
default: ``0``
|
||||||
|
|
||||||
|
angle on the circle to start an arc
|
||||||
|
|
||||||
|
arc_end
|
||||||
|
default: ``2 * Math::PI``
|
||||||
|
|
||||||
|
angle on the circle to end an arc
|
||||||
|
|
||||||
|
arc_ccw
|
||||||
|
default: ``false``
|
||||||
|
|
||||||
|
draw the arc counterclockwise instead of clockwise
|
||||||
|
|
||||||
|
arc_close
|
||||||
|
default: ``false``
|
||||||
|
|
||||||
|
draw a straight line closing the arc
|
||||||
|
|
||||||
.. include:: /args/draw.rst
|
.. include:: /args/draw.rst
|
||||||
.. include:: /args/range.rst
|
.. include:: /args/range.rst
|
||||||
.. include:: /args/layout.rst
|
.. include:: /args/layout.rst
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@ module Squib
|
||||||
cx2: 0 , cy2: 0,
|
cx2: 0 , cy2: 0,
|
||||||
inner_radius: 50, outer_radius: 100,
|
inner_radius: 50, outer_radius: 100,
|
||||||
radius: 100,
|
radius: 100,
|
||||||
n: 5, }
|
n: 5,
|
||||||
|
arc_start: 0, arc_end: 2 * Math::PI, arc_ccw: false, arc_close: false,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.expanding_parameters
|
def self.expanding_parameters
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ module Squib
|
||||||
:operator=, :show_page, :clip, :transform, :mask, :create_pango_layout,
|
:operator=, :show_page, :clip, :transform, :mask, :create_pango_layout,
|
||||||
:antialias=, :curve_to, :matrix, :matrix=, :identity_matrix, :pango_layout_path,
|
:antialias=, :curve_to, :matrix, :matrix=, :identity_matrix, :pango_layout_path,
|
||||||
:stroke_preserve, :target, :new_path, :fill_preserve, :close_path,
|
:stroke_preserve, :target, :new_path, :fill_preserve, :close_path,
|
||||||
:set_line_join, :set_line_cap, :set_dash
|
:set_line_join, :set_line_cap, :set_dash, :arc, :arc_negative
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
# @api private
|
# @api private
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,15 @@ module Squib
|
||||||
def circle(box, draw)
|
def circle(box, draw)
|
||||||
x, y, r = box.x, box.y, box.radius
|
x, y, r = box.x, box.y, box.radius
|
||||||
use_cairo do |cc|
|
use_cairo do |cc|
|
||||||
cc.move_to(x + r, y)
|
# cc.move_to(x + r, y)
|
||||||
cc.circle(x, y, r)
|
if box.arc_ccw
|
||||||
|
cc.arc_negative(x, y, r, box.arc_start, box.arc_end)
|
||||||
|
else
|
||||||
|
cc.arc(x, y, r, box.arc_start, box.arc_end)
|
||||||
|
end
|
||||||
|
if box.arc_close
|
||||||
|
cc.close_path();
|
||||||
|
end
|
||||||
cc.fill_n_stroke(draw)
|
cc.fill_n_stroke(draw)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue