Class: Painter::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/painter/operation.rb

Direct Known Subclasses

Line, Pixel, Rect, Text

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(i) ⇒ Operation

Returns a new instance of Operation.



16
17
18
# File 'lib/painter/operation.rb', line 16

def initialize(i)
  @image = i
end

Class Method Details

.pretty_accessor(*names) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/painter/operation.rb', line 3

def self.pretty_accessor(*names)
  names.each do |n|
    attr_reader n.to_sym
    class_eval <<-END
      def #{n}(v)
        @_#{n} = v
      end
      def _#{n}
        @_#{n}
      end
    END
  end
end

Instance Method Details

#_angleObject



34
35
36
# File 'lib/painter/operation.rb', line 34

def _angle
  @_angle || 0
end

#_colorObject



41
42
43
# File 'lib/painter/operation.rb', line 41

def _color
  @_color || Painter::Color.new(1, 1, 1)
end

#angle(n) ⇒ Object



30
31
32
# File 'lib/painter/operation.rb', line 30

def angle(n)
  @_angle = (n * Math::PI / 180.0)
end

#color(r, g, b, a = nil) ⇒ Object



38
39
40
# File 'lib/painter/operation.rb', line 38

def color(r,g,b,a = nil)
  @_color = Painter::Color.new(r,g,b,a)
end