Module: Sevgi::Graphics::Mixtures::Hatch

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

Overview

DSL helpers for drawing geometry-derived hatch lines.

Instance Method Summary collapse

Instance Method Details

#Draw(lines, **kwargs) ⇒ Array<Sevgi::Graphics::Element>

Draws one or more geometry line-like objects into this element.

Parameters:

  • lines (Object, Array<Object>)

    drawable geometry objects

  • kwargs (Hash)

    SVG attributes passed to each draw call

Returns:



12
13
14
# File 'lib/sevgi/graphics/mixtures/hatch.rb', line 12

def Draw(lines, **kwargs)
  Array(lines).map { it.draw(self, **kwargs) }
end

#Hatch(element, angle:, step:, initial: nil, **kwargs) ⇒ Array<Sevgi::Graphics::Element>

Draws hatch lines swept through a geometry element.

Parameters:

  • element (Object)

    geometry element responding to position

  • angle (Numeric)

    hatch angle in degrees

  • step (Numeric)

    distance between hatch lines

  • initial (Object, nil) (defaults to: nil)

    initial point for the sweep

  • kwargs (Hash)

    SVG attributes passed to each draw call

Returns:

Raises:

  • (Sevgi::MissingComponentError)

    when sevgi/geometry is unavailable



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sevgi/graphics/mixtures/hatch.rb', line 24

def Hatch(element, angle:, step:, initial: nil, **kwargs)
  begin
    require "sevgi/geometry"

  rescue ::LoadError => e
    raise unless e.path == "sevgi/geometry"

    MissingComponentError.("sevgi/geometry")
  end

  Draw(Geometry::Operation.sweep!(element, initial: initial || element.position, angle:, step:), **kwargs)
end