lib/rubysketch/processing.rb in rubysketch-0.3.8 vs lib/rubysketch/processing.rb in rubysketch-0.3.9

- old
+ new

@@ -765,15 +765,15 @@ @camera = Rays::Camera.new width, height, device_name: name end # Start capturing. # - # @return [Capture] self + # @return [nil] nil # def start () raise "Failed to start capture" unless @camera.start - self + nil end # Stop capturing. # # @return [nil] nil @@ -938,17 +938,19 @@ fill 255 stroke 0 end - def beginDraw () + # @private + def beginDraw__ () @matrixStack__.clear @styleStack__.clear @drawing__ = true end - def endDraw () + # @private + def endDraw__ () @drawing__ = false end def width () @image__.width @@ -1714,21 +1716,25 @@ setup__ @image__.painter end # Start drawing. # - def beginDraw () + def beginDraw (&block) @painter__.__send__ :begin_paint - super + beginDraw__ push + if block + block.call + endDraw + end end # End drawing. # def endDraw () pop - super + endDraw__ @painter__.__send__ :end_paint end end# Graphics @@ -1763,11 +1769,11 @@ @mousePos__ = @mousePrevPos__ = Rays::Point.new 0 @mousePressed__ = false @touches__ = [] - @window__.before_draw = proc {beginDraw} - @window__.after_draw = proc {endDraw} + @window__.before_draw = proc {beginDraw__} + @window__.after_draw = proc {endDraw__} drawFrame = -> { @image__ = @window__.canvas @painter__ = @window__.canvas_painter begin