Module: Sevgi::Graphics::Mixtures::Duplicate::InstanceMethods

Defined in:
lib/sevgi/graphics/mixtures/duplicate.rb

Instance Method Summary collapse

Instance Method Details

#Duplicate(dx: nil, dy: nil, parent: nil, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sevgi/graphics/mixtures/duplicate.rb', line 8

def Duplicate(dx: nil, dy: nil, parent: nil, &block)
  duplicated = dup

  duplicated.Traverse do |element|
    element.children = element.children.map(&:dup)
    id = (element.attributes = element.attributes.dup).delete(:id)
    element[:_id] = id if id
    block&.call(element)
  end

  duplicated.Translate(dx, dy) if dx || dy

  duplicated.Adopt(parent)

  duplicated
end

#DuplicateH(dx, parent: nil, &block) ⇒ Object



25
26
27
# File 'lib/sevgi/graphics/mixtures/duplicate.rb', line 25

def DuplicateH(dx, parent: nil, &block)
  Duplicate(dx:, dy: 0, parent:, &block)
end

#DuplicateV(dy, parent: nil, &block) ⇒ Object



29
30
31
# File 'lib/sevgi/graphics/mixtures/duplicate.rb', line 29

def DuplicateV(dy, parent: nil, &block)
  Duplicate(dx: 0, dy:, parent:, &block)
end