Module: Sevgi::Graphics::Mixtures::Hatch
- Defined in:
- lib/sevgi/graphics/mixtures/hatch.rb
Overview
DSL helpers for drawing geometry values and geometry-derived hatch lines.
Draw delegates to each geometry object's drawing protocol. Hatch
first sweeps interior spans through a closed lined element, then draws
them. Its angle describes line direction; step is perpendicular
spacing. The default initial line passes through element.position.
The built-in :inkscape document profile includes this mixture;
:minimal, :default, and :html do not.
Hatch materializes separate finite SVG path elements. When only a repeated visual fill matters, use an SVG pattern and leave repetition and clipping to the renderer instead of computing line geometry.
Instance Method Summary collapse
-
#Draw(lines, **kwargs) ⇒ Array<Sevgi::Graphics::Element>
Draws one or more geometry line-like objects into this element.
-
#Hatch(element, angle:, step:, initial: nil, **kwargs) ⇒ Array<Sevgi::Graphics::Element>
Draws hatch lines swept through a geometry element.
Instance Method Details
#Draw(lines, **kwargs) ⇒ Array<Sevgi::Graphics::Element>
Draws one or more geometry line-like objects into this element.
39 40 41 |
# File 'lib/sevgi/graphics/mixtures/hatch.rb', line 39 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.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/sevgi/graphics/mixtures/hatch.rb', line 65 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 initial = element.position if initial.nil? && element.is_a?(Geometry::Element::Lined) Draw(Geometry::Operation.sweep!(element, initial:, angle:, step:), **kwargs) end |