Sha256: 1ba71f9535e4b5433e08d9faa1e5b9fb59a9fc1aa09e4c9a253d2a0f69001fbd

Contents?: true

Size: 933 Bytes

Versions: 4

Compression:

Stored size: 933 Bytes

Contents

module Processing


  # Draws graphics into an offscreen buffer
  #
  class Graphics

    include Xot::Inspectable
    include GraphicsContext

    # Initialize graphics object.
    #
    def initialize(width, height, pixelDensity = 1)
      image = Rays::Image.new width, height, Rays::RGBA, pixelDensity
      init__ image, image.painter
    end

    # Start drawing.
    #
    def beginDraw(&block)
      beginDraw__
      @painter__.__send__ :begin_paint
      push
      if block
        begin
          block.call self
        ensure
          endDraw
        end
      end
    end

    # End drawing.
    #
    def endDraw()
      pop
      @painter__.__send__ :end_paint
      endDraw__
    end

    # Saves image to file.
    #
    # @param filename [String] file name to save image
    #
    # @return [nil] nil
    #
    def save(filename)
      @image__.save filename
      nil
    end

  end# Graphics


end# Processing

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
processing-0.5.31 lib/processing/graphics.rb
processing-0.5.30 lib/processing/graphics.rb
processing-0.5.29 lib/processing/graphics.rb
processing-0.5.28 lib/processing/graphics.rb