Class: Skia::PictureRecorder
- Inherits:
-
Object
- Object
- Skia::PictureRecorder
- Defined in:
- lib/skia/picture.rb
Instance Method Summary collapse
- #begin_recording(bounds) ⇒ Object
- #delete ⇒ Object
- #end_recording ⇒ Object
-
#initialize ⇒ PictureRecorder
constructor
A new instance of PictureRecorder.
- #ptr ⇒ Object
- #recording? ⇒ Boolean
- #recording_canvas ⇒ Object
Constructor Details
#initialize ⇒ PictureRecorder
Returns a new instance of PictureRecorder.
65 66 67 68 69 70 |
# File 'lib/skia/picture.rb', line 65 def initialize @ptr = Native.sk_picture_recorder_new raise Error, "Failed to create picture recorder" if @ptr.nil? || @ptr.null? @recording = false end |
Instance Method Details
#begin_recording(bounds) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/skia/picture.rb', line 76 def begin_recording(bounds) bounds_struct = bounds.to_struct canvas_ptr = Native.sk_picture_recorder_begin_recording(@ptr, bounds_struct) raise Error, "Failed to begin recording" if canvas_ptr.nil? || canvas_ptr.null? @recording = true canvas = Canvas.new(canvas_ptr) if block_given? yield canvas end_recording else canvas end end |
#delete ⇒ Object
115 116 117 118 |
# File 'lib/skia/picture.rb', line 115 def delete Native.sk_picture_recorder_delete(@ptr) if @ptr @ptr = nil end |
#end_recording ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/skia/picture.rb', line 101 def end_recording return nil unless @recording ptr = Native.sk_picture_recorder_end_recording(@ptr) @recording = false raise Error, "Failed to end recording" if ptr.nil? || ptr.null? Picture.new(ptr) end |
#ptr ⇒ Object
72 73 74 |
# File 'lib/skia/picture.rb', line 72 def ptr @ptr end |
#recording? ⇒ Boolean
111 112 113 |
# File 'lib/skia/picture.rb', line 111 def recording? @recording end |