gtk2svg 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/gtk2svg.rb +31 -17
- 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: f0fe558967f563d8d4f111a47f1c6437c13d369a
|
4
|
+
data.tar.gz: f0004931e1cac3e8fa85098dcfcaa4c05fbd0f40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 285349e48fb22a23d68cd8f7d2e56a072778d9d6ce6dceddfbd81ee67cc20e19e4b9bb81f3b7810438c53e33d4fdbcafb0c88e644e65edf9e5192ffd8273d909
|
7
|
+
data.tar.gz: bec7350106552e774b66486d708c744fa136167862c50371fad7adf68925e763e38c9f9940b0853579017ad047f84059a57aa120b13641bb41c4c83ab194c6cf
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/gtk2svg.rb
CHANGED
@@ -9,12 +9,15 @@ require 'svgle'
|
|
9
9
|
# Description: Experimental gem to render SVG within an GTK2 application.
|
10
10
|
|
11
11
|
|
12
|
+
|
12
13
|
module Gtk2SVG
|
13
14
|
|
14
15
|
class Render < DomRender
|
15
16
|
|
16
17
|
|
17
|
-
def circle(e, attributes,
|
18
|
+
def circle(e, attributes, raw_style)
|
19
|
+
|
20
|
+
style = style_filter(attributes).merge(raw_style)
|
18
21
|
|
19
22
|
h = attributes
|
20
23
|
|
@@ -24,8 +27,9 @@ module Gtk2SVG
|
|
24
27
|
[:draw_arc, [x, y, radius, radius], style, render_all(e)]
|
25
28
|
end
|
26
29
|
|
27
|
-
def ellipse(e, attributes,
|
30
|
+
def ellipse(e, attributes, raw_style)
|
28
31
|
|
32
|
+
style = style_filter(attributes).merge(raw_style)
|
29
33
|
h = attributes
|
30
34
|
|
31
35
|
x, y= %i(cx cy).map{|x| h[x].to_i }
|
@@ -35,33 +39,36 @@ module Gtk2SVG
|
|
35
39
|
[:draw_arc, [x, y, width, height], style, render_all(e)]
|
36
40
|
end
|
37
41
|
|
38
|
-
def line(e, attributes,
|
42
|
+
def line(e, attributes, raw_style)
|
39
43
|
|
40
|
-
style
|
44
|
+
style = style_filter(attributes).merge(raw_style)
|
41
45
|
|
42
46
|
x1, y1, x2, y2 = %i(x1 y1 x2 y2).map{|x| attributes[x].to_i }
|
43
47
|
|
44
48
|
[:draw_line, [x1, y1, x2, y2], style, render_all(e)]
|
45
49
|
end
|
46
50
|
|
47
|
-
def polygon(e, attributes,
|
51
|
+
def polygon(e, attributes, raw_style)
|
48
52
|
|
53
|
+
style = style_filter(attributes).merge(raw_style)
|
49
54
|
points = attributes[:points].split(/\s+/). \
|
50
55
|
map {|x| x.split(/\s*,\s*/).map(&:to_i)}
|
51
56
|
|
52
57
|
[:draw_polygon, points, style, render_all(e)]
|
53
58
|
end
|
54
59
|
|
55
|
-
def polyline(e, attributes,
|
60
|
+
def polyline(e, attributes, raw_style)
|
56
61
|
|
62
|
+
style = style_filter(attributes).merge(raw_style)
|
57
63
|
points = attributes[:points].split(/\s+/). \
|
58
64
|
map {|x| x.split(/\s*,\s*/).map(&:to_i)}
|
59
65
|
|
60
|
-
[:
|
66
|
+
[:draw_lines, points, style, render_all(e)]
|
61
67
|
end
|
62
68
|
|
63
|
-
def rect(e, attributes,
|
69
|
+
def rect(e, attributes, raw_style)
|
64
70
|
|
71
|
+
style = style_filter(attributes).merge(raw_style)
|
65
72
|
h = attributes
|
66
73
|
|
67
74
|
x1, y1, width, height = %i(x y width height).map{|x| h[x].to_i }
|
@@ -78,15 +85,25 @@ module Gtk2SVG
|
|
78
85
|
[:window, render_all(x)]
|
79
86
|
end
|
80
87
|
|
81
|
-
def text(e, attributes,
|
88
|
+
def text(e, attributes, raw_style)
|
82
89
|
|
90
|
+
style = style_filter(attributes).merge(raw_style)
|
83
91
|
style.merge!({font_size: '20'})
|
84
92
|
|
85
|
-
x, y
|
86
|
-
style.merge!({fill: fill})
|
93
|
+
x, y = %i(x y).map{|x| attributes[x].to_i }
|
87
94
|
|
88
|
-
[:draw_layout, [x
|
95
|
+
[:draw_layout, [x, y], e.text, style, render_all(e)]
|
89
96
|
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def style_filter(attributes)
|
101
|
+
|
102
|
+
%i(stroke stroke-width fill).inject({}) do |r,x|
|
103
|
+
attributes.has_key?(x) ? r.merge(x => attributes[x]) : r
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
90
107
|
|
91
108
|
end
|
92
109
|
|
@@ -132,11 +149,9 @@ module Gtk2SVG
|
|
132
149
|
@area.window.draw_polygon(gc, 1, points)
|
133
150
|
end
|
134
151
|
|
135
|
-
def
|
136
|
-
puts 'inside sraw_polying;'
|
137
|
-
points, style = args
|
138
|
-
puts 'style: ' + style.inspect
|
152
|
+
def draw_lines(args)
|
139
153
|
|
154
|
+
points, style = args
|
140
155
|
|
141
156
|
gc = gc_ini(fill: style[:fill] || :none, stroke: style[:stroke] || :none)
|
142
157
|
gc.set_line_attributes(style[:'stroke-width'].to_i, Gdk::GC::LINE_SOLID, \
|
@@ -224,7 +239,6 @@ module Gtk2SVG
|
|
224
239
|
def gc_ini(fill: nil, stroke: nil)
|
225
240
|
gc = Gdk::GC.new(@area.window)
|
226
241
|
colour = fill || stroke
|
227
|
-
puts 'colur : ' + colour.inspect
|
228
242
|
|
229
243
|
unless colour == :none or colour == 'none'
|
230
244
|
gc.set_foreground(set_colour(colour))
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|