Class: RubySketch::Processing::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/rubysketch/processing.rb

Overview

Image object.

Instance Method Summary collapse

Instance Method Details

#copy(sx, sy, sw, sh, dx, dy, dw, dh) ⇒ nil #copy(img, sx, sy, sw, sh, dx, dy, dw, dh) ⇒ nil

Copies image.

Parameters:

  • img (Image) (defaults to: nil)

    image for copy source

  • sx (Numrtic)

    x position of source region

  • sy (Numrtic)

    y position of source region

  • sw (Numrtic)

    width of source region

  • sh (Numrtic)

    height of source region

  • dx (Numrtic)

    x position of destination region

  • dy (Numrtic)

    y position of destination region

  • dw (Numrtic)

    width of destination region

  • dh (Numrtic)

    height of destination region

Returns:

  • (nil)

    nil



626
627
628
629
630
631
# File 'lib/rubysketch/processing.rb', line 626

def copy(img = nil, sx, sy, sw, sh, dx, dy, dw, dh)
  img ||= self
  @image.paint do |painter|
    painter.image img.getInternal__, sx, sy, sw, sh, dx, dy, dw, dh
  end
end

#heightNumeric

Gets height of image.

Returns:

  • (Numeric)

    height of image



591
592
593
# File 'lib/rubysketch/processing.rb', line 591

def height()
  @image.height
end

#resize(width, height) ⇒ nil

Resizes image.

Parameters:

  • width (Numeric)

    width for resized image

  • height (Numeric)

    height for resized image

Returns:

  • (nil)

    nil



602
603
604
605
606
607
# File 'lib/rubysketch/processing.rb', line 602

def resize(width, height)
  @image = Rays::Image.new(width, height).paint do |painter|
    painter.image @image, 0, 0, width, height
  end
  nil
end

#save(filename) ⇒ Object

Saves image to file.

Parameters:

  • filename (String)

    file name to save image



637
638
639
# File 'lib/rubysketch/processing.rb', line 637

def save(filename)
  @image.save filename
end

#widthNumeric

Gets width of image.

Returns:

  • (Numeric)

    width of image



583
584
585
# File 'lib/rubysketch/processing.rb', line 583

def width()
  @image.width
end