Class: RubyMarks::ImageUtils

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

Class Method Summary collapse

Class Method Details

.calc_height(y1, y2) ⇒ Object



10
11
12
# File 'lib/ruby_marks/image_utils.rb', line 10

def self.calc_height(y1, y2)
  y2.to_i - y1.to_i + 1
end

.calc_middle_horizontal(x, width) ⇒ Object



14
15
16
# File 'lib/ruby_marks/image_utils.rb', line 14

def self.calc_middle_horizontal(x, width)
  x.to_i + width.to_i / 2
end

.calc_middle_vertical(y, height) ⇒ Object



18
19
20
# File 'lib/ruby_marks/image_utils.rb', line 18

def self.calc_middle_vertical(y, height)
  y.to_i + height.to_i / 2
end

.calc_width(x1, x2) ⇒ Object



6
7
8
# File 'lib/ruby_marks/image_utils.rb', line 6

def self.calc_width(x1, x2)
  x2.to_i - x1.to_i + 1
end

.to_hex(red, green, blue) ⇒ Object



23
24
25
26
27
28
# File 'lib/ruby_marks/image_utils.rb', line 23

def self.to_hex(red, green, blue)
  red = get_hex_from_color(red)
  green = get_hex_from_color(green)
  blue = get_hex_from_color(blue)
  "##{red}#{green}#{blue}".upcase
end