@image = Gosu::Image.new(@window, 'media/image.png')
@image.draw_text(0, 0, 'Name: Orc')
@image = Image.new(@window, 'image.png')
@text = Image.from_text(@window, "Some text", font, 10)
@image.splice(@text, 0, 0)
@text = Image.from_text(@window, "Some text", font, 10)
for x in 0..@text.width
for y in 0..@text.height
color = @text.get_pixel(x, y)
if color == [0, 0, 0, 1]
@text.set_pixel(x, y, [0, 0, 0, 0]
end
end
end
:chroma_key => [0,0,0,1]
in .splice
def draw_text(x, y, string)
text = Gosu::Image.from_text(@window, string, "Arial", 18)
@image.splice(text, x, y, :chroma_key => [0, 0, 0, 1])
end
Image.from_text
and draw?Window.record
method. Looks like that:@imgtxt = $window.record(width, height) do
@image.draw(...
@text = Image_from_text(...
@text.draw(...
end
[1, 1, 1, 1]
as the chroma key, it should look ugly but generally work.record
just be aware that you have to keep a reference to the original image around too, otherwise the macro will not be rendered properly. (Oops...this sounds like something Gosu should take care of.)
@sprite = Sprite.new # => Make
@sprite.x = x # => Make
@sprite.y = y # => Make
@sprite.z = z # => Make
@sprite.ox = ox # => Make
@sprite.oy = oy # => Make
@sprite.visible = visible # => Make
@sprite.zoom_x = zoom_x # => Make
@sprite.zoom_y = zoom_y # => Make
@sprite.angle = angle # => Make
@sprite.tone = Color.new(red, green, blue[, alpha = 255]) # => Make
@sprite.bitmap = Bitmap.new(width, height) or Bitmap.new(filename) # => Make
@sprite.bitmap.set_pixel(x, y, color) # => Make
@sprite.bitmap.get_pixel(x, y) # => Make
@sprite.bitmap.set_rect(x, y, width, height, color, fill) or @sprite.bitmap.set_rect(Rect.new(x, y, width, height), color, fill) # => Make
@sprite.bitmap.src_rect = Rect.new(x, y, width, height) # => Make
@sprite.bitmap.blt(x, y, Bitmap.new('image.png')[, Rect.new(x, y, width, height) = Rect.new(0, 0, bitmap.width, bitmap.height)]) # => Make
@sprite.bitmap.clear # => Make
Keyboard.trigger?(key) # => Make
Keyboard.trigger_release?(key) # => Make
Keyboard.press?(key) # => Make
Mouse.trigger?(key) # => Make
Mouse.trigger_release?(key) # => Make
Mouse.press?(key) # => Make
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill