A simple rectangle class, to make the bounds returned by the GD::Image#stringFT method more readable.
Methods
Attributes
| [RW] | height | |
| [RW] | width | |
| [RW] | x | |
| [RW] | y |
Public Class methods
This accepts an array of integers, as returned by the GD::Image#stringFT method.
[ show source ]
# File lib/captcha.rb, line 82
82: def Rectangle.from_array( points )
83: minx = [ points[0], points[2], points[4], points[6] ].min
84: maxx = [ points[0], points[2], points[4], points[6] ].max
85: miny = [ points[1], points[3], points[5], points[7] ].min
86: maxy = [ points[1], points[3], points[5], points[7] ].max
87:
88: x = minx
89: y = miny
90: width = maxx - minx
91: height = maxy - miny
92:
93: Rectangle.new( x, y, width, height )
94: end
[ show source ]
# File lib/captcha.rb, line 76
76: def initialize( x, y, width, height )
77: @x, @y = x, y
78: @width, @height = width, height
79: end