Module: Sevgi::Graphics::Mixtures::Replicate::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#Replicate(nx: Undefined, dx: Undefined, ix: nil, ny: Undefined, dy: Undefined, iy: nil, id: nil, &block) ⇒ Object

rubocop:disable Metrics/MethodLength



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sevgi/graphics/mixtures/replicate.rb', line 9

def Replicate(nx: Undefined, dx: Undefined, ix: nil, ny: Undefined, dy: Undefined, iy: nil, id: nil, &block)
  Ensure.without_block(block, nx:, dx:, ny:, dy:)

  With do |base|
    layer(id:) do
      row = layer do
        (nx - 1).times do |time|
          base.DuplicateH((time + 1) * dx, parent: self)
        end
      end

      base.AdoptFirst(row)

      (ny - 1).times do |time|
        row.DuplicateV((time + 1) * dy)
      end
    end.tap do |element|
      IdentifyAsTable(element.children, ix:, iy:)
    end
  end
end

#ReplicateH(n: Undefined, d: Undefined, i: nil, id: nil, &block) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sevgi/graphics/mixtures/replicate.rb', line 31

def ReplicateH(n: Undefined, d: Undefined, i: nil, id: nil, &block)
  Ensure.without_block(block, n:, d:)

  With do |base|
    layer(id:) do
      (n - 1).times { |time| base.DuplicateH((time + 1) * d, parent: self) }
    end.tap do |element|
      base.AdoptFirst(element)
      IdentifyAsList(element.children, i)
    end
  end
end

#ReplicateV(n: Undefined, d: Undefined, i: nil, id: nil, &block) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/sevgi/graphics/mixtures/replicate.rb', line 44

def ReplicateV(n: Undefined, d: Undefined, i: nil, id: nil, &block)
  Ensure.without_block(block, n:, d:)

  With do |base|
    layer(id:) do
      (n - 1).times { |time| base.DuplicateV((time + 1) * d, parent: self) }
    end.tap do |element|
      base.AdoptFirst(element)
      IdentifyAsList(element.children, i)
    end
  end
end

#Tile(symbol = Undefined, nx: Undefined, dx: Undefined, ix: nil, ny: Undefined, dy: Undefined, iy: nil, id: nil, &block) ⇒ Object



57
58
59
60
61
62
# File 'lib/sevgi/graphics/mixtures/replicate.rb', line 57

def Tile(symbol = Undefined, nx: Undefined, dx: Undefined, ix: nil, ny: Undefined, dy: Undefined, iy: nil, id: nil, &block)
  Ensure.with_block(block, symbol:, nx:, dx:, ny:, dy:)

  symbol!(id: symbol).Within(&block)
  use("xlink:href": "##{symbol}").Replicate(nx:, dx:, ix:, ny:, dy:, iy:, id:)
end

#TileH(symbol = Undefined, n: Undefined, d: Undefined, i: nil, id: nil, &block) ⇒ Object



64
65
66
67
68
69
# File 'lib/sevgi/graphics/mixtures/replicate.rb', line 64

def TileH(symbol = Undefined, n: Undefined, d: Undefined, i: nil, id: nil, &block)
  Ensure.with_block(block, symbol:, n:, d:)

  symbol!(id: symbol).Within(&block)
  use("xlink:href": "##{symbol}").ReplicateH(n:, d:, i:, id:)
end

#TileV(symbol = Undefined, n: Undefined, d: Undefined, i: nil, id: nil, &block) ⇒ Object



71
72
73
74
75
76
# File 'lib/sevgi/graphics/mixtures/replicate.rb', line 71

def TileV(symbol = Undefined, n: Undefined, d: Undefined, i: nil, id: nil, &block)
  Ensure.with_block(block, symbol:, n:, d:)

  symbol!(id: symbol).Within(&block)
  use("xlink:href": "##{symbol}").ReplicateV(n:, d:, i:, id:)
end