gir_ffi-cairo 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8900c17f2ad9bef9e2618a3749e5e1f852508c4a
4
- data.tar.gz: 1f9397b9364e47267c9933325a1d1145fd1149ab
3
+ metadata.gz: 00183732aec5e031aff995ac9a16d26d54f939c9
4
+ data.tar.gz: bc440bc00c60b0c0fbbb3d387d9160f631cfe169
5
5
  SHA512:
6
- metadata.gz: 06436cb451c0f1c6abc90f30bfbcc0bc2ce1737bc7d6a09a8e7b808be6426f4734f14d2612d759c74e1c5214309137a76ccadf5a48f2b386a1ad2c16101a0a8f
7
- data.tar.gz: 9e2e71c670a6ce4e7dbca5a5e5cf57dbcb7566f238b6580c72f7edf09fc412234cdc13c5fd21a0c016ebfa4d0f139be133fdfb37079fec29bc33de0b6d17131a
6
+ metadata.gz: 37e81a173cb9d13bb10ff43a0e8f7a2c68c27ffeca829e8f04dd2f3d3d7e970f3c4e82b9374773d166a498344d93dde2bc0322af3b976e04201449e4669315ed
7
+ data.tar.gz: f7493603b64a1455903385fb7ab85c84cf510f938eac630c0fefc49c8d06141945cfa8897c22809e49ee6def419b188c4c374233080e3e7aab544c0034374b3c
data/README.md CHANGED
@@ -21,6 +21,13 @@ file bugs for any functionality that is not yet implemented.
21
21
 
22
22
  gem install gir_ffi-cairo
23
23
 
24
+ ## Contributors
25
+
26
+ The following people have contributed to GirFFI-Cairo:
27
+
28
+ * Natsuki Yagi
29
+ * Matijs van Zuijlen
30
+
24
31
  ## License
25
32
 
26
33
  Copyright © 2012–2016, [Matijs van Zuijlen](http://www.matijs.net/)
@@ -7,6 +7,22 @@ module Cairo
7
7
  self.wrap ptr
8
8
  end
9
9
 
10
+ def move_to(x, y)
11
+ Lib.cairo_move_to self, x, y
12
+ end
13
+
14
+ def line_to(x, y)
15
+ Lib.cairo_line_to self, x, y
16
+ end
17
+
18
+ def close_path
19
+ Lib.cairo_close_path self
20
+ end
21
+
22
+ def rectangle(x, y, width, height)
23
+ Lib.cairo_rectangle self, x, y, width, height
24
+ end
25
+
10
26
  def arc xc, yc, radius, angle1, angle2
11
27
  Lib.cairo_arc self, xc, yc, radius, angle1, angle2
12
28
  end
@@ -15,6 +31,10 @@ module Cairo
15
31
  Lib.cairo_fill self
16
32
  end
17
33
 
34
+ def stroke
35
+ Lib.cairo_stroke self
36
+ end
37
+
18
38
  def get_target
19
39
  ptr = Lib.cairo_get_target self
20
40
  Surface.wrap ptr
@@ -23,16 +43,39 @@ module Cairo
23
43
  def set_source_rgba red, green, blue, alpha
24
44
  Lib.cairo_set_source_rgba self, red, green, blue, alpha
25
45
  end
46
+
47
+ def save
48
+ Lib.cairo_save self
49
+ end
50
+
51
+ def restore
52
+ Lib.cairo_restore self
53
+ end
54
+
55
+ def show_page
56
+ Lib.cairo_show_page self
57
+ end
26
58
  end
27
59
 
28
60
  module Lib
29
61
  attach_function :cairo_create, [:pointer], :pointer
30
62
  attach_function :cairo_get_target, [:pointer], :pointer
31
63
 
64
+ attach_function :cairo_move_to, [:pointer, :double, :double], :void
65
+ attach_function :cairo_line_to, [:pointer, :double, :double], :void
32
66
  attach_function :cairo_arc,
33
67
  [:pointer, :double, :double, :double, :double, :double], :void
68
+ attach_function :cairo_close_path, [:pointer], :void
69
+ attach_function :cairo_rectangle, [:pointer, :double, :double, :double, :double], :void
70
+
34
71
  attach_function :cairo_fill, [:pointer], :void
72
+ attach_function :cairo_stroke, [:pointer], :void
73
+
35
74
  attach_function :cairo_set_source_rgba,
36
75
  [:pointer, :double, :double, :double, :double], :void
76
+
77
+ attach_function :cairo_save, [:pointer], :void
78
+ attach_function :cairo_restore, [:pointer], :void
79
+ attach_function :cairo_show_page, [:pointer], :void
37
80
  end
38
81
  end
@@ -0,0 +1,24 @@
1
+ module Cairo
2
+ class PDFSurface < Surface
3
+ def self.create filename, width, height
4
+ ptr = Lib.cairo_pdf_surface_create filename, width, height
5
+ surface = self.wrap ptr
6
+
7
+ if block_given?
8
+ yield surface
9
+ surface.finish
10
+ end
11
+
12
+ surface
13
+ end
14
+
15
+ def set_size(width, height)
16
+ Lib.cairo_pdf_surface_set_size(self, width, height)
17
+ end
18
+ end
19
+
20
+ module Lib
21
+ attach_function :cairo_pdf_surface_create, [:string, :double, :double], :pointer
22
+ attach_function :cairo_pdf_surface_set_size, [:pointer, :double, :double], :void
23
+ end
24
+ end
@@ -3,9 +3,17 @@ module Cairo
3
3
 
4
4
  class Surface
5
5
  # TODO: Add overrides
6
+ def flush
7
+ Lib.cairo_surface_flush(self)
8
+ end
9
+ def finish
10
+ Lib.cairo_surface_finish(self)
11
+ end
6
12
  end
7
13
 
8
14
  module Lib
9
15
  # TODO: Attach functions
16
+ attach_function :cairo_surface_flush, [:pointer], :void
17
+ attach_function :cairo_surface_finish, [:pointer], :void
10
18
  end
11
19
  end
data/lib/gir_ffi-cairo.rb CHANGED
@@ -6,3 +6,4 @@ require 'gir_ffi-cairo/context'
6
6
  require 'gir_ffi-cairo/format'
7
7
  require 'gir_ffi-cairo/surface'
8
8
  require 'gir_ffi-cairo/image_surface'
9
+ require 'gir_ffi-cairo/pdf_surface'
@@ -0,0 +1,29 @@
1
+ require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
2
+
3
+ describe Cairo::PDFSurface do
4
+ it "is a subclass of Cairo::Surface" do
5
+ Cairo::PDFSurface.superclass.must_equal Cairo::Surface
6
+ end
7
+
8
+ describe ".create" do
9
+ before { @path = 'test.pdf' }
10
+ after { File.delete(@path) if File.exist? @path }
11
+
12
+ it "creates a new Cairo::PDFSurface" do
13
+ obj = Cairo::PDFSurface.create(@path, 300, 200)
14
+ obj.must_be_instance_of Cairo::PDFSurface
15
+ end
16
+
17
+ it "creates a new Cairo::PDFSurface with block" do
18
+ called = nil
19
+ Cairo::PDFSurface.create(@path, 300, 200) {|surface|
20
+ surface.must_be_instance_of Cairo::PDFSurface
21
+ called = true
22
+ }
23
+ refute_nil called
24
+ assert File.exist?(@path)
25
+ end
26
+
27
+ end
28
+ end
29
+
@@ -16,4 +16,20 @@ describe Cairo::Context do
16
16
  ctx.fill
17
17
  pass
18
18
  end
19
+
20
+ describe 'PDF' do
21
+ before { @path = 'integration-test.pdf' }
22
+ after { File.delete(@path) if File.exist? @path }
23
+
24
+ it "can create pdf" do
25
+ Cairo::PDFSurface.create(@path, 400, 300) {|surface|
26
+ ctx = Cairo::Context.create(surface)
27
+ ctx.arc(300, 200, 100, 0, 2 * Math::PI)
28
+ ctx.set_source_rgba(1, 1, 0, 0.5)
29
+ ctx.fill
30
+ ctx.show_page
31
+ }
32
+ pass
33
+ end
34
+ end
19
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gir_ffi-cairo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matijs van Zuijlen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-23 00:00:00.000000000 Z
11
+ date: 2016-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gir_ffi
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.0
19
+ version: 0.11.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.0
26
+ version: 0.11.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,9 +66,11 @@ files:
66
66
  - lib/gir_ffi-cairo/context.rb
67
67
  - lib/gir_ffi-cairo/format.rb
68
68
  - lib/gir_ffi-cairo/image_surface.rb
69
+ - lib/gir_ffi-cairo/pdf_surface.rb
69
70
  - lib/gir_ffi-cairo/surface.rb
70
71
  - test/gir_ffi-cairo/context_test.rb
71
72
  - test/gir_ffi-cairo/image_surface_test.rb
73
+ - test/gir_ffi-cairo/pdf_surface_test.rb
72
74
  - test/integration/context_test.rb
73
75
  - test/test_helper.rb
74
76
  homepage: http://www.github.com/mvz/gir_ffi-cairo
@@ -97,6 +99,7 @@ specification_version: 4
97
99
  summary: GirFFI-based bindings for Cairo
98
100
  test_files:
99
101
  - test/test_helper.rb
100
- - test/gir_ffi-cairo/context_test.rb
101
- - test/gir_ffi-cairo/image_surface_test.rb
102
102
  - test/integration/context_test.rb
103
+ - test/gir_ffi-cairo/pdf_surface_test.rb
104
+ - test/gir_ffi-cairo/image_surface_test.rb
105
+ - test/gir_ffi-cairo/context_test.rb