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, opt = {}) ⇒ 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, opt = {}) ⇒ ImageGD
Returns a new instance of ImageGD.
131 132 133 134 |
# File 'lib/quilt.rb', line 131 def initialize width, height, opt = {} require 'GD' @image = GD::Image.new width, height end |
Instance Method Details
#color(r, g, b) ⇒ Object
136 137 138 |
# File 'lib/quilt.rb', line 136 def color r, g, b @image.colorAllocate r, g, b end |
#fill_rect(x, y, _x, _y, color) ⇒ Object
144 145 146 |
# File 'lib/quilt.rb', line 144 def fill_rect x, y, _x, _y, color @image.filledRectangle x, y, _x, _y, color end |
#polygon(points, color) ⇒ Object
148 149 150 151 152 153 154 |
# File 'lib/quilt.rb', line 148 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
166 167 168 169 170 171 |
# File 'lib/quilt.rb', line 166 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
162 163 164 |
# File 'lib/quilt.rb', line 162 def to_blob @image.pngStr end |
#transparent(color) ⇒ Object
140 141 142 |
# File 'lib/quilt.rb', line 140 def transparent color @image.transparent color end |
#write(path) ⇒ Object
156 157 158 159 160 |
# File 'lib/quilt.rb', line 156 def write path File.open(path, 'w') do |f| @image.png f end end |