Class: Magick::Image::View
- Inherits:
-
Object
- Object
- Magick::Image::View
- Defined in:
- lib/rmagick_internal.rb
Overview
Magick::Image::View class
Defined Under Namespace
Instance Attribute Summary collapse
-
#dirty ⇒ Object
Returns the value of attribute dirty.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #[](*args) ⇒ Object
-
#initialize(img, x, y, width, height) ⇒ View
constructor
A new instance of View.
-
#sync(force = false) ⇒ Object
Store changed pixels back to image.
-
#update(rows) ⇒ Object
Get update from Rows - if @dirty ever becomes true, don’t change it back to false!.
Constructor Details
#initialize(img, x, y, width, height) ⇒ View
Returns a new instance of View.
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
# File 'lib/rmagick_internal.rb', line 1077 def initialize(img, x, y, width, height) img.check_destroyed Kernel.raise ArgumentError, "invalid geometry (#{width}x#{height}+#{x}+#{y})" if width <= 0 || height <= 0 Kernel.raise RangeError, "geometry (#{width}x#{height}+#{x}+#{y}) exceeds image boundary" if x < 0 || y < 0 || (x + width) > img.columns || (y + height) > img.rows @view = img.get_pixels(x, y, width, height) @img = img @x = x @y = y @width = width @height = height @dirty = false end |
Instance Attribute Details
#dirty ⇒ Object
Returns the value of attribute dirty.
1075 1076 1077 |
# File 'lib/rmagick_internal.rb', line 1075 def dirty @dirty end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
1074 1075 1076 |
# File 'lib/rmagick_internal.rb', line 1074 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
1074 1075 1076 |
# File 'lib/rmagick_internal.rb', line 1074 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
1074 1075 1076 |
# File 'lib/rmagick_internal.rb', line 1074 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
1074 1075 1076 |
# File 'lib/rmagick_internal.rb', line 1074 def y @y end |
Instance Method Details
#[](*args) ⇒ Object
1090 1091 1092 1093 1094 |
# File 'lib/rmagick_internal.rb', line 1090 def [](*args) rows = Rows.new(@view, @width, @height, args) rows.add_observer(self) rows end |
#sync(force = false) ⇒ Object
Store changed pixels back to image
1097 1098 1099 1100 |
# File 'lib/rmagick_internal.rb', line 1097 def sync(force = false) @img.store_pixels(x, y, width, height, @view) if @dirty || force @dirty || force end |
#update(rows) ⇒ Object
Get update from Rows - if @dirty ever becomes true, don’t change it back to false!
1104 1105 1106 1107 1108 |
# File 'lib/rmagick_internal.rb', line 1104 def update(rows) @dirty = true rows.delete_observer(self) # No need to tell us again. nil end |