Class: RGhost::Circle
Overview
Draw a circle to the current path(or current row by default).
Options
-
:x and :y
- as center of the circle. -
:radius
- as radius(in points). -
:ang1
- the angle of a vector from (:x , :y ) of length :radius to the first endpoint of the circle. -
:ang2
- the angle of a vector from (:x, :y) of length :radius to the second endpoint of the circle. -
:content
- facade to ShapeContent with same parameters. -
:border
- facade to Border with same parameters. -
:use
- :arc draw counterclockwise and :arcn (arc negative) clockwise direction.
Examples using facade circle method inside of Document
d=Document.new
d.circle :x => 5, :y => 2.5 , :radius => 40
d=Document.new
d.circle :x => 5, :y => 2.5 , :radius => 40, :content => {:fill => false}
d=Document.new
d.circle :x => 5, :y => 2.5 , :radius => 40, :content => {:color => "#FF0000"}
d=Document.new
d.circle :x => 5, :y => 2.5 , :radius => 40, :content => {:color => "#FF0000"} ,:border => {:color => "#FFFFFF"}
d=Document.new
d.circle :x => 5, :y => 2.5 , :radius => 40, :content => {:color => :yellow} ,:border => {:color => :orange, :dash => [1,2,1,2], :width => 20}
d=Document.new
colors=%w[#98AE09 #AFE099 #A971FF #CC1010 #FF7201 #34FEE1]
6.downto(1) do |v|
d.circle :x => 5, :y => 2.5 , :radius => v*10, :content =>{:color => colors[v]}
end
d=Document.new d.circle :x => 5, :y => 2.5 , :ang1 => 90, :radius => 50, :content => {:fill => false }
d=Document.new d.circle :x => 5, :y => 2.5 , :ang2 => 90, :radius => 50, :content => {:fill => false }
d=Document.new d.circle :x => 5, :y => 2.5 , :ang2 => 90, :radius => 50, :content =>=> :green
d=Document.new d.circle :x => 5, :y => 2.5 , :ang2 => 90, :use => :arcn, :radius => 50, :content =>=> :green
Examples using Circle class
d=Document.new
d.scale(3,1)
d.set Circle.new(:x => 1.5, :y => 1.5 , :ang2 => 180, :radius => 25)
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :x => :limit_left, :y=> :current_row, :radius => 50, :ang1 => 0, :ang2 => 360 , :use => :arc, :content => RGhost::ShapeContent::DEFAULT_OPTIONS, :border => RGhost::Border::DEFAULT_OPTIONS }
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Circle
constructor
A new instance of Circle.
- #ps ⇒ Object
Methods inherited from PsObject
#<<, #call, #graphic_scope, #raw, #set, #to_s
Constructor Details
#initialize(options = {}) ⇒ Circle
Returns a new instance of Circle.
83 84 85 86 |
# File 'lib/rghost/circle.rb', line 83 def initialize(={}) super(''){} @options=DEFAULT_OPTIONS.dup.merge() end |
Instance Method Details
#ps ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/rghost/circle.rb', line 88 def ps x,y= RGhost::Units::parse(@options[:x]), RGhost::Units::parse(@options[:y]) #with parse graph=RGhost::Graphic.new graph.raw :newpath graph.set RGhost::Border.new(@options[:border]) if @options[:border] graph.raw "#{x} #{y} #{@options[:radius]} #{@options[:ang1]} #{@options[:ang2]} #{@options[:use]} " graph.set RGhost::ShapeContent.new(@options[:content]) if @options[:content] graph.raw :stroke graph end |