Class: RubyPost::BaseDrawCommand

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

Overview

base class for the commands that draw drawables. ie. draw, fill, drawarrow and drawdblarrow

Direct Known Subclasses

AbstractPlot, Arrow, BaseGraphData, Clip, DoubleArrow, Draw, Fill

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#compile

Constructor Details

#initialize(d = nil) ⇒ BaseDrawCommand

You can set the drawable in the constructor



10
11
12
13
14
# File 'lib/draw.rb', line 10

def initialize(d=nil)
  @options = Array.new
  @drawable = d
  self
end

Instance Attribute Details

#drawable=(value) ⇒ Object (writeonly)

Sets the attribute drawable

Parameters:

  • value

    the value to set the attribute drawable to.



7
8
9
# File 'lib/draw.rb', line 7

def drawable=(value)
  @drawable = value
end

Instance Method Details

#add_option(o) ⇒ Object



16
17
18
19
# File 'lib/draw.rb', line 16

def add_option(o)
  @options.push(o)
  self
end

#color(r, g, b) ⇒ Object

macro for setting the colour of the draw command. Spelt incorrectly.



44
45
46
# File 'lib/draw.rb', line 44

def color(r,g,b)
  colour(r,g,b)
end

#colour(r, g, b) ⇒ Object

macro for setting the colour of the draw command



37
38
39
40
# File 'lib/draw.rb', line 37

def colour(r,g,b)
  add_option(Colour.new(r,g,b))
  self
end

#compile_optionsObject

utility function to compile all the options



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

def compile_options
  str = String.new
  @options.each { |o| str = str + ' ' + o.compile }
  return str
end

#rotate(a) ⇒ Object

macro for rotating the draw command. This is the same as using add_option(Rotate.new(a))



64
65
66
67
# File 'lib/draw.rb', line 64

def rotate(a)
  add_option(Rotate.new(a))
  self
end

#scale(s) ⇒ Object

macro for scaling the draw command. This is the same as using add_option(Scale.new(s))



50
51
52
53
# File 'lib/draw.rb', line 50

def scale(s)
  add_option(Scale.new(s))
  self
end

#set_drawable(d) ⇒ Object

set the drawble to for this draw command. There is only one drawable per command. You can alternatively use BaseDrawCommand::drawable=



24
25
26
27
# File 'lib/draw.rb', line 24

def set_drawable(d)
  @drawable = d
  self
end

#translate(x, y) ⇒ Object

macro for translating the draw command. This is the same as using add_option(Translate.new(x,y))



57
58
59
60
# File 'lib/draw.rb', line 57

def translate(x,y)
  add_option(Translate.new(Pair.new(x,y)))
  self
end