Module: Sevgi::Graphics::Mixtures::Wrappers

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

Instance Method Summary collapse

Instance Method Details

#Cline(x2:, y2:, x1: 0, y1: 0) ⇒ Object



7
8
9
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 7

def Cline(x2:, y2:, x1: 0, y1: 0, **)
  path(d: "M #{x1} #{y1} L #{x2} #{y2}", **)
end

#cline(angle:, length:, x: 0, y: 0) ⇒ Object



29
30
31
32
33
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 29

def cline(angle:, length:, x: 0, y: 0, **)
  dx = length * ::Math.cos(angle.to_f / 180 * ::Math::PI)
  dy = length * ::Math.sin(angle.to_f / 180 * ::Math::PI)
  path(d: "M #{x} #{y} l #{dx} #{dy}", **)
end

#css(hash) ⇒ Object



35
36
37
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 35

def css(hash, **)
  style(Content.css(hash), type: "text/css", **)
end

#cxline(angle:, dx:, x: 0, y: 0) ⇒ Object



39
40
41
42
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 39

def cxline(angle:, dx:, x: 0, y: 0, **)
  dy = dx * ::Math.tan(angle.to_f / 180 * ::Math::PI)
  path(d: "M #{x} #{y} l #{dx} #{dy}", **)
end

#cyline(angle:, dy:, x: 0, y: 0) ⇒ Object



44
45
46
47
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 44

def cyline(angle:, dy:, x: 0, y: 0, **)
  dx = dy / ::Math.tan(angle.to_f / 180 * ::Math::PI)
  path(d: "M #{x} #{y} l #{dx} #{dy}", **)
end

#Hline(x2:, x1: 0, y1: 0) ⇒ Object



11
12
13
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 11

def Hline(x2:, x1: 0, y1: 0, **)
  path(d: "M #{x1} #{y1} H #{x2}", **)
end

#hline(length:, x: 0, y: 0) ⇒ Object



49
50
51
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 49

def hline(length:, x: 0, y: 0, **)
  path(d: "M #{x} #{y} h #{length}", **)
end

#square(length:) ⇒ Object



53
54
55
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 53

def square(length:, **)
  rect(width: length, height: length, **)
end

#Symbol(name, **kwargs, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 15

def Symbol(name, **kwargs, &block)
  id = (words = name.split).map(&:downcase).join("-")
  title = words.map(&:capitalize).join(" ")

  symbol(id:, **kwargs) do
    title(title)
    Within(&block)
  end
end

#Vline(y2:, x1: 0, y1: 0) ⇒ Object



25
26
27
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 25

def Vline(y2:, x1: 0, y1: 0, **)
  path(d: "M #{x1} #{y1} V #{y2}", **)
end

#vline(length:, x: 0, y: 0) ⇒ Object



57
58
59
# File 'lib/sevgi/graphics/mixtures/wrappers.rb', line 57

def vline(length:, x: 0, y: 0, **)
  path(d: "M #{x} #{y} v #{length}", **)
end