require 'gosu'
require 'texplay'
include Gosu
class MyApp < Window
def initialize
super 200, 200, false
@image = Image.new(self, "heart.png", true)
@x = 10 # @image pos x
@y = 10 # @image pos y
end
def needs_cursor?
true
end
def update
if button_down? MsLeft and (@x..@x+@image.width).include?(mouse_x) and (@y..@y+@image.height).include?(mouse_y)
puts "clicked" if @image.get_pixel(mouse_x - @x, mouse_y - @y)[3] != 0.0
end
end
def draw
@image.draw(@x, @y, 1)
end
end
MyApp.new.show
Image#to_blob
, which returns a binary string (and cache it), and then index into that -> image_blob[width * y + h]
. That will then return an argb
string. Not pretty, but 0ldsk00l.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill