Class: Emfsvg::Svg::Elements::Circle

Inherits:
Emfsvg::Svg::Element show all
Defined in:
lib/emfsvg/svg/elements/circle.rb

Overview

— equivalent to with rx=ry=r.

Constant Summary collapse

ELEMENT_NAME =
"circle"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Emfsvg::Svg::Element

#children, #element_name, register

Constructor Details

#initialize(cx:, cy:, r:, fill:, stroke:, clip_path: nil) ⇒ Circle

Returns a new instance of Circle.



13
14
15
16
17
18
19
20
# File 'lib/emfsvg/svg/elements/circle.rb', line 13

def initialize(cx:, cy:, r:, fill:, stroke:, clip_path: nil)
  @cx = cx
  @cy = cy
  @r = r
  @fill = fill
  @stroke = stroke
  @clip_path = clip_path
end

Instance Attribute Details

#clip_pathObject (readonly)

Returns the value of attribute clip_path.



11
12
13
# File 'lib/emfsvg/svg/elements/circle.rb', line 11

def clip_path
  @clip_path
end

#cxObject (readonly)

Returns the value of attribute cx.



11
12
13
# File 'lib/emfsvg/svg/elements/circle.rb', line 11

def cx
  @cx
end

#cyObject (readonly)

Returns the value of attribute cy.



11
12
13
# File 'lib/emfsvg/svg/elements/circle.rb', line 11

def cy
  @cy
end

#fillObject (readonly)

Returns the value of attribute fill.



11
12
13
# File 'lib/emfsvg/svg/elements/circle.rb', line 11

def fill
  @fill
end

#rObject (readonly)

Returns the value of attribute r.



11
12
13
# File 'lib/emfsvg/svg/elements/circle.rb', line 11

def r
  @r
end

#strokeObject (readonly)

Returns the value of attribute stroke.



11
12
13
# File 'lib/emfsvg/svg/elements/circle.rb', line 11

def stroke
  @stroke
end

Class Method Details

.from_node(node) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/emfsvg/svg/elements/circle.rb', line 22

def self.from_node(node)
  new(
    cx: AttributeParser.float(node["cx"]),
    cy: AttributeParser.float(node["cy"]),
    r: AttributeParser.float(node["r"]),
    **Stylable.parse_style(node)
  )
end

Instance Method Details

#to_ellipseObject



31
32
33
34
# File 'lib/emfsvg/svg/elements/circle.rb', line 31

def to_ellipse
  Ellipse.new(cx: cx, cy: cy, rx: r, ry: r, fill: fill, stroke: stroke,
              clip_path: clip_path)
end