Method: Ruby2D::Sprite#draw

Defined in:
lib/ruby2d/sprite.rb

#draw(x:, y:, width: (@width || @clip_width), height: (@height || @clip_height), rotate: @rotate, clip_x: @clip_x, clip_y: @clip_y, clip_width: @clip_width, clip_height: @clip_height, color: [1.0, 1.0, 1.0, 1.0]) ⇒ Object

Parameters:

  • width (Numeric) (defaults to: (@width || @clip_width))

    The width of drawn image

  • height (Numeric) (defaults to: (@height || @clip_height))

    The height of drawn image

  • x (Numeric)
  • y (Numeric)
  • rotate (Numeric) (defaults to: @rotate)

    Angle, default is 0

  • color (Numeric) (defaults to: [1.0, 1.0, 1.0, 1.0])

    (or colour) Tint the image when rendering

  • clip_x (Numeric) (defaults to: @clip_x)
  • clip_x (Numeric) (defaults to: @clip_x)
  • clip_width (Numeric) (defaults to: @clip_width)
  • clip_height (Numeric) (defaults to: @clip_height)


182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/ruby2d/sprite.rb', line 182

def draw(x:, y:, width: (@width || @clip_width), height: (@height || @clip_height), rotate: @rotate,
         clip_x: @clip_x, clip_y: @clip_y, clip_width: @clip_width, clip_height: @clip_height,
         color: [1.0, 1.0, 1.0, 1.0])

  Window.render_ready_check
  render(x: x, y: y, width: width, height: height, color: Color.new(color), rotate: rotate, crop: {
           x: clip_x,
           y: clip_y,
           width: clip_width,
           height: clip_height,
           image_width: @img_width,
           image_height: @img_height
         })
end