gir_ffi-cairo 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Rakefile +5 -3
- data/lib/gir_ffi-cairo/context.rb +26 -23
- data/lib/gir_ffi-cairo/format.rb +11 -13
- data/lib/gir_ffi-cairo/image_surface.rb +7 -6
- data/lib/gir_ffi-cairo/pdf_surface.rb +9 -6
- data/lib/gir_ffi-cairo/surface.rb +10 -8
- data/lib/gir_ffi-cairo.rb +2 -0
- data/test/gir_ffi-cairo/context_test.rb +5 -3
- data/test/gir_ffi-cairo/image_surface_test.rb +5 -4
- data/test/gir_ffi-cairo/pdf_surface_test.rb +8 -8
- data/test/integration/context_test.rb +7 -5
- data/test/test_helper.rb +2 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 15b274d8e00c739bf2ac1fc4a160ce2d535ee94c7b0dfcdff9a6e162c7991393
|
4
|
+
data.tar.gz: 78b673223b0653a824aea70f58386cc1a7bc5f522b0b758c24f319efd286747e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dd29d627b52e35329bf8dee8177c6e39281f3c609fd3bf09bc11536b51f7434692cdb3e4da44c1798dcc069034b21574de7791b4a5142ad546d0b330e19530f
|
7
|
+
data.tar.gz: 3132145bd971d040484c55315ef29899330db73d31eb22757e3ec521e21f4cc606578379d5beef5b834664126768f1ac6f226beb177c9cec88d073e859fa46d6
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_helper'
|
2
4
|
require 'rake/testtask'
|
3
5
|
|
@@ -16,9 +18,9 @@ namespace :test do
|
|
16
18
|
t.warning = true
|
17
19
|
end
|
18
20
|
|
19
|
-
task :
|
21
|
+
task all: [:unit, :integration]
|
20
22
|
end
|
21
23
|
|
22
|
-
task :
|
24
|
+
task test: 'test:all'
|
23
25
|
|
24
|
-
task :
|
26
|
+
task default: 'test'
|
@@ -1,10 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Cairo.load_class :Context
|
3
4
|
|
5
|
+
module Cairo
|
6
|
+
# Overrides for CairoContext (cairo_t)
|
4
7
|
class Context
|
5
|
-
def self.create
|
8
|
+
def self.create(target)
|
6
9
|
ptr = Lib.cairo_create target
|
7
|
-
|
10
|
+
wrap ptr
|
8
11
|
end
|
9
12
|
|
10
13
|
def move_to(x, y)
|
@@ -23,7 +26,7 @@ module Cairo
|
|
23
26
|
Lib.cairo_rectangle self, x, y, width, height
|
24
27
|
end
|
25
28
|
|
26
|
-
def arc
|
29
|
+
def arc(xc, yc, radius, angle1, angle2)
|
27
30
|
Lib.cairo_arc self, xc, yc, radius, angle1, angle2
|
28
31
|
end
|
29
32
|
|
@@ -40,7 +43,7 @@ module Cairo
|
|
40
43
|
Surface.wrap ptr
|
41
44
|
end
|
42
45
|
|
43
|
-
def set_source_rgba
|
46
|
+
def set_source_rgba(red, green, blue, alpha)
|
44
47
|
Lib.cairo_set_source_rgba self, red, green, blue, alpha
|
45
48
|
end
|
46
49
|
|
@@ -56,26 +59,26 @@ module Cairo
|
|
56
59
|
Lib.cairo_show_page self
|
57
60
|
end
|
58
61
|
end
|
62
|
+
end
|
59
63
|
|
60
|
-
|
61
|
-
|
62
|
-
|
64
|
+
Cairo::Lib.module_eval do
|
65
|
+
attach_function :cairo_create, [:pointer], :pointer
|
66
|
+
attach_function :cairo_get_target, [:pointer], :pointer
|
63
67
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
attach_function :cairo_move_to, [:pointer, :double, :double], :void
|
69
|
+
attach_function :cairo_line_to, [:pointer, :double, :double], :void
|
70
|
+
attach_function :cairo_arc,
|
71
|
+
[:pointer, :double, :double, :double, :double, :double], :void
|
72
|
+
attach_function :cairo_close_path, [:pointer], :void
|
73
|
+
attach_function :cairo_rectangle, [:pointer, :double, :double, :double, :double], :void
|
70
74
|
|
71
|
-
|
72
|
-
|
75
|
+
attach_function :cairo_fill, [:pointer], :void
|
76
|
+
attach_function :cairo_stroke, [:pointer], :void
|
73
77
|
|
74
|
-
|
75
|
-
|
78
|
+
attach_function :cairo_set_source_rgba,
|
79
|
+
[:pointer, :double, :double, :double, :double], :void
|
76
80
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
+
attach_function :cairo_save, [:pointer], :void
|
82
|
+
attach_function :cairo_restore, [:pointer], :void
|
83
|
+
attach_function :cairo_show_page, [:pointer], :void
|
81
84
|
end
|
data/lib/gir_ffi-cairo/format.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
|
2
|
-
module Lib
|
3
|
-
enum :Format, [
|
4
|
-
:invalid, -1,
|
5
|
-
:argb32, 0,
|
6
|
-
:rgb24,
|
7
|
-
:a8,
|
8
|
-
:a1,
|
9
|
-
:rgb16_565,
|
10
|
-
:rgb30
|
11
|
-
]
|
12
|
-
end
|
1
|
+
# frozen_string_literal: true
|
13
2
|
|
14
|
-
|
3
|
+
module Cairo
|
4
|
+
Format = Lib.enum :Format, [
|
5
|
+
:invalid, -1,
|
6
|
+
:argb32, 0,
|
7
|
+
:rgb24,
|
8
|
+
:a8,
|
9
|
+
:a1,
|
10
|
+
:rgb16_565,
|
11
|
+
:rgb30
|
12
|
+
]
|
15
13
|
end
|
@@ -1,13 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Cairo
|
4
|
+
# Surface subclass for (bitmap) images.
|
2
5
|
class ImageSurface < Surface
|
3
|
-
def self.create
|
6
|
+
def self.create(format, width, height)
|
4
7
|
ptr = Lib.cairo_image_surface_create format, width, height
|
5
|
-
|
8
|
+
wrap ptr
|
6
9
|
end
|
7
10
|
end
|
8
|
-
|
9
|
-
module Lib
|
10
|
-
attach_function :cairo_image_surface_create, [Cairo::Format, :int, :int], :pointer
|
11
|
-
end
|
12
11
|
end
|
13
12
|
|
13
|
+
Cairo::Lib.attach_function(:cairo_image_surface_create,
|
14
|
+
[Cairo::Format, :int, :int], :pointer)
|
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Cairo
|
4
|
+
# Surface subclass for PDFs.
|
2
5
|
class PDFSurface < Surface
|
3
|
-
def self.create
|
6
|
+
def self.create(filename, width, height)
|
4
7
|
ptr = Lib.cairo_pdf_surface_create filename, width, height
|
5
|
-
surface =
|
8
|
+
surface = wrap ptr
|
6
9
|
|
7
10
|
if block_given?
|
8
11
|
yield surface
|
@@ -16,9 +19,9 @@ module Cairo
|
|
16
19
|
Lib.cairo_pdf_surface_set_size(self, width, height)
|
17
20
|
end
|
18
21
|
end
|
22
|
+
end
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
+
Cairo::Lib.module_eval do
|
25
|
+
attach_function :cairo_pdf_surface_create, [:string, :double, :double], :pointer
|
26
|
+
attach_function :cairo_pdf_surface_set_size, [:pointer, :double, :double], :void
|
24
27
|
end
|
@@ -1,19 +1,21 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Cairo.load_class :Surface
|
3
4
|
|
5
|
+
module Cairo
|
6
|
+
# Overrides for CairoSurface (cairo_surface_t)
|
4
7
|
class Surface
|
5
|
-
# TODO: Add overrides
|
6
8
|
def flush
|
7
9
|
Lib.cairo_surface_flush(self)
|
8
10
|
end
|
11
|
+
|
9
12
|
def finish
|
10
13
|
Lib.cairo_surface_finish(self)
|
11
14
|
end
|
12
15
|
end
|
16
|
+
end
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
attach_function :cairo_surface_finish, [:pointer], :void
|
18
|
-
end
|
18
|
+
Cairo::Lib.module_eval do
|
19
|
+
attach_function :cairo_surface_flush, [:pointer], :void
|
20
|
+
attach_function :cairo_surface_finish, [:pointer], :void
|
19
21
|
end
|
data/lib/gir_ffi-cairo.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
4
|
|
3
5
|
describe Cairo::Context do
|
4
|
-
describe
|
5
|
-
it
|
6
|
+
describe '.create' do
|
7
|
+
it 'creates a new Cairo::Context' do
|
6
8
|
obj = Cairo::Context.create(nil)
|
7
9
|
obj.must_be_instance_of Cairo::Context
|
8
10
|
end
|
@@ -10,7 +12,7 @@ describe Cairo::Context do
|
|
10
12
|
|
11
13
|
let(:instance) { Cairo::Context.create(nil) }
|
12
14
|
|
13
|
-
describe
|
15
|
+
describe '#get_target' do
|
14
16
|
it "returns the context's target" do
|
15
17
|
instance.get_target.must_be_instance_of Cairo::Surface
|
16
18
|
end
|
@@ -1,15 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
4
|
|
3
5
|
describe Cairo::ImageSurface do
|
4
|
-
it
|
6
|
+
it 'is a subclass of Cairo::Surface' do
|
5
7
|
Cairo::ImageSurface.superclass.must_equal Cairo::Surface
|
6
8
|
end
|
7
9
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
+
describe '.create' do
|
11
|
+
it 'creates a new Cairo::ImageSurface' do
|
10
12
|
obj = Cairo::ImageSurface.create(:argb32, 300, 200)
|
11
13
|
obj.must_be_instance_of Cairo::ImageSurface
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
15
|
-
|
@@ -1,29 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
4
|
|
3
5
|
describe Cairo::PDFSurface do
|
4
|
-
it
|
6
|
+
it 'is a subclass of Cairo::Surface' do
|
5
7
|
Cairo::PDFSurface.superclass.must_equal Cairo::Surface
|
6
8
|
end
|
7
9
|
|
8
|
-
describe
|
10
|
+
describe '.create' do
|
9
11
|
before { @path = 'test.pdf' }
|
10
12
|
after { File.delete(@path) if File.exist? @path }
|
11
13
|
|
12
|
-
it
|
14
|
+
it 'creates a new Cairo::PDFSurface' do
|
13
15
|
obj = Cairo::PDFSurface.create(@path, 300, 200)
|
14
16
|
obj.must_be_instance_of Cairo::PDFSurface
|
15
17
|
end
|
16
18
|
|
17
|
-
it
|
19
|
+
it 'creates a new Cairo::PDFSurface with block' do
|
18
20
|
called = nil
|
19
|
-
Cairo::PDFSurface.create(@path, 300, 200)
|
21
|
+
Cairo::PDFSurface.create(@path, 300, 200) do |surface|
|
20
22
|
surface.must_be_instance_of Cairo::PDFSurface
|
21
23
|
called = true
|
22
|
-
|
24
|
+
end
|
23
25
|
refute_nil called
|
24
26
|
assert File.exist?(@path)
|
25
27
|
end
|
26
|
-
|
27
28
|
end
|
28
29
|
end
|
29
|
-
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
4
|
|
3
5
|
describe Cairo::Context do
|
4
|
-
it
|
6
|
+
it 'can retrieve the surface it was created for' do
|
5
7
|
dst = Cairo::ImageSurface.create(:argb32, 400, 300)
|
6
8
|
ctx = Cairo::Context.create(dst)
|
7
9
|
ctx.get_target.to_ptr.must_equal dst.to_ptr
|
8
10
|
pass
|
9
11
|
end
|
10
12
|
|
11
|
-
it
|
13
|
+
it 'can create and fill a path' do
|
12
14
|
dst = Cairo::ImageSurface.create(:argb32, 400, 300)
|
13
15
|
ctx = Cairo::Context.create(dst)
|
14
16
|
ctx.arc(300, 200, 100, 0, 2 * Math::PI)
|
@@ -21,14 +23,14 @@ describe Cairo::Context do
|
|
21
23
|
before { @path = 'integration-test.pdf' }
|
22
24
|
after { File.delete(@path) if File.exist? @path }
|
23
25
|
|
24
|
-
it
|
25
|
-
Cairo::PDFSurface.create(@path, 400, 300)
|
26
|
+
it 'can create pdf' do
|
27
|
+
Cairo::PDFSurface.create(@path, 400, 300) do |surface|
|
26
28
|
ctx = Cairo::Context.create(surface)
|
27
29
|
ctx.arc(300, 200, 100, 0, 2 * Math::PI)
|
28
30
|
ctx.set_source_rgba(1, 1, 0, 0.5)
|
29
31
|
ctx.fill
|
30
32
|
ctx.show_page
|
31
|
-
|
33
|
+
end
|
32
34
|
pass
|
33
35
|
end
|
34
36
|
end
|
data/test/test_helper.rb
CHANGED
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.
|
4
|
+
version: 0.0.10
|
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:
|
11
|
+
date: 2018-03-24 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.
|
19
|
+
version: 0.12.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.
|
26
|
+
version: 0.12.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '12.0'
|
55
55
|
description: Bindings for Cairo generated by GirFFI, with overrides.
|
56
56
|
email:
|
57
57
|
- matijs@matijs.net
|
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
88
|
+
version: 2.3.0
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.7.6
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: GirFFI-based bindings for Cairo
|