Class: XRVG::Style

Inherits:
Object
  • Object
show all
Includes:
Attributable
Defined in:
lib/style.rb

Overview

render.add( Circle[], Style[ :stroke, Color.red ] )

Instance Method Summary collapse

Instance Method Details

#fillopacityObject

attribute :strokeopacity, 1.0



30
31
32
33
34
35
# File 'lib/style.rb', line 30

def fillopacity()
  if @fill.is_a? Color
    return @fill.a
  end
  return 1.0
end

#strokeopacityObject



37
38
39
40
41
42
# File 'lib/style.rb', line 37

def strokeopacity()
  if @stroke.is_a? Color
    return @stroke.a
  end
  return 1.0
end

#svgfillObject



45
46
47
48
49
50
51
52
53
# File 'lib/style.rb', line 45

def svgfill
  if fill.is_a? Color
    return fill.svg
  elsif fill.is_a? Gradient
    return "%fillgradient%"
  else
    return fill
  end
end

#svglineObject



65
66
67
68
69
70
71
72
73
74
# File 'lib/style.rb', line 65

def svgline
  template = 'style="opacity:%opacity%;fill:%fill%;fill-opacity:%fillopacity%;stroke:%stroke%;stroke-width:%strokewidth%;stroke-opacity:%strokeopacity%"'
  
  return template.subreplace( {"%opacity%" => 1.0,
		 "%fill%"    => svgfill,
		 "%fillopacity%" => fillopacity,
		 "%stroke%"  => svgstroke,
		 "%strokewidth%" => strokewidth,
		 "%strokeopacity%" => strokeopacity} )
end

#svgstrokeObject



55
56
57
58
59
60
61
62
63
# File 'lib/style.rb', line 55

def svgstroke
  if stroke.is_a? Color
    return stroke.svg
  elsif stroke.is_a? Gradient
    return "%strokegradient%"
  else
    return stroke
  end
end