mirror of
https://github.com/danbulant/node-x11
synced 2026-05-24 12:35:39 +00:00
simple drawing example
This commit is contained in:
parent
4d735645dc
commit
d8764635e7
1 changed files with 23 additions and 0 deletions
23
test/sketch.js
Normal file
23
test/sketch.js
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
var x11 = require('../lib/x11');
|
||||||
|
var Window = require('./wndwrap');
|
||||||
|
|
||||||
|
var width = 700;
|
||||||
|
var height = 500;
|
||||||
|
|
||||||
|
var xclient = x11.createClient(function(display) {
|
||||||
|
|
||||||
|
new Window(xclient, 0, 0, width, height)
|
||||||
|
.handle({
|
||||||
|
mousemove: function(ev) {
|
||||||
|
pts.push(ev.x);
|
||||||
|
pts.push(ev.y);
|
||||||
|
},
|
||||||
|
|
||||||
|
expose: function(ev) {
|
||||||
|
for (var i=0; i < pts.length/2 ; ++i)
|
||||||
|
ev.gc.drawText(pts[i], pts[i+1], 'Hello, NodeJS!');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map()
|
||||||
|
.title = 'Hello, world!';
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue