Class: Carbuncle::ShadowText

Inherits:
Object
  • Object
show all
Defined in:
gems/carbuncle-graphics/mrblib/shadow_text.rb

Defined Under Namespace

Classes: Proxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(font = nil) ⇒ ShadowText

Returns a new instance of ShadowText.



29
30
31
32
33
34
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 29

def initialize(font = nil)
  @shadow_text = Carbuncle::Text.new(font)
  @shadow_text.color.set(64, 64, 64)
  @foreground_text = Carbuncle::Text.new(@shadow_text.font)
  @offset = Carbuncle::Point.new(2, 2)
end

Instance Attribute Details

#offsetObject

Returns the value of attribute offset.



27
28
29
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 27

def offset
  @offset
end

Instance Method Details

#colorObject



52
53
54
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 52

def color
  @foreground_text.color
end

#color=(value) ⇒ Object



69
70
71
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 69

def color=(value)
  @foreground_text.color = value
end

#drawObject



108
109
110
111
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 108

def draw
  @shadow_text.draw
  @foreground_text.draw
end

#fontObject



48
49
50
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 48

def font
  @foreground_text.font
end

#font=(value) ⇒ Object



64
65
66
67
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 64

def font=(value)
  @shadow_text.font = value
  @foreground_text.font = value
end

#foregroundObject



40
41
42
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 40

def foreground
  @foreground ||= Carbuncle::ShadowText::Proxy.new(@foreground_text)
end

#heightObject



98
99
100
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 98

def height
  size.y
end

#opacityObject



56
57
58
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 56

def opacity
  color.alpha
end

#opacity=(value) ⇒ Object



73
74
75
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 73

def opacity=(value)
  color.alpha = value
end

#positionObject



60
61
62
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 60

def position
  @foreground_text.position
end

#position=(value) ⇒ Object



82
83
84
85
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 82

def position=(value)
  @foreground_text.position = value
  @shadow_text.position.set(offset.x + @foreground.x, offset.y + @foreground.y)
end

#rectObject



113
114
115
116
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 113

def rect
  s = size
  Carbuncle::Rect.new(x, y, s.x, s.y)
end

#shadowObject



36
37
38
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 36

def shadow
  @shadow ||= Carbuncle::ShadowText::Proxy.new(@shadow_text)
end

#sizeObject



87
88
89
90
91
92
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 87

def size
  base_size = @foreground_text.size
  x = base_size.x + offset.x.abs
  y = base_size.y + offset.y.abs
  Carbuncle::Point.new(x, y)
end

#update(dt) ⇒ Object



102
103
104
105
106
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 102

def update(dt)
  @shadow_text.update(dt)
  @foreground_text.update(dt)
  @shadow_text.position.set(offset.x + @foreground_text.x, offset.y + @foreground_text.y)
end

#valueObject



44
45
46
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 44

def value
  @foreground_text.value
end

#value=(value) ⇒ Object



77
78
79
80
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 77

def value=(value)
  @shadow_text.value = value
  @foreground_text.value = value
end

#widthObject



94
95
96
# File 'gems/carbuncle-graphics/mrblib/shadow_text.rb', line 94

def width
  size.x
end