glimmer-dsl-gtk 0.0.4 → 0.0.8

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.
@@ -0,0 +1,36 @@
1
+ require 'glimmer-dsl-gtk'
2
+
3
+ include Glimmer
4
+
5
+ window {
6
+ title 'Fill and Stroke 2'
7
+ default_size 256, 256
8
+
9
+ drawing_area {
10
+ paint 242.25, 242.25, 242.25
11
+
12
+ path {
13
+ move_to 128.0, 25.6
14
+ line_to 230.4, 230.4
15
+ rel_line_to -102.4, 0.0
16
+ curve_to 51.2, 230.4, 51.2, 128.0, 128.0, 128.0
17
+ close_path
18
+
19
+ fill 0, 0, 255
20
+ stroke 0, 0, 0
21
+ line_width 10
22
+ }
23
+
24
+ path {
25
+ move_to 64.0, 25.6
26
+ rel_line_to 51.2, 51.2
27
+ rel_line_to -51.2, 51.2
28
+ rel_line_to -51.2, -51.2
29
+ close_path
30
+
31
+ fill 0, 0, 255
32
+ stroke 0, 0, 0
33
+ line_width 10
34
+ }
35
+ }
36
+ }.show
@@ -0,0 +1,43 @@
1
+ require 'glimmer-dsl-gtk'
2
+
3
+ include Glimmer
4
+
5
+ window {
6
+ title 'Fill Style'
7
+ default_size 256, 256
8
+
9
+ drawing_area {
10
+ paint 242.25, 242.25, 242.25
11
+
12
+ path {
13
+ rectangle 12, 12, 232, 70
14
+ path { # sub-path
15
+ arc 64, 64, 40, 0, 2*Math::PI
16
+ }
17
+ path { # sub-path
18
+ arc_negative 192, 64, 40, 0, -2*Math::PI
19
+ }
20
+
21
+ fill_rule Cairo::FILL_RULE_EVEN_ODD
22
+ line_width 6
23
+ fill 0, 178.5, 0
24
+ stroke 0, 0, 0
25
+ }
26
+
27
+ path {
28
+ rectangle 12, 12, 232, 70
29
+ path { # sub-path
30
+ arc 64, 64, 40, 0, 2*Math::PI
31
+ }
32
+ path { # sub-path
33
+ arc_negative 192, 64, 40, 0, -2*Math::PI
34
+ }
35
+
36
+ translate 0, 128
37
+ fill_rule Cairo::FILL_RULE_WINDING
38
+ line_width 6
39
+ fill 0, 0, 229.5
40
+ stroke 0, 0, 0
41
+ }
42
+ }
43
+ }.show
@@ -0,0 +1,31 @@
1
+ require 'glimmer-dsl-gtk'
2
+
3
+ include Glimmer
4
+
5
+ window {
6
+ title 'Gradient'
7
+ default_size 256, 256
8
+
9
+ drawing_area {
10
+ paint 242.25, 242.25, 242.25
11
+
12
+ # Create the Linear Pattern
13
+ rectangle(0, 0, 256, 256) {
14
+ pat = Cairo::LinearPattern.new(0.0, 0.0, 0.0, 256.0)
15
+ pat.add_color_stop_rgba(1, 0, 0, 0, 1)
16
+ pat.add_color_stop_rgba(0, 1, 1, 1, 1)
17
+
18
+ fill pat
19
+ }
20
+
21
+ # Create the radial pattern
22
+ arc(128.0, 128.0, 76.8, 0, 2 * Math::PI) {
23
+ pat = Cairo::RadialPattern.new(115.2, 102.4, 25.6,
24
+ 102.4, 102.4, 128.0)
25
+ pat.add_color_stop_rgba(0, 1, 1, 1, 1)
26
+ pat.add_color_stop_rgba(1, 0, 0, 0, 1)
27
+
28
+ fill pat
29
+ }
30
+ }
31
+ }.show
@@ -0,0 +1,28 @@
1
+ require 'glimmer-dsl-gtk'
2
+ require 'net/http'
3
+
4
+ image_content = Net::HTTP.get(URI('https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-gtk/master/images/breaking-blue-wave.png'))
5
+ image_file = File.join(Dir.home, 'breaking-blue-wave.png')
6
+ File.write(image_file, image_content)
7
+
8
+ include Glimmer
9
+
10
+ window {
11
+ title 'Image'
12
+ default_size 256, 256
13
+
14
+ drawing_area {
15
+ paint 242.25, 242.25, 242.25
16
+
17
+ image = Cairo::ImageSurface.from_png(image_file)
18
+ w = image.width
19
+ h = image.height
20
+
21
+ translate 128.0, 128.0
22
+ rotate 45*Math::PI/180
23
+ scale 256.0/w, 256.0/h
24
+ translate -0.5*w, -0.5*h
25
+
26
+ paint image, 0, 0
27
+ }
28
+ }.show
@@ -0,0 +1,37 @@
1
+ require 'glimmer-dsl-gtk'
2
+ require 'net/http'
3
+
4
+ image_content = Net::HTTP.get(URI('https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-gtk/master/images/breaking-blue-wave.png'))
5
+ image_file = File.join(Dir.home, 'breaking-blue-wave.png')
6
+ File.write(image_file, image_content)
7
+
8
+ include Glimmer
9
+
10
+ window {
11
+ title 'Image Gradient'
12
+ default_size 256, 256
13
+
14
+ drawing_area {
15
+ paint 242.25, 242.25, 242.25
16
+
17
+ image = Cairo::ImageSurface.from_png(image_file)
18
+ w = image.width
19
+ h = image.height
20
+
21
+ # Load the image as a surface pattern
22
+ pattern = Cairo::SurfacePattern.new(image)
23
+ pattern.extend = Cairo::EXTEND_REPEAT
24
+
25
+ # Set up the scale matrix
26
+ pattern.matrix = Cairo::Matrix.scale(w/256.0 * 5.0, h/256.0 * 5.0)
27
+
28
+ rectangle(0, 0, 256, 256) {
29
+ translate 128.0, 128.0
30
+ rotate Math::PI / 4
31
+ scale 1/Math.sqrt(2), 1/Math.sqrt(2)
32
+ translate -128.0, -128.0
33
+
34
+ fill pattern
35
+ }
36
+ }
37
+ }.show
@@ -0,0 +1,27 @@
1
+ require 'glimmer-dsl-gtk'
2
+
3
+ include Glimmer
4
+
5
+ window {
6
+ title 'Multi Segment Caps'
7
+ default_size 256, 256
8
+
9
+ drawing_area {
10
+ paint 242.25, 242.25, 242.25
11
+
12
+ path {
13
+ move_to 50.0, 75.0
14
+ line_to 200.0, 75.0
15
+
16
+ move_to 50.0, 125.0
17
+ line_to 200.0, 125.0
18
+
19
+ move_to 50.0, 175.0
20
+ line_to 200.0, 175.0
21
+
22
+ line_width 30
23
+ line_cap Cairo::LINE_CAP_ROUND
24
+ stroke 0, 0, 0
25
+ }
26
+ }
27
+ }.show
@@ -0,0 +1,20 @@
1
+ require 'glimmer-dsl-gtk'
2
+
3
+ include Glimmer
4
+
5
+ window {
6
+ title 'Rounded Rectangle'
7
+ default_size 256, 256
8
+
9
+ drawing_area {
10
+ paint 242.25, 242.25, 242.25
11
+
12
+ path {
13
+ rounded_rectangle(25.6, 25.6, 204.8, 204.8, 20)
14
+
15
+ fill 127.5, 127.5, 255
16
+ line_width 10.0
17
+ stroke 127.5, 0, 0, 0.5
18
+ }
19
+ }
20
+ }.show
@@ -0,0 +1,53 @@
1
+ require 'glimmer-dsl-gtk'
2
+
3
+ include Glimmer
4
+
5
+ window {
6
+ title 'Set line cap'
7
+ default_size 256, 256
8
+
9
+ drawing_area {
10
+ paint 242.25, 242.25, 242.25
11
+
12
+ # The main code
13
+ path {
14
+ move_to 64.0, 50.0
15
+ line_to 64.0, 200.0
16
+
17
+ line_cap Cairo::LINE_CAP_BUTT # default
18
+ line_width 30
19
+ stroke 0, 0, 0
20
+ }
21
+
22
+ path {
23
+ move_to 128.0, 50.0
24
+ line_to 128.0, 200.0
25
+
26
+ line_cap Cairo::LINE_CAP_ROUND
27
+ line_width 30
28
+ stroke 0, 0, 0
29
+ }
30
+
31
+ path {
32
+ move_to 192.0, 50.0
33
+ line_to 192.0, 200.0
34
+
35
+ line_cap Cairo::LINE_CAP_SQUARE
36
+ line_width 30
37
+ stroke 0, 0, 0
38
+ }
39
+
40
+ # draw helping lines */
41
+ path {
42
+ move_to 64.0, 50.0
43
+ line_to 64.0, 200.0
44
+ move_to 128.0, 50.0
45
+ line_to 128.0, 200.0
46
+ move_to 192.0, 50.0
47
+ line_to 192.0, 200.0
48
+
49
+ line_width 2.56
50
+ stroke 255, 51, 51
51
+ }
52
+ }
53
+ }.show
@@ -0,0 +1,43 @@
1
+ require 'glimmer-dsl-gtk'
2
+
3
+ include Glimmer
4
+
5
+ window {
6
+ title 'Set line join'
7
+ default_size 256, 256
8
+
9
+ drawing_area {
10
+ paint 242.25, 242.25, 242.25
11
+
12
+ # The main code
13
+ path {
14
+ move_to 76.8, 84.48
15
+ rel_line_to 51.2, -51.2
16
+ rel_line_to 51.2, 51.2
17
+
18
+ line_join Cairo::LINE_JOIN_MITER # default
19
+ line_width 40.96
20
+ stroke 0, 0, 0
21
+ }
22
+
23
+ path {
24
+ move_to 76.8, 161.28
25
+ rel_line_to 51.2, -51.2
26
+ rel_line_to 51.2, 51.2
27
+
28
+ line_join Cairo::LINE_JOIN_BEVEL
29
+ line_width 40.96
30
+ stroke 0, 0, 0
31
+ }
32
+
33
+ path {
34
+ move_to 76.8, 238.08
35
+ rel_line_to 51.2, -51.2
36
+ rel_line_to 51.2, 51.2
37
+
38
+ line_join Cairo::LINE_JOIN_ROUND
39
+ line_width 40.96
40
+ stroke 0, 0, 0
41
+ }
42
+ }
43
+ }.show
@@ -0,0 +1,46 @@
1
+ require 'glimmer-dsl-gtk'
2
+
3
+ include Glimmer
4
+
5
+ window {
6
+ title 'Text'
7
+ default_size 256, 256
8
+
9
+ drawing_area {
10
+ paint 242.25, 242.25, 242.25
11
+
12
+ font_family = OS.linux? ? 'Sans' : (OS.mac? ? 'Helvetica' : 'Arial')
13
+
14
+ # The main code
15
+ path {
16
+ move_to 10.0, 135.0
17
+ show_text 'Hello'
18
+
19
+ font_face font_family, Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_BOLD
20
+ font_size 90.0
21
+ line_width 2.56
22
+ fill 0, 0, 0
23
+ stroke 0, 0, 0
24
+ }
25
+
26
+ path {
27
+ move_to 70.0, 165.0
28
+ text_path 'void'
29
+
30
+ font_face font_family, Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_BOLD
31
+ font_size 90.0
32
+ line_width 2.56
33
+ fill 127.5, 127.5, 255
34
+ stroke 0, 0, 0
35
+ }
36
+
37
+ # draw helping lines
38
+ path {
39
+ arc 10.0, 135.0, 5.12, 0, 2*Math::PI
40
+ close_path
41
+ arc 70.0, 165.0, 5.12, 0, 2*Math::PI
42
+
43
+ fill 255, 51, 51, 0.6
44
+ }
45
+ }
46
+ }.show
@@ -7,9 +7,7 @@ window {
7
7
  default_size 400, 400
8
8
 
9
9
  drawing_area {
10
- rectangle(0, 0, 400, 400) {
11
- fill 255, 255, 255
12
- }
10
+ paint 255, 255, 255
13
11
 
14
12
  arc(85, 85, 45, (Math::PI/180)*90, -(Math::PI/180)*90) {
15
13
  fill 255, 0, 0
@@ -8,61 +8,60 @@ window {
8
8
 
9
9
  drawing_area {
10
10
  on(:draw) do |drawing_area_widget, cairo_context|
11
- cairo_context.rectangle(0, 0, 400, 400)
12
- cairo_context.set_source_rgb(255, 255, 255)
13
- cairo_context.fill
11
+ cairo_context.set_source_rgb(255/255.0, 255/255.0, 255/255.0)
12
+ cairo_context.paint
14
13
 
15
14
  cairo_context.arc(85, 85, 45, (Math::PI/180)*90, -(Math::PI/180)*90)
16
15
  cairo_context.set_source_rgb(255, 0, 0)
17
16
  cairo_context.fill
18
17
 
19
18
  cairo_context.arc(85, 85, 45, (Math::PI/180)*90, -(Math::PI/180)*90)
20
- cairo_context.set_source_rgb(0, 128, 255)
19
+ cairo_context.set_source_rgb(0, 128/255.0, 255/255.0)
21
20
  cairo_context.set_line_width(3)
22
21
  cairo_context.stroke
23
22
 
24
23
  cairo_context.arc(85, 185, 45, (Math::PI/180)*100, -(Math::PI/180)*30)
25
- cairo_context.set_source_rgb(255, 0, 0)
24
+ cairo_context.set_source_rgb(255/255.0, 0, 0)
26
25
  cairo_context.fill
27
26
 
28
27
  cairo_context.arc(85, 185, 45, (Math::PI/180)*100, -(Math::PI/180)*30)
29
- cairo_context.set_source_rgb(0, 128, 255)
28
+ cairo_context.set_source_rgb(0, 128/255.0, 255/255.0)
30
29
  cairo_context.set_line_width(3)
31
30
  cairo_context.stroke
32
31
 
33
32
  cairo_context.circle(85, 285, 45)
34
- cairo_context.set_source_rgb(255, 0, 0)
33
+ cairo_context.set_source_rgb(255/255.0, 0, 0)
35
34
  cairo_context.fill
36
35
 
37
36
  cairo_context.circle(85, 285, 45)
38
- cairo_context.set_source_rgb(0, 128, 255)
37
+ cairo_context.set_source_rgb(0, 128/255.0, 255/255.0)
39
38
  cairo_context.set_line_width(3)
40
39
  cairo_context.stroke
41
40
 
42
41
  cairo_context.rectangle(140, 40, 180, 90)
43
- cairo_context.set_source_rgb(255, 255, 0)
42
+ cairo_context.set_source_rgb(255/255.0, 255/255.0, 0)
44
43
  cairo_context.fill
45
44
 
46
45
  cairo_context.rectangle(140, 40, 180, 90)
47
- cairo_context.set_source_rgb(255, 0, 0)
46
+ cairo_context.set_source_rgb(255/255.0, 0, 0)
48
47
  cairo_context.set_line_width(3)
49
48
  cairo_context.stroke
50
49
 
51
50
  cairo_context.rounded_rectangle(140, 140, 180, 90, 30, 20)
52
- cairo_context.set_source_rgb(255, 255, 0)
51
+ cairo_context.set_source_rgb(255/255.0, 255/255.0, 0)
53
52
  cairo_context.fill
54
53
 
55
54
  cairo_context.rounded_rectangle(140, 140, 180, 90, 30, 20)
56
- cairo_context.set_source_rgb(255, 0, 0)
55
+ cairo_context.set_source_rgb(255/255.0, 0, 0)
57
56
  cairo_context.set_line_width(3)
58
57
  cairo_context.stroke
59
58
 
60
59
  cairo_context.triangle(140, 240, 320, 240, 230, 330)
61
- cairo_context.set_source_rgb(255, 255, 0)
60
+ cairo_context.set_source_rgb(255/255.0, 255/255.0, 0)
62
61
  cairo_context.fill
63
62
 
64
63
  cairo_context.triangle(140, 240, 320, 240, 230, 330)
65
- cairo_context.set_source_rgb(255, 0, 0)
64
+ cairo_context.set_source_rgb(255/255.0, 0, 0)
66
65
  cairo_context.set_line_width(3)
67
66
  cairo_context.stroke
68
67
 
@@ -71,7 +70,7 @@ window {
71
70
  cairo_context.curve_to 190, 60, 200, 80, 210, 70
72
71
  cairo_context.curve_to 240, 80, 250, 100, 260, 90
73
72
  cairo_context.curve_to 290, 90, 300, 110, 310, 100
74
- cairo_context.set_source_rgb(0, 255, 0)
73
+ cairo_context.set_source_rgb(0, 255/255.0, 0)
75
74
  cairo_context.fill
76
75
 
77
76
  cairo_context.new_path
@@ -79,7 +78,7 @@ window {
79
78
  cairo_context.curve_to 190, 60, 200, 80, 210, 70
80
79
  cairo_context.curve_to 240, 80, 250, 100, 260, 90
81
80
  cairo_context.curve_to 290, 90, 300, 110, 310, 100
82
- cairo_context.set_source_rgb(0, 0, 255)
81
+ cairo_context.set_source_rgb(0, 0, 255/255.0)
83
82
  cairo_context.stroke
84
83
 
85
84
  cairo_context.new_path
@@ -90,7 +89,7 @@ window {
90
89
  cairo_context.line_to 200, 200
91
90
  cairo_context.line_to 180, 170
92
91
  cairo_context.close_path
93
- cairo_context.set_source_rgb(0, 255, 0)
92
+ cairo_context.set_source_rgb(0, 255/255.0, 0)
94
93
  cairo_context.fill
95
94
 
96
95
  cairo_context.new_path
@@ -101,7 +100,7 @@ window {
101
100
  cairo_context.line_to 200, 200
102
101
  cairo_context.line_to 180, 170
103
102
  cairo_context.close_path
104
- cairo_context.set_source_rgb(0, 0, 255)
103
+ cairo_context.set_source_rgb(0, 0, 255/255.0)
105
104
  cairo_context.stroke
106
105
 
107
106
  cairo_context.new_path
@@ -112,7 +111,7 @@ window {
112
111
  cairo_context.line_to 200, 280
113
112
  cairo_context.line_to 180, 270
114
113
  cairo_context.close_path
115
- cairo_context.set_source_rgb(0, 255, 0)
114
+ cairo_context.set_source_rgb(0, 255/255.0, 0)
116
115
  cairo_context.fill
117
116
 
118
117
  cairo_context.new_path
@@ -123,7 +122,7 @@ window {
123
122
  cairo_context.line_to 200, 280
124
123
  cairo_context.line_to 180, 270
125
124
  cairo_context.close_path
126
- cairo_context.set_source_rgb(0, 0, 255)
125
+ cairo_context.set_source_rgb(0, 0, 255/255.0)
127
126
  cairo_context.stroke
128
127
 
129
128
  cairo_context.new_path
@@ -133,7 +132,7 @@ window {
133
132
  cairo_context.line_to 220, 340
134
133
  cairo_context.line_to 200, 330
135
134
  cairo_context.line_to 180, 320
136
- cairo_context.set_source_rgb(0, 0, 255)
135
+ cairo_context.set_source_rgb(0, 0, 255/255.0)
137
136
  cairo_context.stroke
138
137
  end
139
138
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-gtk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-29 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -142,7 +142,8 @@ dependencies:
142
142
  - - ">"
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
- description: Glimmer DSL for GTK - Ruby-GNOME Desktop Development GUI Library
145
+ description: Glimmer DSL for GTK - Ruby-GNOME Desktop Development GUI Library - Supports
146
+ all GTK widgets and Cairo graphics
146
147
  email: andy.am@gmail.com
147
148
  executables:
148
149
  - girb
@@ -170,6 +171,7 @@ files:
170
171
  - lib/glimmer/gtk.rb
171
172
  - lib/glimmer/gtk/shape.rb
172
173
  - lib/glimmer/gtk/shape/arc.rb
174
+ - lib/glimmer/gtk/shape/arc_negative.rb
173
175
  - lib/glimmer/gtk/shape/circle.rb
174
176
  - lib/glimmer/gtk/shape/path.rb
175
177
  - lib/glimmer/gtk/shape/polygon.rb
@@ -178,12 +180,29 @@ files:
178
180
  - lib/glimmer/gtk/shape/rounded_rectangle.rb
179
181
  - lib/glimmer/gtk/shape/square.rb
180
182
  - lib/glimmer/gtk/shape/triangle.rb
183
+ - lib/glimmer/gtk/transformable.rb
181
184
  - lib/glimmer/gtk/widget_proxy.rb
182
185
  - lib/glimmer/gtk/widget_proxy/application_proxy.rb
183
186
  - lib/glimmer/gtk/widget_proxy/box_proxy.rb
184
187
  - lib/glimmer/gtk/widget_proxy/drawing_area_proxy.rb
185
188
  - lib/glimmer/gtk/widget_proxy/message_dialog_proxy.rb
186
189
  - lib/glimmer/gtk/widget_proxy/window_proxy.rb
190
+ - samples/cairo/arc.rb
191
+ - samples/cairo/arc_negative.rb
192
+ - samples/cairo/clip.rb
193
+ - samples/cairo/clip_image.rb
194
+ - samples/cairo/curve_to.rb
195
+ - samples/cairo/dashes.rb
196
+ - samples/cairo/fill_and_stroke2.rb
197
+ - samples/cairo/fill_style.rb
198
+ - samples/cairo/gradient.rb
199
+ - samples/cairo/image.rb
200
+ - samples/cairo/image_gradient.rb
201
+ - samples/cairo/multi_segment_caps.rb
202
+ - samples/cairo/rounded_rectangle.rb
203
+ - samples/cairo/set_line_cap.rb
204
+ - samples/cairo/set_line_join.rb
205
+ - samples/cairo/text.rb
187
206
  - samples/elaborate/tetris.rb
188
207
  - samples/elaborate/tetris/model/block.rb
189
208
  - samples/elaborate/tetris/model/game.rb