Class: Quilt::ImageGD
- Inherits:
-
Object
- Object
- Quilt::ImageGD
- Defined in:
- lib/quilt.rb
Instance Method Summary collapse
- #color(r, g, b) ⇒ Object
- #fill_rect(x, y, _x, _y, color) ⇒ Object
-
#initialize(width, height) ⇒ ImageGD
constructor
A new instance of ImageGD.
- #polygon(points, color) ⇒ Object
- #resize(size) ⇒ Object
- #to_blob ⇒ Object
- #transparent(color) ⇒ Object
- #write(path) ⇒ Object
Constructor Details
#initialize(width, height) ⇒ ImageGD
Returns a new instance of ImageGD.
57 58 59 60 |
# File 'lib/quilt.rb', line 57 def initialize width, height require 'GD' @image = GD::Image.new width, height end |
Instance Method Details
#color(r, g, b) ⇒ Object
62 63 64 |
# File 'lib/quilt.rb', line 62 def color r, g, b @image.colorAllocate r, g, b end |
#fill_rect(x, y, _x, _y, color) ⇒ Object
70 71 72 |
# File 'lib/quilt.rb', line 70 def fill_rect x, y, _x, _y, color @image.filledRectangle x, y, _x, _y, color end |
#polygon(points, color) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/quilt.rb', line 74 def polygon points, color poly = GD::Polygon.new points.each do |i| poly.addPt i[0], i[1] end @image.filledPolygon poly, color end |
#resize(size) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/quilt.rb', line 92 def resize size _image = GD::Image.new size, size # FIXME bug @image.copyResized _image, 0, 0, 0, 0, size, size, @image.width, @image.height @image = _image end |
#to_blob ⇒ Object
88 89 90 |
# File 'lib/quilt.rb', line 88 def to_blob @image.pngStr end |
#transparent(color) ⇒ Object
66 67 68 |
# File 'lib/quilt.rb', line 66 def transparent color @image.transparent color end |
#write(path) ⇒ Object
82 83 84 85 86 |
# File 'lib/quilt.rb', line 82 def write path File.open(path, 'w') do |f| @image.png f end end |