Method: Processing::GraphicsContext#background

Defined in:
lib/processing/graphics_context.rb

#background(str) ⇒ nil #background(str, alpha) ⇒ nil #background(gray) ⇒ nil #background(gray, alpha) ⇒ nil #background(r, g, b) ⇒ nil #background(r, g, b, alpha) ⇒ nil

Clears screen.

Examples:

background(255)            # White background
background(0)              # Black background
background(255, 0, 0)      # Red background
background(255, 0, 0, 128) # Semi-transparent red background

Parameters:

  • str (String)

    color code like ‘#00AAFF’

  • gray (Integer)

    gray value (0..255)

  • r (Integer)

    red value (0..255)

  • g (Integer)

    green value (0..255)

  • b (Integer)

    blue value (0..255)

  • alpha (Integer)

    alpha value (0..255)

Returns:

  • (nil)

    nil

See Also:



1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
# File 'lib/processing/graphics_context.rb', line 1466

def background(*args)
  assertDrawing__
  rgba = toRGBA__(*args)
  if rgba[3] == 1
    @painter__.background(*rgba)
  else
    @painter__.push fill: rgba, stroke: :none, blend_mode: :replace do |_|
      @painter__.rect 0, 0, width, height
    end
  end
  nil
end