glimmer-dsl-libui 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
data/bin/girb CHANGED
File without changes
@@ -4,50 +4,50 @@ include Glimmer
4
4
 
5
5
  window('Area Gallery', 400, 400) {
6
6
  area {
7
- path { # declarative stable path
7
+ path { # declarative stable path (explicit path syntax for multiple shapes sharing attributes)
8
8
  square(0, 0, 100)
9
9
  square(100, 100, 400)
10
-
10
+
11
11
  fill r: 102, g: 102, b: 204
12
12
  }
13
- path { # declarative stable path
13
+
14
+ path { # declarative stable path (explicit path syntax for multiple shapes sharing attributes)
14
15
  rectangle(0, 100, 100, 400)
15
16
  rectangle(100, 0, 400, 100)
16
-
17
+
17
18
  # linear gradient (has x0, y0, x1, y1, and stops)
18
19
  fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
19
20
  }
20
- path { # declarative stable path
21
- polygon(100, 100, 100, 400, 400, 100, 400, 400)
22
-
21
+
22
+ polygon(100, 100, 100, 400, 400, 100, 400, 400) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
23
23
  fill r: 202, g: 102, b: 104, a: 0.5
24
24
  stroke r: 0, g: 0, b: 0
25
25
  }
26
- path { # declarative stable path
27
- polybezier(0, 0, 200, 100, 100, 200, 400, 100, 300, 100, 100, 300, 100, 400, 100, 300, 300, 100, 400, 400)
28
-
26
+
27
+ polybezier(0, 0,
28
+ 200, 100, 100, 200, 400, 100,
29
+ 300, 100, 100, 300, 100, 400,
30
+ 100, 300, 300, 100, 400, 400) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
29
31
  fill r: 202, g: 102, b: 204, a: 0.5
30
32
  stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
31
33
  }
32
- path { # declarative stable path
33
- polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
34
34
 
35
+ polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
35
36
  stroke r: 0, g: 0, b: 0, thickness: 2
36
37
  }
37
- path { # declarative stable path
38
- arc(404, 216, 190, 90, 90, false)
39
-
38
+
39
+ arc(404, 216, 190, 90, 90, false) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
40
40
  # radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
41
41
  fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
42
42
  stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
43
43
  }
44
- path { # declarative stable path
45
- circle(200, 200, 90)
46
-
44
+
45
+ circle(200, 200, 90) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
47
46
  fill r: 202, g: 102, b: 204, a: 0.5
48
47
  stroke r: 0, g: 0, b: 0, thickness: 2
49
48
  }
50
- text(161, 40, 100) { # x, y, width
49
+
50
+ text(161, 40, 100) { # declarative stable text
51
51
  string('Area Gallery') {
52
52
  font family: 'Arial', size: (OS.mac? ? 14 : 11)
53
53
  color :black
@@ -4,12 +4,13 @@ include Glimmer
4
4
 
5
5
  window('Area Gallery', 400, 400) {
6
6
  area {
7
- path { # declarative stable path
7
+ path { # declarative stable path with explicit attributes (explicit path syntax for multiple shapes sharing attributes)
8
8
  square {
9
9
  x 0
10
10
  y 0
11
11
  length 100
12
12
  }
13
+
13
14
  square {
14
15
  x 100
15
16
  y 100
@@ -18,13 +19,15 @@ window('Area Gallery', 400, 400) {
18
19
 
19
20
  fill r: 102, g: 102, b: 204
20
21
  }
21
- path { # declarative stable path
22
+
23
+ path { # declarative stable path with explicit attributes (explicit path syntax for multiple shapes sharing attributes)
22
24
  rectangle {
23
25
  x 0
24
26
  y 100
25
27
  width 100
26
28
  height 400
27
29
  }
30
+
28
31
  rectangle {
29
32
  x 100
30
33
  y 0
@@ -35,115 +38,114 @@ window('Area Gallery', 400, 400) {
35
38
  # linear gradient (has x0, y0, x1, y1, and stops)
36
39
  fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
37
40
  }
38
- path { # declarative stable path
39
- figure {
41
+
42
+ figure { # declarative stable path with explicit attributes (implicit path syntax for a single shape nested directly under area)
43
+ x 100
44
+ y 100
45
+
46
+ line {
40
47
  x 100
48
+ y 400
49
+ }
50
+
51
+ line {
52
+ x 400
41
53
  y 100
42
-
43
- line {
44
- x 100
45
- y 400
46
- }
47
- line {
48
- x 400
49
- y 100
50
- }
51
- line {
52
- x 400
53
- y 400
54
- }
55
-
56
- closed true
54
+ }
55
+
56
+ line {
57
+ x 400
58
+ y 400
57
59
  }
58
60
 
61
+ closed true # polygon figure is closed (last point forms a line with first point)
59
62
  fill r: 202, g: 102, b: 104, a: 0.5
60
63
  stroke r: 0, g: 0, b: 0
61
64
  }
62
- path { # declarative stable path
63
- figure {
64
- x 0
65
- y 0
66
-
67
- bezier {
68
- c1_x 200
69
- c1_y 100
70
- c2_x 100
71
- c2_y 200
72
- end_x 400
73
- end_y 100
74
- }
75
- bezier {
76
- c1_x 300
77
- c1_y 100
78
- c2_x 100
79
- c2_y 300
80
- end_x 100
81
- end_y 400
82
- }
83
- bezier {
84
- c1_x 100
85
- c1_y 300
86
- c2_x 300
87
- c2_y 100
88
- end_x 400
89
- end_y 400
90
- }
65
+
66
+ figure { # declarative stable path with explicit attributes (implicit path syntax for a single shape nested directly under area)
67
+ x 0
68
+ y 0
69
+
70
+ bezier {
71
+ c1_x 200
72
+ c1_y 100
73
+ c2_x 100
74
+ c2_y 200
75
+ end_x 400
76
+ end_y 100
91
77
  }
92
-
78
+
79
+ bezier {
80
+ c1_x 300
81
+ c1_y 100
82
+ c2_x 100
83
+ c2_y 300
84
+ end_x 100
85
+ end_y 400
86
+ }
87
+
88
+ bezier {
89
+ c1_x 100
90
+ c1_y 300
91
+ c2_x 300
92
+ c2_y 100
93
+ end_x 400
94
+ end_y 400
95
+ }
96
+
93
97
  fill r: 202, g: 102, b: 204, a: 0.5
94
98
  stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
95
99
  }
96
- path { # declarative stable path
97
- polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
98
- figure {
99
- x 100
100
+
101
+ figure { # declarative stable path with explicit attributes (implicit path syntax for a single shape nested directly under area)
102
+ x 100
103
+ y 100
104
+
105
+ line {
106
+ x 400
100
107
  y 100
101
-
102
- line {
103
- x 400
104
- y 100
105
- }
106
- line {
107
- x 100
108
- y 400
109
- }
110
- line {
111
- x 400
112
- y 400
113
- }
114
- line {
115
- x 0
116
- y 0
117
- }
118
108
  }
119
-
109
+
110
+ line {
111
+ x 100
112
+ y 400
113
+ }
114
+
115
+ line {
116
+ x 400
117
+ y 400
118
+ }
119
+
120
+ line {
121
+ x 0
122
+ y 0
123
+ }
124
+
120
125
  stroke r: 0, g: 0, b: 0, thickness: 2
121
126
  }
122
- path { # declarative stable path
123
- arc {
124
- x_center 404
125
- y_center 216
126
- radius 190
127
- start_angle 90
128
- sweep 90
129
- is_negative false
130
- }
131
-
127
+
128
+ arc { # declarative stable path with explicit attributes (implicit path syntax for a single shape nested directly under area)
129
+ x_center 404
130
+ y_center 216
131
+ radius 190
132
+ start_angle 90
133
+ sweep 90
134
+ is_negative false
132
135
  # radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
133
136
  fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
134
137
  stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
135
138
  }
136
- path { # declarative stable path
137
- circle {
138
- x_center 200
139
- y_center 200
140
- radius 90
141
- }
142
-
139
+
140
+ circle { # declarative stable path with explicit attributes (implicit path syntax for a single shape nested directly under area)
141
+ x_center 200
142
+ y_center 200
143
+ radius 90
143
144
  fill r: 202, g: 102, b: 204, a: 0.5
144
145
  stroke r: 0, g: 0, b: 0, thickness: 2
145
146
  }
146
- text {
147
+
148
+ text { # declarative stable text with explicit attributes
147
149
  x 161
148
150
  y 40
149
151
  width 100
@@ -5,50 +5,50 @@ include Glimmer
5
5
  window('Area Gallery', 400, 400) {
6
6
  area {
7
7
  on_draw do |area_draw_params|
8
- path { # a dynamic path is added semi-declaratively inside on_draw block
8
+ path { # dynamic path, added semi-declaratively inside on_draw block
9
9
  square(0, 0, 100)
10
10
  square(100, 100, 400)
11
-
11
+
12
12
  fill r: 102, g: 102, b: 204
13
13
  }
14
- path { # a dynamic path is added semi-declaratively inside on_draw block
14
+
15
+ path { # dynamic path, added semi-declaratively inside on_draw block
15
16
  rectangle(0, 100, 100, 400)
16
17
  rectangle(100, 0, 400, 100)
17
-
18
+
18
19
  # linear gradient (has x0, y0, x1, y1, and stops)
19
20
  fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
20
21
  }
21
- path { # a dynamic path is added semi-declaratively inside on_draw block
22
- polygon(100, 100, 100, 400, 400, 100, 400, 400)
23
-
22
+
23
+ polygon(100, 100, 100, 400, 400, 100, 400, 400) { # dynamic path, added semi-declaratively inside on_draw block
24
24
  fill r: 202, g: 102, b: 104, a: 0.5
25
25
  stroke r: 0, g: 0, b: 0
26
26
  }
27
- path { # a dynamic path is added semi-declaratively inside on_draw block
28
- polybezier(0, 0, 200, 100, 100, 200, 400, 100, 300, 100, 100, 300, 100, 400, 100, 300, 300, 100, 400, 400)
29
-
27
+
28
+ polybezier(0, 0,
29
+ 200, 100, 100, 200, 400, 100,
30
+ 300, 100, 100, 300, 100, 400,
31
+ 100, 300, 300, 100, 400, 400) { # dynamic path, added semi-declaratively inside on_draw block
30
32
  fill r: 202, g: 102, b: 204, a: 0.5
31
33
  stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
32
34
  }
33
- path { # a dynamic path is added semi-declaratively inside on_draw block
34
- polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
35
35
 
36
+ polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0) { # dynamic path, added semi-declaratively inside on_draw block
36
37
  stroke r: 0, g: 0, b: 0, thickness: 2
37
38
  }
38
- path { # a dynamic path is added semi-declaratively inside on_draw block
39
- arc(404, 216, 190, 90, 90, false)
40
-
39
+
40
+ arc(404, 216, 190, 90, 90, false) { # dynamic path, added semi-declaratively inside on_draw block
41
41
  # radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
42
42
  fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
43
43
  stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
44
44
  }
45
- path { # a dynamic path is added semi-declaratively inside on_draw block
46
- circle(200, 200, 90)
47
-
45
+
46
+ circle(200, 200, 90) { # dynamic path, added semi-declaratively inside on_draw block
48
47
  fill r: 202, g: 102, b: 204, a: 0.5
49
48
  stroke r: 0, g: 0, b: 0, thickness: 2
50
49
  }
51
- text(161, 40, 100) { # x, y, width
50
+
51
+ text(161, 40, 100) { # dynamic text added semi-declaratively inside on_draw block
52
52
  string('Area Gallery') {
53
53
  font family: 'Arial', size: (OS.mac? ? 14 : 11)
54
54
  color :black
@@ -5,12 +5,13 @@ include Glimmer
5
5
  window('Area Gallery', 400, 400) {
6
6
  area {
7
7
  on_draw do |area_draw_params|
8
- path { # a dynamic path is added semi-declaratively inside on_draw block
8
+ path { # dynamic path, added semi-declaratively inside on_draw block
9
9
  square {
10
10
  x 0
11
11
  y 0
12
12
  length 100
13
13
  }
14
+
14
15
  square {
15
16
  x 100
16
17
  y 100
@@ -19,13 +20,15 @@ window('Area Gallery', 400, 400) {
19
20
 
20
21
  fill r: 102, g: 102, b: 204
21
22
  }
22
- path { # a dynamic path is added semi-declaratively inside on_draw block
23
+
24
+ path { # dynamic path, added semi-declaratively inside on_draw block
23
25
  rectangle {
24
26
  x 0
25
27
  y 100
26
28
  width 100
27
29
  height 400
28
30
  }
31
+
29
32
  rectangle {
30
33
  x 100
31
34
  y 0
@@ -36,115 +39,114 @@ window('Area Gallery', 400, 400) {
36
39
  # linear gradient (has x0, y0, x1, y1, and stops)
37
40
  fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
38
41
  }
39
- path { # a dynamic path is added semi-declaratively inside on_draw block
40
- figure {
42
+
43
+ figure { # dynamic path, added semi-declaratively inside on_draw block
44
+ x 100
45
+ y 100
46
+
47
+ line {
41
48
  x 100
49
+ y 400
50
+ }
51
+
52
+ line {
53
+ x 400
42
54
  y 100
43
-
44
- line {
45
- x 100
46
- y 400
47
- }
48
- line {
49
- x 400
50
- y 100
51
- }
52
- line {
53
- x 400
54
- y 400
55
- }
56
-
57
- closed true
55
+ }
56
+
57
+ line {
58
+ x 400
59
+ y 400
58
60
  }
59
61
 
62
+ closed true # polygon figure is closed (last point forms a line with first point)
60
63
  fill r: 202, g: 102, b: 104, a: 0.5
61
64
  stroke r: 0, g: 0, b: 0
62
65
  }
63
- path { # a dynamic path is added semi-declaratively inside on_draw block
64
- figure {
65
- x 0
66
- y 0
67
-
68
- bezier {
69
- c1_x 200
70
- c1_y 100
71
- c2_x 100
72
- c2_y 200
73
- end_x 400
74
- end_y 100
75
- }
76
- bezier {
77
- c1_x 300
78
- c1_y 100
79
- c2_x 100
80
- c2_y 300
81
- end_x 100
82
- end_y 400
83
- }
84
- bezier {
85
- c1_x 100
86
- c1_y 300
87
- c2_x 300
88
- c2_y 100
89
- end_x 400
90
- end_y 400
91
- }
66
+
67
+ figure { # dynamic path, added semi-declaratively inside on_draw block
68
+ x 0
69
+ y 0
70
+
71
+ bezier {
72
+ c1_x 200
73
+ c1_y 100
74
+ c2_x 100
75
+ c2_y 200
76
+ end_x 400
77
+ end_y 100
92
78
  }
93
-
79
+
80
+ bezier {
81
+ c1_x 300
82
+ c1_y 100
83
+ c2_x 100
84
+ c2_y 300
85
+ end_x 100
86
+ end_y 400
87
+ }
88
+
89
+ bezier {
90
+ c1_x 100
91
+ c1_y 300
92
+ c2_x 300
93
+ c2_y 100
94
+ end_x 400
95
+ end_y 400
96
+ }
97
+
94
98
  fill r: 202, g: 102, b: 204, a: 0.5
95
99
  stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
96
100
  }
97
- path { # a dynamic path is added semi-declaratively inside on_draw block
98
- polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
99
- figure {
100
- x 100
101
+
102
+ figure { # dynamic path, added semi-declaratively inside on_draw block
103
+ x 100
104
+ y 100
105
+
106
+ line {
107
+ x 400
101
108
  y 100
102
-
103
- line {
104
- x 400
105
- y 100
106
- }
107
- line {
108
- x 100
109
- y 400
110
- }
111
- line {
112
- x 400
113
- y 400
114
- }
115
- line {
116
- x 0
117
- y 0
118
- }
119
109
  }
120
-
110
+
111
+ line {
112
+ x 100
113
+ y 400
114
+ }
115
+
116
+ line {
117
+ x 400
118
+ y 400
119
+ }
120
+
121
+ line {
122
+ x 0
123
+ y 0
124
+ }
125
+
121
126
  stroke r: 0, g: 0, b: 0, thickness: 2
122
127
  }
123
- path { # a dynamic path is added semi-declaratively inside on_draw block
124
- arc {
125
- x_center 404
126
- y_center 216
127
- radius 190
128
- start_angle 90
129
- sweep 90
130
- is_negative false
131
- }
132
-
128
+
129
+ arc { # dynamic path, added semi-declaratively inside on_draw block
130
+ x_center 404
131
+ y_center 216
132
+ radius 190
133
+ start_angle 90
134
+ sweep 90
135
+ is_negative false
133
136
  # radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
134
137
  fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
135
138
  stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
136
139
  }
137
- path { # a dynamic path is added semi-declaratively inside on_draw block
138
- circle {
139
- x_center 200
140
- y_center 200
141
- radius 90
142
- }
143
-
140
+
141
+ circle { # dynamic path, added semi-declaratively inside on_draw block
142
+ x_center 200
143
+ y_center 200
144
+ radius 90
144
145
  fill r: 202, g: 102, b: 204, a: 0.5
145
146
  stroke r: 0, g: 0, b: 0, thickness: 2
146
147
  }
147
- text {
148
+
149
+ text { # dynamic path, added semi-declaratively inside on_draw block
148
150
  x 161
149
151
  y 40
150
152
  width 100
@@ -4,17 +4,14 @@ include Glimmer
4
4
 
5
5
  window('Basic Transform', 350, 350) {
6
6
  area {
7
- path {
8
- square(0, 0, 350)
9
-
7
+ square(0, 0, 350) {
10
8
  fill r: 255, g: 255, b: 0
11
9
  }
12
10
  40.times do |n|
13
- path {
14
- square(0, 0, 100)
15
-
11
+ square(0, 0, 100) {
16
12
  fill r: [255 - n*5, 0].max, g: [n*5, 255].min, b: 0, a: 0.5
17
13
  stroke :black, thickness: 2
14
+
18
15
  transform {
19
16
  unless OS.windows?
20
17
  skew 0.15, 0.15
@@ -0,0 +1,34 @@
1
+ require 'glimmer-dsl-libui'
2
+
3
+ include Glimmer
4
+
5
+ window('Basic Transform', 350, 350) {
6
+ area {
7
+ path {
8
+ square(0, 0, 350)
9
+
10
+ fill r: 255, g: 255, b: 0
11
+ }
12
+ 40.times do |n|
13
+ path {
14
+ square(0, 0, 100)
15
+
16
+ fill r: [255 - n*5, 0].max, g: [n*5, 255].min, b: 0, a: 0.5
17
+ stroke :black, thickness: 2
18
+
19
+ transform {
20
+ unless OS.windows?
21
+ skew 0.15, 0.15
22
+ translate 50, 50
23
+ end
24
+ rotate 100, 100, -9 * n
25
+ scale 1.1, 1.1
26
+ if OS.windows?
27
+ skew 0.15, 0.15
28
+ translate 50, 50
29
+ end
30
+ }
31
+ }
32
+ end
33
+ }
34
+ }.show
@@ -201,9 +201,7 @@ class ColorTheCircles
201
201
  }
202
202
 
203
203
  @circles_data.each do |circle_data|
204
- path {
205
- circle_data[:circle] = circle(*circle_data[:args])
206
-
204
+ circle_data[:circle] = circle(*circle_data[:args]) {
207
205
  fill circle_data[:fill]
208
206
  stroke circle_data[:stroke]
209
207
  }
@@ -88,9 +88,7 @@ window('Dynamic Area', 240, 600) {
88
88
 
89
89
  @area = area {
90
90
  on_draw do |area_draw_params|
91
- path { # a dynamic path is added semi-declaratively inside on_draw block
92
- rectangle(@x_spinbox.value, @y_spinbox.value, @width_spinbox.value, @height_spinbox.value)
93
-
91
+ rectangle(@x_spinbox.value, @y_spinbox.value, @width_spinbox.value, @height_spinbox.value) { # a dynamic path is added semi-declaratively inside on_draw block
94
92
  fill r: @red_spinbox.value, g: @green_spinbox.value, b: @blue_spinbox.value, a: @alpha_spinbox.value / 100.0
95
93
  }
96
94
  end