Method: Processing::GraphicsContext#shape

Defined in:
lib/processing/graphics_context.rb

#shape(img, a, b) ⇒ nil #shape(img, a, b, c, d) ⇒ nil Also known as: drawShape

Draws a shape.

The parameters a, b, c, and d are determined by shapeMode().

Parameters:

  • shp (Shape)

    shape to draw

  • a (Numeric) (defaults to: 0)

    horizontal position of the shape, by default

  • b (Numeric) (defaults to: 0)

    vertical position of the shape, by default

  • c (Numeric) (defaults to: nil)

    width of the shape, by default

  • d (Numeric) (defaults to: nil)

    height of the shape, by default

Returns:

  • (nil)

    nil

See Also:



1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
# File 'lib/processing/graphics_context.rb', line 1808

def shape(shp, a = 0, b = 0, c = nil, d = nil)
  assertDrawing__
  return nil unless shp.isVisible

  drawWithTexture__ do |_|
    if c || d || @shapeMode__ != CORNER
      x, y, w, h = toXYWH__ @shapeMode__, a, b, c || shp.width, d || shp.height
      shp.draw__ @painter__, x, y, w, h
    else
      shp.draw__ @painter__, a, b
    end
  end
  nil
end