module Cura::Helpers::Component::Drawing

Helpers for drawing within components.

Protected Instance Methods

draw_background() click to toggle source

Draw the background of this component.

# File lib/cura/helpers/component/drawing.rb, line 48
def draw_background
  x      = absolute_x + @margin.left + @border.left
  y      = absolute_y + @margin.top + @border.top
  width  = self.width + @padding.width
  height = self.height + @padding.height
  color  = background

  pencil.draw_rectangle(x, y, width, height, color)
end
draw_border() click to toggle source

Draw the border of this component.

# File lib/cura/helpers/component/drawing.rb, line 59
def draw_border # TODO
end
draw_character(x, y, character, foreground=Cura::Color.black, background=Cura::Color.white, bold=false, underline=false) click to toggle source

Draw a single character.

# File lib/cura/helpers/component/drawing.rb, line 32
def draw_character(x, y, character, foreground=Cura::Color.black, background=Cura::Color.white, bold=false, underline=false)
  x = absolute_x + @offsets.left + x
  y = absolute_y + @offsets.top + y

  pencil.draw_character(x, y, character, foreground, background, bold, underline)
end
draw_point(x, y, color=Cura::Color.black) click to toggle source

Draw a point.

# File lib/cura/helpers/component/drawing.rb, line 15
def draw_point(x, y, color=Cura::Color.black)
  x = absolute_x + @offsets.left + x
  y = absolute_y + @offsets.top + y

  pencil.draw_point(x, y, color)
end
draw_rectangle(x, y, width, height, color=Cura::Color.black) click to toggle source

Draw a rectangle. TODO: filled argument

# File lib/cura/helpers/component/drawing.rb, line 24
def draw_rectangle(x, y, width, height, color=Cura::Color.black)
  x = absolute_x + @offsets.left + x
  y = absolute_y + @offsets.top + y

  pencil.draw_rectangle(x, y, width, height, color)
end
draw_text(x, y, text, foreground=Cura::Color.black, background=Cura::Color.white, bold=false, underline=false) click to toggle source

Draw text.

# File lib/cura/helpers/component/drawing.rb, line 40
def draw_text(x, y, text, foreground=Cura::Color.black, background=Cura::Color.white, bold=false, underline=false)
  x = absolute_x + @offsets.left + x
  y = absolute_y + @offsets.top + y

  pencil.draw_text(x, y, text, foreground, background, bold, underline)
end