Class: Emfsvg::Svg::Elements::Rect

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

Overview

Produces EMR_RECTANGLE (no rx/ry) or EMR_ROUNDRECT (rx/ry present).

Constant Summary collapse

ELEMENT_NAME =
"rect"

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(x:, y:, width:, height:, rx:, ry:, fill:, stroke:, clip_path: nil) ⇒ Rect

Returns a new instance of Rect.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/emfsvg/svg/elements/rect.rb', line 14

def initialize(x:, y:, width:, height:, rx:, ry:, fill:, stroke:, clip_path: nil)
  @x = x
  @y = y
  @width = width
  @height = height
  @rx = rx
  @ry = ry
  @fill = fill
  @stroke = stroke
  @clip_path = clip_path
end

Instance Attribute Details

#clip_pathObject (readonly)

Returns the value of attribute clip_path.



12
13
14
# File 'lib/emfsvg/svg/elements/rect.rb', line 12

def clip_path
  @clip_path
end

#fillObject (readonly)

Returns the value of attribute fill.



12
13
14
# File 'lib/emfsvg/svg/elements/rect.rb', line 12

def fill
  @fill
end

#heightObject (readonly)

Returns the value of attribute height.



12
13
14
# File 'lib/emfsvg/svg/elements/rect.rb', line 12

def height
  @height
end

#rxObject (readonly)

Returns the value of attribute rx.



12
13
14
# File 'lib/emfsvg/svg/elements/rect.rb', line 12

def rx
  @rx
end

#ryObject (readonly)

Returns the value of attribute ry.



12
13
14
# File 'lib/emfsvg/svg/elements/rect.rb', line 12

def ry
  @ry
end

#strokeObject (readonly)

Returns the value of attribute stroke.



12
13
14
# File 'lib/emfsvg/svg/elements/rect.rb', line 12

def stroke
  @stroke
end

#widthObject (readonly)

Returns the value of attribute width.



12
13
14
# File 'lib/emfsvg/svg/elements/rect.rb', line 12

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



12
13
14
# File 'lib/emfsvg/svg/elements/rect.rb', line 12

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



12
13
14
# File 'lib/emfsvg/svg/elements/rect.rb', line 12

def y
  @y
end

Class Method Details

.from_node(node) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/emfsvg/svg/elements/rect.rb', line 26

def self.from_node(node)
  new(
    x: AttributeParser.float(node["x"]),
    y: AttributeParser.float(node["y"]),
    width: AttributeParser.float(node["width"]),
    height: AttributeParser.float(node["height"]),
    rx: AttributeParser.float(node["rx"]),
    ry: AttributeParser.float(node["ry"]),
    **Stylable.parse_style(node)
  )
end

Instance Method Details

#rounded?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/emfsvg/svg/elements/rect.rb', line 38

def rounded?
  rx.positive? || ry.positive?
end