Sha256: 3e8b425ad95cd1eb667eabc0f63201fb2c5af89198115c71f2b28caa930a4c0b

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

module Processing


  # Draws graphics into an offscreen buffer
  #
  # @see https://processing.org/reference/PGraphics.html
  # @see https://p5js.org/reference/p5/p5.Graphics/
  #
  class Graphics

    include Xot::Inspectable
    include GraphicsContext

    # Initialize graphics object.
    #
    # @see https://p5js.org/reference/p5/p5.Graphics/
    #
    def initialize(width, height, pixelDensity = 1)
      image = Rays::Image.new(
        width, height, Rays::RGBA, pixel_density: pixelDensity)
      init__ image, image.painter
    end

    # Start drawing.
    #
    # @see https://processing.org/reference/PGraphics_beginDraw_.html
    #
    def beginDraw(&block)
      @painter__.__send__ :begin_paint
      beginDraw__
      push
      if block
        begin
          block.call self
        ensure
          endDraw
        end
      end
    end

    # End drawing.
    #
    # @see https://processing.org/reference/PGraphics_endDraw_.html
    #
    def endDraw()
      pop
      endDraw__
      @painter__.__send__ :end_paint
    end

  end# Graphics


end# Processing

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
processing-1.1.5 lib/processing/graphics.rb
processing-1.1.4 lib/processing/graphics.rb
processing-1.1.3 lib/processing/graphics.rb
processing-1.1.2 lib/processing/graphics.rb
processing-1.1.1 lib/processing/graphics.rb