Added Shape rectangles example. Fixed shape mask test

This commit is contained in:
Michael J M Thomson 2015-05-29 16:15:03 +10:00
parent fafa42e6e6
commit 749b877d99
2 changed files with 14 additions and 12 deletions

View file

@ -7,13 +7,10 @@ x11.createClient(function(err, display) {
var root = display.screen[0].root;
X.require('shape', function(err, Shape) {
var win = X.AllocID();
var black = display.screen[0].black_pixel;
X.CreateWindow(win, root, 0, 0, 200, 200, 0, undefined, X.InputOutput, undefined,
{ backgroundPixel: black });
X.CreateWindow(win, root, 0, 0, 200, 200);
X.ChangeWindowAttributes(win, { backgroundPixel: display.screen[0].black_pixel });
X.MapWindow(win);
Shape.Rectangles(Shape.Op.Set, Shape.Kind.Bounding, win,
0, 0, [
Shape.Rectangles(Shape.Op.Set, Shape.Kind.Bounding, win, 0, 0, [
[40, 40, 40, 40], [120, 40, 40, 40],
[0, 120, 20, 20], [180, 120, 20, 20],
[20, 140, 30, 20], [150, 140, 30, 20],

View file

@ -6,17 +6,22 @@ x11.createClient(function(err, display) {
X.require('shape', function(err, Shape) {
var win = X.AllocID();
X.CreateWindow(win, root, 0, 0, 200, 200);
X.ChangeWindowAttributes(win, { backgroundPixel: display.screen[0].white_pixel });
X.MapWindow(win);
Shape.SelectInput(win, 1);
X.ClearArea(win, 0, 0, 200, 200, false);
Shape.SelectInput(win, true);
Shape.InputSelected(win, function(err, isSelected) {
console.log("IsSelected: " + isSelected);
});
var pid = X.AllocID();
X.CreatePixmap(pid, win, 1, 200, 200);
var bitmap = X.AllocID();
X.CreatePixmap(bitmap, win, 1, 200, 200);
var gc = X.AllocID();
X.CreateGC(gc, win);
X.PolyText8(pid, gc, 0, 0, ['Hello, Node.JS!', ' Hello, world!']);
Shape.Mask(Shape.Op.Set, Shape.Kind.Input, win, 0, 0, pid);
X.CreateGC(gc, bitmap, { foreground: 1 });
// X.PolyText8(bitmap, gc, 0, 0, ['Hello, Node.JS!', ' Hello, world!']);
X.PolyFillArc(bitmap, gc, [0, 0, 200, 200, 0, 360 * 64]);
Shape.Mask(Shape.Op.Set, Shape.Kind.Bounding, win, 0, 0, bitmap);
X.on('event', function(ev) {
console.log(ev);