From 749b877d9901ede5748104deabcd4571e3a7301b Mon Sep 17 00:00:00 2001 From: Michael J M Thomson Date: Fri, 29 May 2015 16:15:03 +1000 Subject: [PATCH] Added Shape rectangles example. Fixed shape mask test --- examples/smoketest/shape-rectangles.js | 9 +++------ examples/smoketest/shapetest.js | 17 +++++++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/examples/smoketest/shape-rectangles.js b/examples/smoketest/shape-rectangles.js index 4fb29a5..38c02d4 100644 --- a/examples/smoketest/shape-rectangles.js +++ b/examples/smoketest/shape-rectangles.js @@ -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], diff --git a/examples/smoketest/shapetest.js b/examples/smoketest/shapetest.js index 1ceba00..7784165 100644 --- a/examples/smoketest/shapetest.js +++ b/examples/smoketest/shapetest.js @@ -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);