@@ -25,7 +25,7 @@ window.Processing = require('./src/')(Browser);
25
25
},{"./src/":27}],2:[function(require,module,exports){
26
26
module.exports={
27
27
"name": "Processing.js",
28
- "version": "1.4.5 ",
28
+ "version": "1.4.6 ",
29
29
"dependencies": {
30
30
"argv": "~0.0.2",
31
31
"browserify": "~2.18.1",
@@ -7652,6 +7652,8 @@ module.exports = function setupParser(Processing, options) {
7652
7652
var defaultScope = options.defaultScope,
7653
7653
PConstants = defaultScope.PConstants,
7654
7654
aFunctions = options.aFunctions,
7655
+ Browser = options.Browser,
7656
+ document = Browser.document,
7655
7657
undef;
7656
7658
7657
7659
// Processing global methods and constants for the parser
@@ -9378,6 +9380,90 @@ module.exports = function setupParser(Processing, options) {
9378
9380
return sketch;
9379
9381
};
9380
9382
9383
+ // the logger for println()
9384
+ var PjsConsole = function (document) {
9385
+ var e = {}, added = false;
9386
+ e.BufferMax = 200;
9387
+ e.wrapper = document.createElement("div");
9388
+ e.wrapper.setAttribute("style", "opacity:.75;display:block;position:fixed;bottom:0px;left:0px;right:0px;height:50px;background-color:#aaa");
9389
+ e.dragger = document.createElement("div");
9390
+ e.dragger.setAttribute("style", "display:block;border:3px black raised;cursor:n-resize;position:absolute;top:0px;left:0px;right:0px;height:5px;background-color:#333");
9391
+ e.closer = document.createElement("div");
9392
+ e.closer.onmouseover = function () {
9393
+ e.closer.style.setProperty("background-color", "#ccc");
9394
+ };
9395
+ e.closer.onmouseout = function () {
9396
+ e.closer.style.setProperty("background-color", "#ddd");
9397
+ };
9398
+ e.closer.innerHTML = "✖";
9399
+ e.closer.setAttribute("style", "opacity:.5;display:block;border:3px black raised;position:absolute;top:10px;right:30px;height:20px;width:20px;background-color:#ddd;color:#000;line-height:20px;text-align:center;cursor:pointer;");
9400
+ e.javaconsole = document.createElement("div");
9401
+ e.javaconsole.setAttribute("style", "overflow-x: auto;display:block;position:absolute;left:10px;right:0px;bottom:5px;top:10px;overflow-y:scroll;height:40px;");
9402
+ e.wrapper.appendChild(e.dragger);
9403
+ e.wrapper.appendChild(e.javaconsole);
9404
+ e.wrapper.appendChild(e.closer);
9405
+ e.dragger.onmousedown = function (t) {
9406
+ e.divheight = e.wrapper.style.height;
9407
+ if (document.selection) document.selection.empty();
9408
+ else window.getSelection().removeAllRanges();
9409
+ var n = t.screenY;
9410
+ window.onmousemove = function (t) {
9411
+ e.wrapper.style.height = parseFloat(e.divheight) + (n - t.screenY) + "px";
9412
+ e.javaconsole.style.height = parseFloat(e.divheight) + (n - t.screenY) - 10 + "px"
9413
+ };
9414
+ window.onmouseup = function (t) {
9415
+ if (document.selection) document.selection.empty();
9416
+ else window.getSelection().removeAllRanges();
9417
+ e.wrapper.style.height = parseFloat(e.divheight) + (n - t.screenY) + "px";
9418
+ e.javaconsole.style.height = parseFloat(e.divheight) + (n - t.screenY) - 10 + "px";
9419
+ window.onmousemove = null;
9420
+ window.onmouseup = null;
9421
+ };
9422
+ };
9423
+ e.BufferArray = [];
9424
+ e.print = e.log = function (t) {
9425
+ // var oldheight = e.javaconsole.scrollHeight-e.javaconsole.scrollTop;
9426
+ if (e.BufferArray[e.BufferArray.length - 1]) e.BufferArray[e.BufferArray.length - 1] += (t) + "";
9427
+ else e.BufferArray.push(t);
9428
+ e.javaconsole.innerHTML = e.BufferArray.join('');
9429
+ if (e.wrapper.style.visibility === "hidden") {
9430
+ e.wrapper.style.visibility = "visible";
9431
+ }
9432
+ //if (e.BufferArray.length > e.BufferMax) e.BufferArray.splice(0, 1);
9433
+ //else e.javaconsole.scrollTop = oldheight;
9434
+ if (e.wrapper.style.visibility === "hidden") {
9435
+ e.wrapper.style.visibility = "visible"
9436
+ }
9437
+ };
9438
+ e.println = function (t) {
9439
+ if(!added) { document.body.appendChild(e.wrapper); }
9440
+ e.print(t);
9441
+ e.BufferArray.push('<br/>');
9442
+ e.javaconsole.innerHTML = e.BufferArray.join('');
9443
+ if (e.wrapper.style.visibility === "hidden") {
9444
+ e.wrapper.style.visibility = "visible";
9445
+ }
9446
+ if (e.BufferArray.length > e.BufferMax) e.BufferArray.splice(0, 1);
9447
+ else e.javaconsole.scrollTop = e.javaconsole.scrollHeight;
9448
+ if (e.wrapper.style.visibility === "hidden") {
9449
+ e.wrapper.style.visibility = "visible";
9450
+ }
9451
+ };
9452
+ e.showconsole = function () {
9453
+ e.wrapper.style.visibility = "visible";
9454
+ };
9455
+ e.hideconsole = function () {
9456
+ e.wrapper.style.visibility = "hidden";
9457
+ };
9458
+ e.closer.onclick = function () {
9459
+ e.hideconsole();
9460
+ };
9461
+ e.hideconsole();
9462
+ return e;
9463
+ };
9464
+
9465
+ Processing.logger = new PjsConsole(document);
9466
+
9381
9467
// done
9382
9468
return Processing;
9383
9469
};
@@ -13903,18 +13989,7 @@ module.exports = function setupParser(Processing, options) {
13903
13989
* @see #print
13904
13990
*/
13905
13991
p.println = function(message) {
13906
- var bufferLen = logBuffer.length;
13907
- var bufferMsg = "";
13908
- if (bufferLen) {
13909
- bufferMsg = logBuffer.join("");
13910
- logBuffer.length = 0; // clear log buffer
13911
- }
13912
-
13913
- if (arguments.length === 0 && bufferLen === 0) {
13914
- Processing.logger.log(bufferMsg + "");
13915
- } else if (arguments.length !== 0) {
13916
- Processing.logger.log(bufferMsg + message);
13917
- }
13992
+ Processing.logger.println(message);
13918
13993
};
13919
13994
/**
13920
13995
* The print() function writes to the console area of the Processing environment.
@@ -13924,7 +13999,7 @@ module.exports = function setupParser(Processing, options) {
13924
13999
* @see #join
13925
14000
*/
13926
14001
p.print = function(message) {
13927
- logBuffer.push (message);
14002
+ Processing.logger.print (message);
13928
14003
};
13929
14004
13930
14005
// Alphanumeric chars arguments automatically converted to numbers when
@@ -21481,7 +21556,7 @@ module.exports = function buildProcessingJS(Browser, testHarness) {
21481
21556
}),
21482
21557
21483
21558
XMLElement = source.XMLElement({
21484
- Browser:Browser,
21559
+ Browser: Browser,
21485
21560
XMLAttribute: XMLAttribute
21486
21561
}),
21487
21562
@@ -21500,10 +21575,10 @@ module.exports = function buildProcessingJS(Browser, testHarness) {
21500
21575
}),
21501
21576
21502
21577
PShapeSVG = source.PShapeSVG({
21503
- CommonFunctions:CommonFunctions,
21504
- PConstants:PConstants,
21505
- PShape:PShape,
21506
- XMLElement:XMLElement,
21578
+ CommonFunctions: CommonFunctions,
21579
+ PConstants: PConstants,
21580
+ PShape: PShape,
21581
+ XMLElement: XMLElement,
21507
21582
colors: source.colors
21508
21583
}),
21509
21584
@@ -21521,14 +21596,15 @@ module.exports = function buildProcessingJS(Browser, testHarness) {
21521
21596
}),
21522
21597
21523
21598
Processing = source.Processing({
21524
- defaultScope:defaultScope,
21525
- Browser:Browser,
21526
- extend:source.extend,
21527
- noop:noop
21599
+ defaultScope: defaultScope,
21600
+ Browser: Browser,
21601
+ extend: source.extend,
21602
+ noop: noop
21528
21603
});
21529
21604
21530
21605
// set up the Processing syntax parser
21531
21606
Processing = source.setupParser(Processing, {
21607
+ Browser: Browser,
21532
21608
aFunctions: testHarness,
21533
21609
defaultScope: defaultScope
21534
21610
});
0 commit comments