Class: QrForge::Components::EyeOuter::Square

Inherits:
ForgeComponent show all
Defined in:
lib/qr_forge/components/eye_outer/square.rb

Instance Method Summary collapse

Methods inherited from ForgeComponent

#initialize

Constructor Details

This class inherits a constructor from QrForge::Components::ForgeComponent

Instance Method Details

#draw(y:, x:, quiet_zone:, area:, color: "black", **_) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/qr_forge/components/eye_outer/square.rb', line 8

def draw(y:, x:, quiet_zone:, area:, color: "black", **_)
  x += quiet_zone
  y += quiet_zone

  # Draw the outer black square (7x7)
  @xml_builder.rect(
    x:,
    y:,
    width: area,
    height: area,
    fill: color
  )

  # Draw the inner (cutout) square (5x5) to create the finder pattern
  inset = 1
  inner = area - 2

  @xml_builder.rect(
    x: x + inset,
    y: y + inset,
    width: inner,
    height: inner,
    fill: color,
    test_id: @test_id
  )
end