Class: QrForge::Components::EyeInner::Circle

Inherits:
ForgeComponent show all
Defined in:
lib/qr_forge/components/eye_inner/circle.rb

Constant Summary collapse

INSET_MODULES =

how many modules to inset on each side

2

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



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/qr_forge/components/eye_inner/circle.rb', line 11

def draw(y:, x:, quiet_zone:, area:, color: "black", **_)
  # 1) full-finder radius in modules
  full_radius = area / 2.0

  # 2) subtract that many modules from *each* side
  r = full_radius - INSET_MODULES

  return if r <= 0 # no room to draw

  # 3) center calculation
  cx = x + quiet_zone + full_radius
  cy = y + quiet_zone + full_radius

  @xml_builder.circle(
    cx:,
    cy:,
    r: r,
    fill: color,
    test_id: @test_id
  )
end