Method: Ruby2D::Canvas#initialize
- Defined in:
- lib/ruby2d/canvas.rb
#initialize(width:, height:, x: 0, y: 0, z: 0, rotate: 0, fill: [0, 0, 0, 0], color: nil, colour: nil, opacity: nil, update: true, show: true) ⇒ Canvas
Create a Canvas.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ruby2d/canvas.rb', line 31 def initialize(width:, height:, x: 0, y: 0, z: 0, rotate: 0, fill: [0, 0, 0, 0], color: nil, colour: nil, opacity: nil, update: true, show: true) @x = x @y = y @z = z @width = width @height = height @rotate = rotate @fill = Color.new(fill) self.color = color || colour || 'white' color.opacity = opacity if opacity @update = update ext_create([@width, @height, @fill.r, @fill.g, @fill.b, @fill.a]) # sets @ext_pixel_data @texture = Texture.new(@ext_pixel_data, @width, @height) add if show end |