gtk2svg 0.3.2 → 0.3.3
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/gtk2svg.rb +5 -39
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a55c872601bd2d4c2fc6bf06dcb2584fbf0f243c
|
4
|
+
data.tar.gz: beff474fdeea18a06e29fb0b0638a6f74ccc23b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d371d6758b11617697842efa6434513e89d7fbd45c17a8ffb719f34ec689e73420cbd357c41d3da37eb8a4440cad55daf6caed57223a01ece9623252ed1b46a
|
7
|
+
data.tar.gz: c1686b09617e0aa837a0fbb3e26fcb1351ade542f348847af88568b3c481097a124ccbffc1ea29abbf43b0751dc453adf710bd2b6c398bde920035a35452d51f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/gtk2svg.rb
CHANGED
@@ -8,30 +8,8 @@ require 'svgle'
|
|
8
8
|
|
9
9
|
|
10
10
|
# Description: Experimental gem to render SVG within an GTK2 application.
|
11
|
-
# Currently it can only render rectangles along with the fill colour.
|
12
11
|
|
13
12
|
|
14
|
-
module SVG
|
15
|
-
class Element
|
16
|
-
|
17
|
-
attr_reader :style
|
18
|
-
|
19
|
-
def initialize(attributes, style)
|
20
|
-
|
21
|
-
@h = {x: '0', y: '0'}.merge attributes
|
22
|
-
|
23
|
-
@style = {fill: 'black'}
|
24
|
-
@style.merge!(style) if attributes[:style]
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def attributes()
|
29
|
-
@h
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
13
|
module Gtk2SVG
|
36
14
|
|
37
15
|
class Render < DomRender
|
@@ -42,10 +20,7 @@ module Gtk2SVG
|
|
42
20
|
|
43
21
|
def ellipse(e, attributes, style)
|
44
22
|
|
45
|
-
|
46
|
-
h = e2.attributes
|
47
|
-
style = e2.style
|
48
|
-
|
23
|
+
h = attributes
|
49
24
|
|
50
25
|
x, y= %i(cx cy).map{|x| h[x].to_i }
|
51
26
|
width = h[:rx].to_i * 2
|
@@ -56,22 +31,16 @@ module Gtk2SVG
|
|
56
31
|
|
57
32
|
def line(e, attributes, style)
|
58
33
|
|
59
|
-
e2 = SVG::Element.new attributes, style
|
60
|
-
h = e2.attributes
|
61
|
-
style = e2.style
|
62
34
|
style[:stroke_width] = style.delete(:'stroke-width') || '3'
|
63
35
|
|
64
|
-
x1, y1, x2, y2 = %i(x1 y1 x2 y2).map{|x|
|
36
|
+
x1, y1, x2, y2 = %i(x1 y1 x2 y2).map{|x| attributes[x].to_i }
|
65
37
|
|
66
38
|
[:draw_line, [x1, y1, x2, y2], style, render_all(e)]
|
67
39
|
end
|
68
40
|
|
69
41
|
def rect(e, attributes, style)
|
70
42
|
|
71
|
-
|
72
|
-
h = e2.attributes
|
73
|
-
style = e2.style
|
74
|
-
|
43
|
+
h = attributes
|
75
44
|
|
76
45
|
x1, y1, width, height = %i(x y width height).map{|x| h[x].to_i }
|
77
46
|
x2, y2, = x1 + width, y1 + height
|
@@ -81,12 +50,9 @@ module Gtk2SVG
|
|
81
50
|
|
82
51
|
def text(e, attributes, style)
|
83
52
|
|
84
|
-
|
85
|
-
h = e2.attributes
|
86
|
-
style = e2.style.merge({font_size: '20'})
|
87
|
-
|
53
|
+
style.merge!({font_size: '20'})
|
88
54
|
|
89
|
-
x, y, fill = %i(x y fill).map{|x|
|
55
|
+
x, y, fill = %i(x y fill).map{|x| attributes[x] }
|
90
56
|
style.merge!({fill: fill})
|
91
57
|
|
92
58
|
[:draw_layout, [x.to_i, y.to_i], e.text, style, render_all(e)]
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|