Module: BgUtils

Defined in:
lib/bg_utils.rb

Defined Under Namespace

Classes: EmptyImageSource, Skybox, TiledImage

Class Method Summary collapse

Class Method Details

.get_pixel(gosu_image, x, y) ⇒ Object



116
117
118
119
120
121
122
123
# File 'lib/bg_utils.rb', line 116

def self.get_pixel(gosu_image, x, y)
	if x < 0 or x >= gosu_image.width or y < 0 or y >= gosu_image.height
		return nil
	else
		result = gosu_image.to_blob[(y * gosu_image.width + x) * 4, 4].unpack("C*")
		return Gosu::Color.new(result[3], result[0], result[1], result[2])
	end		
end

.set_pixel(gosu_image, x, y, color, brush_size = 1) ⇒ Object



125
126
127
128
# File 'lib/bg_utils.rb', line 125

def self.set_pixel(gosu_image, x, y, color, brush_size = 1)
	one_pixel_image = Gosu::Image.new(EmptyImageSource.new(brush_size.floor, brush_size.floor, color))
	gosu_image.insert(one_pixel_image, x.floor, y.floor)
end