Class: Gosu::Image
- Inherits:
-
Object
- Object
- Gosu::Image
- Defined in:
- lib/ashton/gosu_ext/image.rb
Constant Summary collapse
Instance Method Summary collapse
-
#cache ⇒ Object
The cache is a replacement for Texplay’s pixel cache system.
- #draw(*args) ⇒ Object
-
#draw_as_points(points, z, options = {}) ⇒ Object
Draw a list of centred sprites by position.
- #draw_rot(*args) ⇒ Object
- #to_texture ⇒ Object
Instance Method Details
#cache ⇒ Object
The cache is a replacement for Texplay’s pixel cache system.
88 89 90 |
# File 'lib/ashton/gosu_ext/image.rb', line 88 def cache @cache ||= Ashton::PixelCache.new self end |
#draw(*args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ashton/gosu_ext/image.rb', line 7 def draw(*args) args, shader = if args.last.is_a?(Hash) [args[0..-2], args.last[:shader]] else [args, nil] end z = args[2] if shader shader.enable z $window.gl z do shader.image = self shader.color = args[5].is_a?(Color) ? args[5] : DEFAULT_DRAW_COLOR end end begin draw_without_hash(*args) ensure shader.disable z if shader end end |
#draw_as_points(points, z, options = {}) ⇒ Object
Draw a list of centred sprites by position.
TODO: Need to use point sprites here, but this is still much faster than individual #draws if using shaders and comparable if not.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ashton/gosu_ext/image.rb', line 64 def draw_as_points(points, z, = {}) color = [:color] || DEFAULT_DRAW_COLOR scale = [:scale] || 1.0 shader = [:shader] mode = [:mode] || :default if shader shader.enable z $window.gl z do shader.image = self shader.color = color end end begin points.each do |x, y| draw_rot_without_hash x, y, z, 0, 0.5, 0.5, scale, scale, color, mode end ensure shader.disable z if shader end end |
#draw_rot(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ashton/gosu_ext/image.rb', line 33 def draw_rot(*args) args, shader = if args.last.is_a?(Hash) [args[0..-2], args.last[:shader]] else [args, nil] end z = args[2] if shader shader.enable z $window.gl z do shader.image = self shader.color = args[8].is_a?(Color) ? args[8] : DEFAULT_DRAW_COLOR end end begin draw_rot_without_hash(*args) ensure shader.disable z if shader end end |