mirror of
https://github.com/danbulant/node-x11
synced 2026-06-14 20:21:40 +00:00
Merge branch 'master' of https://github.com/sidorares/node-x11
This commit is contained in:
commit
be8a5c76d5
1 changed files with 41 additions and 9 deletions
50
README.md
50
README.md
|
|
@ -47,20 +47,52 @@ Core requsests usage:
|
|||
});
|
||||
|
||||
|
||||
Simple core requests Window wrapper:
|
||||
'click&draw' demo using simple Window wrapper:
|
||||
|
||||
var x11 = require('x11');
|
||||
var x11 = require('../lib/x11');
|
||||
var Window = require('./wndwrap');
|
||||
var xclient = x11.createClient();
|
||||
xclient.on('connect', function(display) {
|
||||
var mainwnd = new Window(xclient, 0, 0, 100, 100);
|
||||
mainwnd.on('expose', function(ev) {
|
||||
ev.gc.drawText(50, 50, 'Hello, NodeJS!');
|
||||
});
|
||||
mainwnd.map();
|
||||
|
||||
x11.createClient(function(display) {
|
||||
|
||||
var pts = [];
|
||||
new Window(display.client, 0, 0, 700, 500)
|
||||
.handle({
|
||||
|
||||
mousemove: function(ev) {
|
||||
if (this.pressed)
|
||||
{
|
||||
var lastpoly = pts[pts.length - 1];
|
||||
lastpoly.push(ev.x);
|
||||
lastpoly.push(ev.y);
|
||||
if (lastpoly.length > 3)
|
||||
this.gc.polyLine(lastpoly.slice(-4));
|
||||
}
|
||||
},
|
||||
|
||||
mousedown: function(ev) {
|
||||
if (ev.keycode == 1) { // left button
|
||||
this.pressed = true;
|
||||
pts.push([]); // start next polyline
|
||||
}
|
||||
},
|
||||
|
||||
mouseup: function(ev) {
|
||||
if (ev.keycode == 1) // left button
|
||||
this.pressed = false;
|
||||
},
|
||||
|
||||
expose: function(ev) {
|
||||
for (var i=0; i < pts.length ; ++i)
|
||||
this.gc.polyLine(pts[i]);
|
||||
}
|
||||
|
||||
})
|
||||
.map()
|
||||
.title = 'Hello, world!';
|
||||
});
|
||||
|
||||
|
||||
|
||||
# Protocol documentation
|
||||
|
||||
- http://www.x.org/releases/X11R7.6/doc/
|
||||
|
|
|
|||
Loading…
Reference in a new issue