class Mork::Coord
@private The Coord
class takes coordinates in the standard unit (e.g. mm) and provides pixel-based coordinates useful for image manipulation
Attributes
h[R]
w[R]
x[R]
y[R]
Public Class Methods
new(w, h: w, x: 0, y: 0, cx: 1, cy: cx)
click to toggle source
# File lib/mork/coord.rb, line 8 def initialize(w, h: w, x: 0, y: 0, cx: 1, cy: cx) @x = (cx*x).round @y = (cy*y).round @w = (cx*w).round @h = (cy*h).round end
Public Instance Methods
choice_cell()
click to toggle source
# File lib/mork/coord.rb, line 27 def choice_cell rness = [@h, @w].min / 2 rect_points + " #{rness} #{rness}" end
cropper()
click to toggle source
# File lib/mork/coord.rb, line 40 def cropper "#{@w}x#{@h}+#{@x}+#{@y}" end
cross1()
click to toggle source
# File lib/mork/coord.rb, line 32 def cross1 [@x+corner, @y+corner, @x+@w-corner, @y+@h-corner].join ' ' end
cross2()
click to toggle source
# File lib/mork/coord.rb, line 36 def cross2 [@x+corner, @y+@h-corner, @x+@w-corner, @y+corner].join ' ' end
print()
click to toggle source
# File lib/mork/coord.rb, line 19 def print puts "X: #{@x}, Y: #{@y}, W: #{@w}, H: #{@h}" end
rect_points()
click to toggle source
# File lib/mork/coord.rb, line 23 def rect_points [@x, @y, @x+@w, @y+@h].join ' ' end
to_hash()
click to toggle source
# File lib/mork/coord.rb, line 15 def to_hash { w: @w, h: @h, x: @x, y: @y } end
x_rng()
click to toggle source
# File lib/mork/coord.rb, line 44 def x_rng @x...@x+@w end
y_rng()
click to toggle source
# File lib/mork/coord.rb, line 48 def y_rng @y...@y+@h end
Private Instance Methods
corner()
click to toggle source
# File lib/mork/coord.rb, line 54 def corner (@h - @w).abs end