Ruiby 3.23.0 → 3.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.txt +11 -11
- data/README.md +28 -15
- data/VERSION +1 -1
- data/coverage/index.html +1 -1
- data/doc.html +4 -4
- data/lib/ruiby_gtk/dsl/canvas.rb +75 -20
- data/lib/ruiby_gtk/dsl/list_grid.rb +1 -0
- data/lib/ruiby_gtk/dsl/plot.rb +1 -1
- data/lib/ruiby_gtk/ruiby_dsl.rb +4 -1
- data/lib/ruiby_gtk/ruiby_dsl3.rb +2 -2
- data/samples/circle.rb +4 -2
- data/samples/gradients.rb +24 -0
- data/samples/quadvideo.rb +3 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fd700885087f60ca85e4180dd50212ba8201983
|
4
|
+
data.tar.gz: 5c8be8fb45db8a39983dfd45f2cf38dcad75d5cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72bbaba901ea7dd7b2c92a8c858d0acb87767a5ba2ac10df72dd8f51fabf6d188ef5729f19e55c365c31f707e7dcb60182e27b271b1c527b7d30976e64777daf
|
7
|
+
data.tar.gz: e398906d054b4dd1057e948f68f838329dc412942180542360c26e8e13c0a39aa19a0fd9b25768064129d3e6d5ebb0793896d2821317e8edf02a2c77f3184605
|
data/CHANGELOG.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
3.24.0 : 2017-11-28 19:12:41 +0100
|
2
|
+
quadvideo.rb : q
|
3
|
+
circle.rb : bg with gradient
|
4
|
+
ruiby_dsl3.rb : error() with exception for video()
|
5
|
+
plot.rb : correction color
|
6
|
+
list_grid.rb : no unselect on set_data
|
7
|
+
canvas.rb : gradiant for draw_rectangle, draw_rounded_rectangle, drw_polygon
|
8
|
+
README.md : gradient evolution, ruby-gnome2 references
|
9
|
+
README.md : updates
|
10
|
+
README.md : update dependencies
|
1
11
|
3.23.0 : 2017-09-25 17:43:54 +0200
|
2
12
|
README.md : 3.23
|
3
13
|
ruiby_default_dialog3.rb : dialog synced
|
@@ -488,14 +498,4 @@
|
|
488
498
|
ruiby_dsl3.rb : api n combo box
|
489
499
|
gol.rb : speedy
|
490
500
|
ruiby_threader.rb : anim
|
491
|
-
gol.rb : entry for modify life formula online
|
492
|
-
canvas.rb : animation, polygons, scale, rotation, translation
|
493
|
-
test_basics_widget.rb : video test only if gstereamer is loaded
|
494
|
-
Gemfile : no gst
|
495
|
-
0.128.0 : 2013-09-24 00:47:41 +0200
|
496
|
-
test_basics_widget.rb : video test
|
497
|
-
0.127.0 : 2013-09-24 00:18:05 +0200
|
498
|
-
ruiby_dsl3.rb : uri
|
499
|
-
0.126.0 : 2013-09-24 00:14:00 +0200
|
500
|
-
ruiby_dsl3.rb : uri / url
|
501
|
-
0.125.0 : 2013-09-23 22:01:28 +0200
|
501
|
+
gol.rb : entry for modify life formula online
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Ruiby
|
2
2
|
|
3
|
+
![icon](https://user-images.githubusercontent.com/27629/31522353-9bbe8958-afad-11e7-8e50-56ec8f904a79.png)
|
4
|
+
|
3
5
|
[![Build Status](https://travis-ci.org/glurp/dsl-gtk.svg?branch=master)](https://travis-ci.org/glurp/dsl-gtk)
|
4
6
|
[![Gem Version](https://badge.fury.io/rb/Ruiby.png)](http://badge.fury.io/rb/Ruiby)
|
5
7
|
[![AppVeyor](https://ci.appveyor.com/api/projects/status/y6pqyq79ybcmj9ye?svg=true)](https://ci.appveyor.com/project/Glurp/dsl-gtk/branch/master)
|
@@ -18,16 +20,21 @@ Doc: [Reference+Exemples.](https://rawgithub.com/glurp/Ruiby/master/doc.html)
|
|
18
20
|
|
19
21
|
Gem : https://rubygems.org/gems/Ruiby
|
20
22
|
|
23
|
+
Based on Ruby-Gmome2 :
|
24
|
+
* [Sources, Issues](https://github.com/ruby-gnome2/ruby-gnome2)
|
25
|
+
* [API](http://ruby-gnome2.osdn.jp/)
|
26
|
+
|
21
27
|
|
22
28
|
Status
|
23
29
|
======
|
24
30
|
|
25
|
-
NEW : 3.
|
31
|
+
NEW : 3.24.0 !! 28-11-2017 : Gradiant on canvas draw primitives
|
26
32
|
|
27
33
|
|
28
34
|
|
29
35
|
TODO :
|
30
36
|
|
37
|
+
* [ ] improve graphics quality on canvas : gradiant,transparency...
|
31
38
|
* [ ] Gadget api: actual gadgets are cairo drawing => to be encapsuled
|
32
39
|
* [ ] refactor samples demos with last improve: dynvar/autoslot...
|
33
40
|
* [ ] resolve 100% gtk3 deprecated warning
|
@@ -58,21 +65,24 @@ Test it:
|
|
58
65
|
```
|
59
66
|
|
60
67
|
|
61
|
-
Here a working gem config on windows (
|
68
|
+
Here a working gem config on windows (25-Sept-2019, Ruby 2.3.3p222) :
|
62
69
|
```
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
cairo-gobject-3.
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
did_you_mean-1.0.0
|
71
|
+
pkg-config-1.2.3
|
72
|
+
native-package-installer-1.0.4
|
73
|
+
cairo-1.15.9
|
74
|
+
glib2-3.1.8
|
75
|
+
gobject-introspection-3.1.8
|
76
|
+
gio2-3.1.8
|
77
|
+
atk-3.1.8
|
78
|
+
cairo-gobject-3.1.8
|
79
|
+
pango-3.1.8
|
80
|
+
gdk_pixbuf2-3.1.8
|
81
|
+
gdk3-3.1.8
|
82
|
+
rsvg2-3.1.8
|
83
|
+
gtk3-3.1.8
|
84
|
+
Ruiby-3.23.0
|
85
|
+
gtksourceview3-3.1.8
|
76
86
|
```
|
77
87
|
|
78
88
|
|
@@ -374,8 +384,11 @@ TODO:
|
|
374
384
|
License
|
375
385
|
=======
|
376
386
|
Ruiby : LGPL, CC BY-SA
|
387
|
+
|
377
388
|
fafamfam rasters images : CC Attribution 4.0 http://www.famfamfam.com/
|
389
|
+
|
378
390
|
Crystal Clear icon set : LGPL
|
391
|
+
|
379
392
|
Farm Fresh icon set : CC Attribution 3.0 License http://www.fatcow.com/free-icons
|
380
393
|
|
381
394
|
Exemples
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.24.0
|
data/coverage/index.html
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
<img src="./assets/0.10.0/loading.gif" alt="loading"/>
|
15
15
|
</div>
|
16
16
|
<div id="wrapper" style="display:none;">
|
17
|
-
<div class="timestamp">Generated <abbr class="timeago" title="2017-
|
17
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2017-09-25T17:44:43+02:00">2017-09-25T17:44:43+02:00</abbr></div>
|
18
18
|
<ul class="group_tabs"></ul>
|
19
19
|
|
20
20
|
<div id="content">
|
data/doc.html
CHANGED
@@ -72,7 +72,7 @@ hdoc['prompt']= '<div class="api"><br>def prompt(txt,value="")</div><div>show a
|
|
72
72
|
hdoc['ask']= '<div class="api"><br>def ask(*txt)</div><div>show a modal <a href=#dialog>dialog</a>, asking yes/no question, return boolean response<br></div>';
|
73
73
|
hdoc['log']= '<div class="api"><br>def log(*txt)</div><div> Logs<br>put a line of <a href=#message>message</a> <a href=#text>text</a> in log <a href=#dialog>dialog</a> (create and show the log <a href=#dialog>dialog</a> if not exist)<br></div>';
|
74
74
|
hdoc['install_composant']= '<div class="api"><br>def install_composant(window,componant)</div><div>helper for <a href=#install>install</a> a <a href=#component>component</a>.<br>when use a <a href=#component>component</a>, define in Ruiby_dsl word:<br>def component_name(*args)<br>c=install_composant(<a href=#self>self</a>,ClassCompenent.new(*args))<br>end<br>ClassCompenent must inherit from AbstractComposant and define <br><a href=#component>component</a> method (as a <a href=#window>window</a>)<br>class XX < AbstractComposant<br>def <a href=#component>component</a><br><a href=#stack>stack</a> { .... }<br>end<br>end<br></div>';
|
75
|
-
hdoc['canvas']= '<div class="api"><br>def canvas(width,height,option={})</div><div>Creative Commons BY-SA : Regis dAubarede <regis.aubarede@gmail.com><br>LGPL<br>Create a drawing area, for pixel/vectoriel draw<br>for interactive actions see test.rb fo little example.<br><br>@<a href=#cv>cv</a>=canvas(width,height,opt) do<br><a href=#on_canvas_draw>on_canvas_draw</a> { |<a href=#w>w</a>,ctx| myDraw(<a href=#w>w</a>,ctx) }<br><a href=#on_canvas_button_press>on_canvas_button_press</a> {|<a href=#w>w</a>,e| [e.x,e.y] } must return a object which will given to next move/release callback<br><a href=#on_canvas_button_motion>on_canvas_button_motion</a> {|<a href=#w>w</a>,e,o| n=[e.x,e.y] ; ... ; n }<br><a href=#on_canvas_button_release>on_canvas_button_release</a> {|<a href=#w>w</a>,e,o| ... }<br>on_canvas_keypress {|<a href=#w>w</a>,key| ... }<br>end<br><br>for drawing in canvas, this commands are usable.<br>basic gtk commands can still be uses ( move_to(), line_to()... )<br>def myDraw(<a href=#w>w</a>,ctx)<br><a href=#w>w</a>.init_ctx(color_fg="000000",color_bg="FFFFFF",width=1)<br><a href=#w>w</a>.draw_point(x1,y1,color,width)<br><a href=#w>w</a>.draw_polygon([x,y,...],colorFill,colorStroke,widthStroke)<br><a href=#w>w</a>.draw_circle(cx,cy,rayon,colorFill,colorStroke,widthStroke)<br><a href=#w>w</a>.draw_rectangle(x0,y0,<a href=#w>w</a>,h,r,widthStroke,colorFill
|
75
|
+
hdoc['canvas']= '<div class="api"><br>def canvas(width,height,option={})</div><div>Creative Commons BY-SA : Regis dAubarede <regis.aubarede@gmail.com><br>LGPL<br>Create a drawing area, for pixel/vectoriel draw<br>for interactive actions see test.rb fo little example.<br><br>@<a href=#cv>cv</a>=canvas(width,height,opt) do<br><a href=#on_canvas_draw>on_canvas_draw</a> { |<a href=#w>w</a>,ctx| myDraw(<a href=#w>w</a>,ctx) }<br><a href=#on_canvas_button_press>on_canvas_button_press</a> {|<a href=#w>w</a>,e| [e.x,e.y] } must return a object which will given to next move/release callback<br><a href=#on_canvas_button_motion>on_canvas_button_motion</a> {|<a href=#w>w</a>,e,o| n=[e.x,e.y] ; ... ; n }<br><a href=#on_canvas_button_release>on_canvas_button_release</a> {|<a href=#w>w</a>,e,o| ... }<br>on_canvas_keypress {|<a href=#w>w</a>,key| ... }<br>end<br><br>for drawing in canvas, this commands are usable.<br>basic gtk commands can still be uses ( move_to(), line_to()... )<br>def myDraw(<a href=#w>w</a>,ctx)<br><a href=#w>w</a>.init_ctx(color_fg="000000",color_bg="FFFFFF",width=1)<br><a href=#w>w</a>.draw_point(x1,y1,color,width)<br><a href=#w>w</a>.draw_polygon([x,y,...],colorFill,colorStroke,widthStroke)<br><a href=#w>w</a>.draw_circle(cx,cy,rayon,colorFill,colorStroke,widthStroke)<br><a href=#w>w</a>.draw_rectangle(x0,y0,<a href=#w>w</a>,h, r,widthStroke,colorFill,<a href=#w>w</a>)<br><a href=#cv>cv</a>.draw_rounded_rectangle(x0,y0,<a href=#w>w</a>,h,ar,colorStroke,colorFill,widthStroke)<br><a href=#w>w</a>.draw_pie(x,y,r,l_ratio_color_label)<br><a href=#w>w</a>.draw_arc(x,y,r,start,eend,width,color_stroke,color_fill=nil) camenber<br><a href=#w>w</a>.draw_arc2(x,y,r,start,eend,width,color_stroke,color_fill=nil) circle fraction<br><a href=#w>w</a>.draw_varbarr(x0,y0,x1,y1,vmin,vmax,l_date_value,width) {|<a href=#value>value</a>| color}<br><a href=#w>w</a>.draw_image(x,y,filename,sx,sy)<br><a href=#cv>cv</a>.ctx_font(<a href=#name>name</a>,size) choose font <a href=#name>name</a> and size for next draw_text...<br><a href=#w>w</a>.draw_text(x,y,<a href=#text>text</a>,scale,color,bgcolor=nil)<br><a href=#w>w</a>.draw_text_left(x,y,<a href=#text>text</a>,scale,color,bgcolor=nil)<br><a href=#w>w</a>.draw_text_center(x,y,<a href=#text>text</a>,scale,color,bgcolor=nil)<br>lxy=<a href=#w>w</a>.translate(lxy,dx=0,dy=0) move a <a href=#list>list</a> of points<br>lxy=<a href=#w>w</a>.rotate(lxy,x0,y0,angle) rotate a <a href=#list>list</a> of points<br><a href=#cv>cv</a>.rotation(cx,cy,a) { draw... }<br><a href=#w>w</a>.scale(10,20,2) { <a href=#w>w</a>.draw_image(3,0,filename) } <br>>> draw in a transladed/scaled coord system<br>>> <a href=#image>image</a> will be draw at 16/20 (10+3*2)/(20+0*2)<br>, and size doubled<br><br>end<br>gradient can be use for recangle and polygone, see samples/gradients.rb<br>in place od String bg-color, say Array : <a href=#w>w</a>{type direction color1 color2 ...}<br>type = linear/radial direction : tb Top->Bottom, bu Bottom->Up , lr: Left->Right, ..., trb -> TopLeft -> BottomRight <br></div>';
|
76
76
|
hdoc['cv']= '<div class="api"><br>def cv.rotate(lxy,x0,y0,angle)</div><div></div>';
|
77
77
|
hdoc['force_update']= '<div class="api"><br>def force_update(canvas)</div><div><a href=#update>update</a> a <a href=#canvas>canvas</a><br></div>';
|
78
78
|
hdoc['on_canvas_button_press']= '<div class="api"><br>def on_canvas_button_press(&blk)</div><div>define action on button_press<br>action must return an object whici will be transmit to motion/release handler<br></div>';
|
@@ -322,8 +322,8 @@ function popup(word) {
|
|
322
322
|
</head>
|
323
323
|
<body>
|
324
324
|
<div class='title'>Ruiby DSL Documentation</div>
|
325
|
-
Ruiby Version: 3.
|
326
|
-
Generated at : 2017-
|
325
|
+
Ruiby Version: 3.23.3<br>
|
326
|
+
Generated at : 2017-11-28 19:12:38 +0100<br>
|
327
327
|
<a href="#code">See code example</a>
|
328
328
|
<hr>
|
329
329
|
<center>Search : <input type='input' value="" size='80' onchange='doSearch(this.value);'></center>
|
@@ -466,7 +466,7 @@ Generated at : 2017-09-25 17:43:53 +0200<br>
|
|
466
466
|
|
467
467
|
<div class='atitle'><a name='canvas'>canvas</a></div>
|
468
468
|
<div class='api'>def canvas(width,height,option={})</div>
|
469
|
-
<div class='descr'>Creative Commons BY-SA : Regis d'Aubarede <regis.aubarede@gmail.com><br>LGPL<br>Create a drawing area, for pixel/vectoriel draw<br>for interactive actions see test.rb fo little example.<br><br>@<a href='#cv'>cv</a>=canvas(width,height,opt) do<br><a href='#on_canvas_draw'>on_canvas_draw</a> { |<a href='#w'>w</a>,ctx| myDraw(<a href='#w'>w</a>,ctx) }<br><a href='#on_canvas_button_press'>on_canvas_button_press</a> {|<a href='#w'>w</a>,e| [e.x,e.y] } must return a object which will given to next move/release callback<br><a href='#on_canvas_button_motion'>on_canvas_button_motion</a> {|<a href='#w'>w</a>,e,o| n=[e.x,e.y] ; ... ; n }<br><a href='#on_canvas_button_release'>on_canvas_button_release</a> {|<a href='#w'>w</a>,e,o| ... }<br>on_canvas_keypress {|<a href='#w'>w</a>,key| ... }<br>end<br><br>for drawing in canvas, this commands are usable.<br>basic gtk commands can still be uses ( move_to(), line_to()... )<br>def myDraw(<a href='#w'>w</a>,ctx)<br><a href='#w'>w</a>.init_ctx(color_fg="000000",color_bg="FFFFFF",width=1)<br><a href='#w'>w</a>.draw_point(x1,y1,color,width)<br><a href='#w'>w</a>.draw_polygon([x,y,...],colorFill,colorStroke,widthStroke)<br><a href='#w'>w</a>.draw_circle(cx,cy,rayon,colorFill,colorStroke,widthStroke)<br><a href='#w'>w</a>.draw_rectangle(x0,y0,<a href='#w'>w</a>,h,r,widthStroke,colorFill
|
469
|
+
<div class='descr'>Creative Commons BY-SA : Regis d'Aubarede <regis.aubarede@gmail.com><br>LGPL<br>Create a drawing area, for pixel/vectoriel draw<br>for interactive actions see test.rb fo little example.<br><br>@<a href='#cv'>cv</a>=canvas(width,height,opt) do<br><a href='#on_canvas_draw'>on_canvas_draw</a> { |<a href='#w'>w</a>,ctx| myDraw(<a href='#w'>w</a>,ctx) }<br><a href='#on_canvas_button_press'>on_canvas_button_press</a> {|<a href='#w'>w</a>,e| [e.x,e.y] } must return a object which will given to next move/release callback<br><a href='#on_canvas_button_motion'>on_canvas_button_motion</a> {|<a href='#w'>w</a>,e,o| n=[e.x,e.y] ; ... ; n }<br><a href='#on_canvas_button_release'>on_canvas_button_release</a> {|<a href='#w'>w</a>,e,o| ... }<br>on_canvas_keypress {|<a href='#w'>w</a>,key| ... }<br>end<br><br>for drawing in canvas, this commands are usable.<br>basic gtk commands can still be uses ( move_to(), line_to()... )<br>def myDraw(<a href='#w'>w</a>,ctx)<br><a href='#w'>w</a>.init_ctx(color_fg="000000",color_bg="FFFFFF",width=1)<br><a href='#w'>w</a>.draw_point(x1,y1,color,width)<br><a href='#w'>w</a>.draw_polygon([x,y,...],colorFill,colorStroke,widthStroke)<br><a href='#w'>w</a>.draw_circle(cx,cy,rayon,colorFill,colorStroke,widthStroke)<br><a href='#w'>w</a>.draw_rectangle(x0,y0,<a href='#w'>w</a>,h, r,widthStroke,colorFill,<a href='#w'>w</a>)<br><a href='#cv'>cv</a>.draw_rounded_rectangle(x0,y0,<a href='#w'>w</a>,h,ar,colorStroke,colorFill,widthStroke)<br><a href='#w'>w</a>.draw_pie(x,y,r,l_ratio_color_label)<br><a href='#w'>w</a>.draw_arc(x,y,r,start,eend,width,color_stroke,color_fill=nil) camenber<br><a href='#w'>w</a>.draw_arc2(x,y,r,start,eend,width,color_stroke,color_fill=nil) circle fraction<br><a href='#w'>w</a>.draw_varbarr(x0,y0,x1,y1,vmin,vmax,l_date_value,width) {|<a href='#value'>value</a>| color}<br><a href='#w'>w</a>.draw_image(x,y,filename,sx,sy)<br><a href='#cv'>cv</a>.ctx_font(<a href='#name'>name</a>,size) choose font <a href='#name'>name</a> and size for next draw_text...<br><a href='#w'>w</a>.draw_text(x,y,<a href='#text'>text</a>,scale,color,bgcolor=nil)<br><a href='#w'>w</a>.draw_text_left(x,y,<a href='#text'>text</a>,scale,color,bgcolor=nil)<br><a href='#w'>w</a>.draw_text_center(x,y,<a href='#text'>text</a>,scale,color,bgcolor=nil)<br>lxy=<a href='#w'>w</a>.translate(lxy,dx=0,dy=0) move a <a href='#list'>list</a> of points<br>lxy=<a href='#w'>w</a>.rotate(lxy,x0,y0,angle) rotate a <a href='#list'>list</a> of points<br><a href='#cv'>cv</a>.rotation(cx,cy,a) { draw... }<br><a href='#w'>w</a>.scale(10,20,2) { <a href='#w'>w</a>.draw_image(3,0,filename) } <br>>> draw in a transladed/scaled coord system<br>>> <a href='#image'>image</a> will be draw at 16/20 (10+3*2)/(20+0*2)<br>, and size doubled<br><br>end<br>gradient can be use for recangle and polygone, see samples/gradients.rb<br>in place od String bg-color, say Array : <a href='#w'>w</a>{type direction color1 color2 ...}<br>type = linear/radial direction : tb Top->Bottom, bu Bottom->Up , lr: Left->Right, ..., trb -> TopLeft -> BottomRight <br> <a href='#ex_canvas'>ex</a></div>
|
470
470
|
|
471
471
|
<div class='atitle'><a name='canvasOld'>canvasOld</a></div>
|
472
472
|
<div class='api'>def canvasOld(width,height,option={})</div>
|
data/lib/ruiby_gtk/dsl/canvas.rb
CHANGED
@@ -21,13 +21,14 @@ module Ruiby_dsl
|
|
21
21
|
# w.draw_point(x1,y1,color,width)
|
22
22
|
# w.draw_polygon([x,y,...],colorFill,colorStroke,widthStroke)
|
23
23
|
# w.draw_circle(cx,cy,rayon,colorFill,colorStroke,widthStroke)
|
24
|
-
# w.draw_rectangle(x0,y0,w,h,r,widthStroke,colorFill,
|
24
|
+
# w.draw_rectangle(x0,y0,w,h, r,widthStroke,colorFill,w)
|
25
25
|
# cv.draw_rounded_rectangle(x0,y0,w,h,ar,colorStroke,colorFill,widthStroke)
|
26
26
|
# w.draw_pie(x,y,r,l_ratio_color_label)
|
27
|
-
# w.draw_arc(x,y,r,start,eend,width,color_stroke,color_fill=nil)
|
28
|
-
# w.draw_arc2(x,y,r,start,eend,width,color_stroke,color_fill=nil)
|
27
|
+
# w.draw_arc(x,y,r,start,eend,width,color_stroke,color_fill=nil) # camenber
|
28
|
+
# w.draw_arc2(x,y,r,start,eend,width,color_stroke,color_fill=nil) # circle fraction
|
29
29
|
# w.draw_varbarr(x0,y0,x1,y1,vmin,vmax,l_date_value,width) {|value| color}
|
30
30
|
# w.draw_image(x,y,filename,sx,sy)
|
31
|
+
# cv.ctx_font(name,size) # choose font name and size for next draw_text...
|
31
32
|
# w.draw_text(x,y,text,scale,color,bgcolor=nil)
|
32
33
|
# w.draw_text_left(x,y,text,scale,color,bgcolor=nil)
|
33
34
|
# w.draw_text_center(x,y,text,scale,color,bgcolor=nil)
|
@@ -38,7 +39,11 @@ module Ruiby_dsl
|
|
38
39
|
# >> draw in a transladed/scaled coord system
|
39
40
|
# >> image will be draw at 16/20 (10+3*2)/(20+0*2)
|
40
41
|
# , and size doubled
|
42
|
+
#
|
41
43
|
# end
|
44
|
+
# gradient can be use for recangle and polygone, see samples/gradients.rb
|
45
|
+
# in place od String bg-color, say Array : #w{type direction color1 color2 ...}
|
46
|
+
# type = linear/radial direction : tb Top->Bottom, bu Bottom->Up , lr: Left->Right, ..., trb -> TopLeft -> BottomRight
|
42
47
|
|
43
48
|
def canvas(width,height,option={})
|
44
49
|
autoslot()
|
@@ -92,15 +97,58 @@ module Ruiby_dsl
|
|
92
97
|
colorStroke=@currentColorFg if colorFill.nil? && colorStroke.nil?
|
93
98
|
_draw_poly(lxy,colorStroke,colorFill,widthStroke)
|
94
99
|
end
|
100
|
+
def cv._set_gradient(cv,cr,acolor,lxy)
|
101
|
+
type,sens,*data=acolor
|
102
|
+
return unless type && sens && data && data.size>=2
|
103
|
+
cr.set_source_rgba(*Ruiby_dsl.cv_color_html("#FFF"))
|
104
|
+
if type =~ /^g/
|
105
|
+
x0,y0,x1,y1=*bbox(lxy)
|
106
|
+
case sens
|
107
|
+
when "tb" then x0,y0,x1,y1 = x1/2,y0, x1/2,y1
|
108
|
+
when "bu" then x1,y1,x0,y0 = x1/2,y0, x1/2,y1
|
109
|
+
when "lr" then x0,y0,x1,y1 = 0,y1/2, x1,y1/2
|
110
|
+
when "rl" then x0,y0,x1,y1 = x1,y1/2, x0,y1/2
|
111
|
+
when "trb" then x0,y0,x1,y1 = x0,y0, x1,y1
|
112
|
+
when "tlb" then x0,y0,x1,y1 = x1,y0, x0,y1
|
113
|
+
else
|
114
|
+
error("unknown gradient : #{sens}")
|
115
|
+
end
|
116
|
+
#p [sens,x0,y0,x1,y1]
|
117
|
+
pattern = Cairo::LinearPattern.new(x0,y0,x1,y1)
|
118
|
+
last_color="#000"
|
119
|
+
data.each_with_index {|color,i|
|
120
|
+
pos= 1.0*i/(data.length-1)
|
121
|
+
#p [pos,Ruiby_dsl.cv_color_html(color)]
|
122
|
+
color=last_color if color=="-"
|
123
|
+
last_color=color
|
124
|
+
pattern.add_color_stop(pos, *(Ruiby_dsl.cv_color_html(color)[0..2]))
|
125
|
+
}
|
126
|
+
cr.set_source(pattern)
|
127
|
+
else
|
128
|
+
end
|
129
|
+
end
|
130
|
+
def cv.bbox(lxy)
|
131
|
+
xmin,ymin=lxy[0..1]
|
132
|
+
xmax,ymax=lxy[0..1]
|
133
|
+
lxy.each_slice(2) {|x,y|
|
134
|
+
xmin=x if x<xmin ;ymin=y if y<ymin
|
135
|
+
xmax=x if x>xmax ;ymax=y if y>ymax
|
136
|
+
}
|
137
|
+
[xmin,ymin,xmax,ymax]
|
138
|
+
end
|
95
139
|
def cv._draw_poly(lxy,color_fg,color_bg,width)
|
96
140
|
raise("odd number of coord for lxy") if !lxy || lxy.size==0 || lxy.size%2==1
|
97
141
|
w,cr=@currentCanvasCtx
|
98
142
|
cr.set_line_width(width) if width
|
99
143
|
x0,y0,*poly=*lxy
|
100
144
|
if color_bg
|
101
|
-
cr.set_source_rgba(*Ruiby_dsl.cv_color_html(color_bg))
|
102
145
|
cr.move_to(x0,y0)
|
103
146
|
poly.each_slice(2) {|x,y| cr.line_to(x,y) }
|
147
|
+
if Array === color_bg
|
148
|
+
_set_gradient(w,cr,color_bg,lxy)
|
149
|
+
else
|
150
|
+
cr.set_source_rgba(*Ruiby_dsl.cv_color_html(color_bg))
|
151
|
+
end
|
104
152
|
cr.fill
|
105
153
|
end
|
106
154
|
if color_fg
|
@@ -115,21 +163,6 @@ module Ruiby_dsl
|
|
115
163
|
width||=@currentWidth
|
116
164
|
draw_line([x,y-width/2.0, x,y+width/2.0],color,width)
|
117
165
|
end
|
118
|
-
def cv.draw_text(x,y,text,scale=1,color=nil,bgcolor=nil)
|
119
|
-
w,cr=@currentCanvasCtx
|
120
|
-
cr.set_line_width(1)
|
121
|
-
cr.set_source_rgba(*Ruiby_dsl.cv_color_html(color || @currentColorFg ))
|
122
|
-
scale(x,y,scale) {
|
123
|
-
if bgcolor
|
124
|
-
a=cr.text_extents(text)
|
125
|
-
w.draw_rectangle(0,-1,a.width,-a.height-3,1,bgcolor,bgcolor,0)
|
126
|
-
cr.set_source_rgba(*Ruiby_dsl.cv_color_html(color || @currentColorFg ))
|
127
|
-
end
|
128
|
-
cr.move_to(0,0)
|
129
|
-
cr.show_text(text)
|
130
|
-
cr.fill
|
131
|
-
}
|
132
|
-
end
|
133
166
|
def cv.draw_varbarr(x0,y0,x1,y1,dmin,dmax,lvalues0,width,&b)
|
134
167
|
ax=1.0*(x1-x0)/(dmax-dmin) ;bx= x0-ax*dmin
|
135
168
|
ay=1.0*(y1-y0)/(dmax-dmin) ;by= y0-ay*dmin
|
@@ -157,6 +190,21 @@ module Ruiby_dsl
|
|
157
190
|
cr.select_font_face(fd.family, Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL)
|
158
191
|
cr.set_font_size(size)
|
159
192
|
end
|
193
|
+
def cv.draw_text(x,y,text,scale=1,color=nil,bgcolor=nil)
|
194
|
+
w,cr=@currentCanvasCtx
|
195
|
+
cr.set_line_width(1)
|
196
|
+
cr.set_source_rgba(*Ruiby_dsl.cv_color_html(color || @currentColorFg ))
|
197
|
+
scale(x,y,scale) {
|
198
|
+
if bgcolor
|
199
|
+
a=cr.text_extents(text)
|
200
|
+
w.draw_rectangle(0,-1,a.width,-a.height-3,1,bgcolor,bgcolor,0)
|
201
|
+
cr.set_source_rgba(*Ruiby_dsl.cv_color_html(color || @currentColorFg ))
|
202
|
+
end
|
203
|
+
cr.move_to(0,0)
|
204
|
+
cr.show_text(text)
|
205
|
+
cr.fill
|
206
|
+
}
|
207
|
+
end
|
160
208
|
|
161
209
|
def cv.draw_text_left(x,y,text,scale=1,color=nil,bgcolor=nil)
|
162
210
|
w,cr=@currentCanvasCtx
|
@@ -198,7 +246,11 @@ module Ruiby_dsl
|
|
198
246
|
cv,cr=@currentCanvasCtx
|
199
247
|
pi=Math::PI
|
200
248
|
ar=[ar,ar,ar,ar] if ar.kind_of?(Numeric)
|
201
|
-
|
249
|
+
if Array === colorFill
|
250
|
+
_set_gradient(w,cr,colorFill,[x0,y0,x0+w,y0+h])
|
251
|
+
else
|
252
|
+
cr.set_source_rgba(*Ruiby_dsl.cv_color_html(colorFill ? colorFill : colorStroke))
|
253
|
+
end
|
202
254
|
cr.set_line_width( widthStroke )
|
203
255
|
r=ar[0]
|
204
256
|
cr.move_to(x0,y0+r)
|
@@ -375,6 +427,7 @@ module Ruiby_dsl
|
|
375
427
|
def on_canvas_draw(&blk)
|
376
428
|
_accept?(:handler)
|
377
429
|
@currentCanvas.signal_connect( 'draw' ) do |w,cr|
|
430
|
+
next if defined?($RUIBY_CANVAS_ERROR) && $RUIBY_CANVAS_ERROR==true
|
378
431
|
cr.set_line_join(Cairo::LINE_JOIN_ROUND)
|
379
432
|
cr.set_line_cap(Cairo::LINE_CAP_ROUND)
|
380
433
|
cr.set_line_width(2)
|
@@ -383,8 +436,10 @@ module Ruiby_dsl
|
|
383
436
|
begin
|
384
437
|
w.instance_eval { @currentCanvasCtx=[w,cr] }
|
385
438
|
blk.call(w,cr)
|
439
|
+
$RUIBY_CANVAS_ERROR=false
|
386
440
|
#w.instance_eval { @currentCanvasCtx=nil }
|
387
441
|
rescue Exception => e
|
442
|
+
$RUIBY_CANVAS_ERROR=true
|
388
443
|
after(1) { error(e) }
|
389
444
|
end
|
390
445
|
end
|
data/lib/ruiby_gtk/dsl/plot.rb
CHANGED
@@ -70,7 +70,7 @@ module Ruiby_dsl
|
|
70
70
|
l=c[:data].each_with_object([]) { |(y,x),a|
|
71
71
|
a << x*c[:xa]+c[:xb] ; a << y*c[:ya]+c[:yb]
|
72
72
|
}
|
73
|
-
if c[:
|
73
|
+
if c[:bgcolor]
|
74
74
|
l1= [0,c[:yb]] + l + [ c[:xminmax].last*c[:xa]+c[:xb] ,c[:yb]]
|
75
75
|
w.draw_polygon(l1,c[:bgcolor],c[:color],2)
|
76
76
|
else
|
data/lib/ruiby_gtk/ruiby_dsl.rb
CHANGED
@@ -1010,10 +1010,13 @@ module Ruiby_dsl
|
|
1010
1010
|
require "gst"
|
1011
1011
|
require "clutter-gtk" # gem install clutter-gtk
|
1012
1012
|
require "clutter-gst" # gem install clutter-gstreamer
|
1013
|
-
|
1013
|
+
p 1
|
1014
1014
|
clutter = ClutterGtk::Embed.new
|
1015
|
+
p 2
|
1015
1016
|
video=ClutterGst::VideoTexture.new
|
1017
|
+
p 3
|
1016
1018
|
clutter.stage.add_child(video)
|
1019
|
+
p 4
|
1017
1020
|
video.width=w
|
1018
1021
|
video.height=h
|
1019
1022
|
video.uri = url if url
|
data/lib/ruiby_gtk/ruiby_dsl3.rb
CHANGED
@@ -459,8 +459,8 @@ module Ruiby_dsl
|
|
459
459
|
require "clutter-gtk" # gem install clutter-gtk
|
460
460
|
require "clutter-gst" # gem install clutter-gstreamer
|
461
461
|
ClutterGst::VideoTexture.new
|
462
|
-
rescue
|
463
|
-
error("Not ready for Clutter/Gstreame...")
|
462
|
+
rescue Exception => e
|
463
|
+
error("Not ready for Clutter/Gstreame...",e)
|
464
464
|
return button("no video")
|
465
465
|
end
|
466
466
|
p 1
|
data/samples/circle.rb
CHANGED
@@ -7,9 +7,10 @@ require_relative '../lib/Ruiby.rb'
|
|
7
7
|
Ruiby.app width: 400, height:200, title: "Drawing Ruiby/canvas test" do
|
8
8
|
pt=[0,0]
|
9
9
|
stack do
|
10
|
+
@lab=labeli("@")
|
10
11
|
canvas(0,0) do
|
11
12
|
on_canvas_draw do |w,ctx|
|
12
|
-
w.draw_rectangle(
|
13
|
+
w.draw_rectangle(0,0,400,200,0,nil,%w{g tb #AAA #555 - - - - - - - #AAA},2)
|
13
14
|
w.draw_rectangle(30,30,70,70,[0,0,20,20],"#F00","#00A",1)
|
14
15
|
w.draw_rectangle(60,110,50,50,[10,10,0,0],"#F00","#A0A",1)
|
15
16
|
w.draw_rectangle(110,15,50,50,[0,10,10,0],"#F00","#AAA",1)
|
@@ -19,7 +20,8 @@ Ruiby.app width: 400, height:200, title: "Drawing Ruiby/canvas test" do
|
|
19
20
|
|
20
21
|
w.draw_rectangle(pt.first-2,pt.last-2,3,3,0,"#000","#000",0) if pt!=[0,0]
|
21
22
|
end
|
22
|
-
on_canvas_button_press {|w,e| pt=[e.x,e.y] }
|
23
|
+
on_canvas_button_press {|w,e| pt=[e.x,e.y] ; @lab.text=pt.to_s ; pt}
|
24
|
+
on_canvas_button_motion {|w,e,o| pt=[e.x,e.y] ; @lab.text=pt.to_s ; pt}
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Creative Commons BY-SA : Regis d'Aubarede <regis.aubarede@gmail.com>
|
3
|
+
# LGPL
|
4
|
+
|
5
|
+
require_relative '../lib/Ruiby.rb'
|
6
|
+
|
7
|
+
Ruiby.app width: 400, height: 300, title: "Drawing Ruiby/canvas test" do
|
8
|
+
pt=[0,0]
|
9
|
+
stack do
|
10
|
+
canvas(0,0) do
|
11
|
+
on_canvas_draw do |w,ctx|
|
12
|
+
w.draw_rectangle(0,0,200-1,100-1,0 ,nil,%w{g tb #F00 #FF0 #00F},2)
|
13
|
+
w.draw_rectangle(200,0,200-1,100-1,0 ,nil,%w{g bu #F00 #FF0 #00F},2)
|
14
|
+
w.draw_rectangle(0,100,200-1,100-1,0 ,nil,%w{g lr #F00 #FF0 #00F},2)
|
15
|
+
w.draw_rectangle(200,100,200,100,0 ,nil,%w{g tlb #F00 #FF0 #00F},2)
|
16
|
+
w.draw_rounded_rectangle(0,200,200,100,30 ,nil,%w{g tb #AAA #AAA #AAA #FFF #AAA #AAA #AAA},2)
|
17
|
+
w.draw_rounded_rectangle(200,200,200,100,30 ,nil,%w{g trb #FFF #AAA #555},2)
|
18
|
+
|
19
|
+
w.draw_rectangle(pt.first-2,pt.last-2,3,3,0,"#000","#000",0) if pt!=[0,0]
|
20
|
+
end
|
21
|
+
on_canvas_button_press {|w,e| pt=[e.x,e.y] }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/samples/quadvideo.rb
CHANGED
@@ -10,6 +10,9 @@
|
|
10
10
|
######################################################################
|
11
11
|
|
12
12
|
require_relative '../lib/Ruiby.rb'
|
13
|
+
require "gst"
|
14
|
+
require "clutter-gtk" # gem install clutter-gtk
|
15
|
+
require "clutter-gst" # gem install clutter-gstreamer
|
13
16
|
|
14
17
|
Gem.loaded_specs.map {|n,g| puts " | %10s %6s " % [g.name,g.version] }
|
15
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Ruiby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Regis d'Aubarede
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gtk3
|
@@ -4741,6 +4741,7 @@ files:
|
|
4741
4741
|
- samples/gadget_trading.rb
|
4742
4742
|
- samples/gol.rb
|
4743
4743
|
- samples/gol2.rb
|
4744
|
+
- samples/gradients.rb
|
4744
4745
|
- samples/hello.rb
|
4745
4746
|
- samples/icones.rb
|
4746
4747
|
- samples/images.rb
|
@@ -4887,6 +4888,7 @@ test_files:
|
|
4887
4888
|
- samples/gadget_trading.rb
|
4888
4889
|
- samples/gol.rb
|
4889
4890
|
- samples/gol2.rb
|
4891
|
+
- samples/gradients.rb
|
4890
4892
|
- samples/hello.rb
|
4891
4893
|
- samples/icones.rb
|
4892
4894
|
- samples/images.rb
|