painter 0.0.4 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/painter.rb +13 -11
  2. data/spec/output/captcha.png +0 -0
  3. metadata +4 -4
@@ -3,9 +3,6 @@ require 'painter/image_struct'
3
3
  require 'painter/stdio'
4
4
  require 'painter/cgd2'
5
5
  require 'painter/operation'
6
- require 'painter/image'
7
- require 'painter/font'
8
- require 'painter/canvas'
9
6
  require 'painter/color'
10
7
  require 'painter/rect'
11
8
  require 'painter/pixel'
@@ -16,19 +13,24 @@ require 'painter/line'
16
13
  class Painter
17
14
  attr_reader :image_pointer
18
15
 
19
- def self.write(path, x, y, file_format)
16
+ def self.write(path, x, y, file_format, &block)
17
+ data = create(x, y, file_format, &block)
18
+ File.open(path, 'w') do |f|
19
+ f.write data
20
+ end
21
+ end
22
+
23
+ def self.create(x, y, file_format, &block)
20
24
  instance = new
21
25
  instance.initializeFromCreate(x,y)
22
- yield instance
23
- File.open(path, 'w') do |f|
24
- instance.format(file_format) do |data|
25
- f.write data
26
- end
26
+ block.call(instance)
27
+ data = nil
28
+ instance.format(file_format) do |output|
29
+ data = output
27
30
  end
28
- ensure
29
31
  instance.release!
32
+ return data
30
33
  end
31
-
32
34
  def self.open(path, format = nil)
33
35
  instance = new
34
36
  instance.initializeFromOpen(path, format)
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: painter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Sandofsky