module Nyle::INNER
Private Class Methods
_load_image(filename, color_key: nil)
click to toggle source
# File lib/nyle.rb, line 307 def _load_image(filename, color_key: nil) loaded = GdkPixbuf::Pixbuf.new(file: filename) if color_key # Set transparent color with given color (alpha = 0) loaded.add_alpha(true, Cairo::Color.parse(color_key).r * 255, # 0 - 255 Cairo::Color.parse(color_key).g * 255, # 0 - 255 Cairo::Color.parse(color_key).b * 255) # 0 - 255 else # Not to transpare loaded end end
_pixel(x, y)
click to toggle source
# File lib/nyle.rb, line 368 def _pixel(x, y) cr = Nyle.module_eval{ @__cr } surface = cr.target address = surface.width * (y.to_i * 4) + (x.to_i * 4) color = surface.data.byteslice(address, 4).unpack("H*").first.upcase # e.g. '\xcc\x77\x00\xff -> ['cc7700ff'] -> 'CC7700FF' color = '#' + color.slice(4, 2) + color.slice(2, 2) + color.slice(0, 2) # #BBGGRR -> #RRGGBB end