From 36255359c42d3949193c6f96a2097e3870a916db Mon Sep 17 00:00:00 2001 From: Chris Ruppel Date: Sat, 26 Jan 2013 23:00:09 -0600 Subject: [PATCH 1/7] Adding logo.js --- src/main/javascript/drone/logo.js | 173 ++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 src/main/javascript/drone/logo.js diff --git a/src/main/javascript/drone/logo.js b/src/main/javascript/drone/logo.js new file mode 100644 index 0000000..97c04af --- /dev/null +++ b/src/main/javascript/drone/logo.js @@ -0,0 +1,173 @@ +load(__folder + "drone.js"); +// +// Constructs the JS logo +// https://raw.github.com/voodootikigod/logo.js/master/js.png +// +// fg +// the material that the letters JS will be made of +// bg +// the material that the square will be made of +// +Drone.extend('logojs', function(fg, bg) { + fg = '35:7'; // default to gray wool + bg = 41; // default to gold blocks + + // Draw the sqaure + this.up() + .box(bg, 100, 100, 1); + + // Draw the J, starting with the hook + this.right(30).up(13) + .box(fg) + .right().down() + .box(fg, 1, 3, 1) + .right().down() + .box(fg, 1, 5, 1) + .right().down() + .box(fg, 1, 7, 1) + .right() + .box(fg, 1, 8, 1) + .right().down() + .box(fg, 1, 10, 1) + .right() + .box(fg, 1, 9, 1) + .right() + .box(fg, 1, 8, 1) + .right().down() + .box(fg, 2, 8, 1) + .right(2) + .box(fg, 4, 7, 1) + .right(4) + .box(fg, 1, 8, 1) + .right() + .box(fg, 1, 9, 1) + .right().up() + .box(fg, 3, 10, 1) + .right(3).up() + .box(fg, 2, 9, 1) + .right(2).up() + .box(fg, 2, 8, 1) + .right(2).up() + .box(fg, 1, 7, 1) + .right().up() + .box(fg, 1, 6, 1) + .right().up() + .box(fg, 1, 5, 1) + .right().up(2) + .box(fg, 1, 3, 1) + .left(9).up(3) + .box(fg, 10, 30, 1); + + // Draw the S + // It's drawn in three strokes from bottom to top. Look for when + // it switches from .right() to .left() then back again + this.move('start') + // move to starting point for S + .right(64).up(13) + // stroke 1 + .box(fg) + .right().down() + .box(fg, 1, 3, 1) + .right().down() + .box(fg, 1, 5, 1) + .right().down() + .box(fg, 1, 7, 1) + .right() + .box(fg, 1, 8, 1) + .right().down() + .box(fg, 1, 10, 1) + .right() + .box(fg, 1, 9, 1) + .right() + .box(fg, 1, 8, 1) + .right().down() + .box(fg, 2, 8, 1) + .right(2) + .box(fg, 4, 7, 1) + .right(4) + .box(fg, 2, 8, 1) + .right(2) + .box(fg, 1, 9, 1) + .right().up() + .box(fg, 1, 9, 1) + .right() + .box(fg, 1, 10, 1) + .right() + .box(fg, 1, 22, 1) + .right().up() + .box(fg, 2, 20, 1) + .right().up() + .box(fg, 1, 18, 1) + .right().up() + .box(fg, 1, 17, 1) + .right().up() + .box(fg, 1, 15, 1) + .right().up() + .box(fg, 1, 13, 1) + .right().up(2) + .box(fg, 1, 9, 1) + .right().up(2) + .box(fg, 1, 5, 1) + // stroke 2 + .left(8).up(4) + .box(fg, 1, 9, 1) + .left().up() + .box(fg, 1, 9, 1) + .left().up() + .box(fg, 1, 8, 1) + .left(2).up() + .box(fg, 2, 8, 1) + .left(2).up() + .box(fg, 2, 7, 1) + .left(2).up() + .box(fg, 2, 7, 1) + .left() + .box(fg, 1, 8, 1) + .left().up() + .box(fg, 1, 8, 1) + .left() + .box(fg, 1, 9, 1) + .left(2).up() + .box(fg, 2, 19, 1) + .left().up() + .box(fg, 1, 17, 1) + .left() + .box(fg, 1, 16, 1) + .left().up() + .box(fg, 1, 14, 1) + .left().up(2) + .box(fg, 1, 10, 1) + .left().up(2) + .box(fg, 1, 6, 1) + // stroke 3 + .right(7).up(6) + .box(fg, 1, 8, 1) + .right().up() + .box(fg, 1, 7, 1) + .right().up() + .box(fg, 2, 7, 1) + .right(2).up() + .box(fg, 4, 6, 1) + .right(4).down() + .box(fg, 2, 7, 1) + .right().down() + .box(fg, 1, 8, 1) + .right() + .box(fg, 1, 7, 1) + .right().down() + .box(fg, 1, 8, 1) + .right().down() + .box(fg, 1, 9, 1) + .right().down() + .box(fg, 1, 9, 1) + .right().up() + .box(fg, 1, 8, 1) + .right().up() + .box(fg, 1, 6, 1) + .right().up() + .box(fg, 1, 5, 1) + .right().up() + .box(fg, 1, 3, 1) + .right().up() + .box(fg); +}); From 182cdc22d875a46d4e005c862a4e221cefcac825 Mon Sep 17 00:00:00 2001 From: Chris Ruppel Date: Sat, 26 Jan 2013 23:07:10 -0600 Subject: [PATCH 2/7] Fixing defaults so args can take effect. --- src/main/javascript/drone/logo.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/javascript/drone/logo.js b/src/main/javascript/drone/logo.js index 97c04af..4698398 100644 --- a/src/main/javascript/drone/logo.js +++ b/src/main/javascript/drone/logo.js @@ -9,8 +9,13 @@ load(__folder + "drone.js"); // the material that the square will be made of // Drone.extend('logojs', function(fg, bg) { - fg = '35:7'; // default to gray wool - bg = 41; // default to gold blocks + + // foreground defaults to gray wool + if (typeof fg == "undefined") + fg = '35:7'; + // background defaults to gold blocks + if (typeof bg == "undefined") + bg = 41; // Draw the sqaure this.up() From 723965bcf8c0098319b8c3caa48f464a80e40cb6 Mon Sep 17 00:00:00 2001 From: Chris Ruppel Date: Sat, 26 Jan 2013 23:45:16 -0600 Subject: [PATCH 3/7] Add logojscube(). Refactored logojs() to handle being fired multiple times by the same Drone. --- src/main/javascript/drone/logo.js | 38 ++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/main/javascript/drone/logo.js b/src/main/javascript/drone/logo.js index 4698398..64a1a63 100644 --- a/src/main/javascript/drone/logo.js +++ b/src/main/javascript/drone/logo.js @@ -61,14 +61,14 @@ Drone.extend('logojs', function(fg, bg) { .right().up(2) .box(fg, 1, 3, 1) .left(9).up(3) - .box(fg, 10, 30, 1); + .box(fg, 10, 31, 1) // Draw the S // It's drawn in three strokes from bottom to top. Look for when // it switches from .right() to .left() then back again - this.move('start') + // move to starting point for S - .right(64).up(13) + .right(22).down(6) // stroke 1 .box(fg) .right().down() @@ -176,3 +176,35 @@ Drone.extend('logojs', function(fg, bg) { .right().up() .box(fg); }); +// +// Makes a cube of JS logos! +// This is a wrapper for logojs() so look at its docs +// +// Until the drone can rotate on its Z axis we can't +// use logojs() to create top/bottom sides of cube. +// +Drone.extend('logojscube', function(fg, bg) { + + this.logojs(fg, bg); + + this.move('start') + .right(100) + .turn(3) + .logojs(fg, bg); + + this.move('start') + .right(100) + .turn(3) + .right(100) + .turn(3) + .logojs(fg, bg); + + this.move('start') + .right(100) + .turn(3) + .right(100) + .turn(3) + .right(100) + .turn(3) + .logojs(fg, bg); +}); From 5af256cd55aa2e53b206dbc6006da67bf98c877f Mon Sep 17 00:00:00 2001 From: Chris Ruppel Date: Sun, 27 Jan 2013 14:05:19 -0600 Subject: [PATCH 4/7] Adding a checkpoint to logojscube() so it can be fired multiple times by the same Drone. --- src/main/javascript/drone/logo.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/javascript/drone/logo.js b/src/main/javascript/drone/logo.js index 64a1a63..fe75f6f 100644 --- a/src/main/javascript/drone/logo.js +++ b/src/main/javascript/drone/logo.js @@ -185,21 +185,22 @@ Drone.extend('logojs', function(fg, bg) { // Drone.extend('logojscube', function(fg, bg) { - this.logojs(fg, bg); + this.chkpt('jscube-start') + .logojs(fg, bg); - this.move('start') + this.move('jscube-start') .right(100) .turn(3) .logojs(fg, bg); - this.move('start') + this.move('jscube-start') .right(100) .turn(3) .right(100) .turn(3) .logojs(fg, bg); - this.move('start') + this.move('jscube-start') .right(100) .turn(3) .right(100) From e7f4a5c99bdeccbe6bdf01b1e41208ed6a560518 Mon Sep 17 00:00:00 2001 From: Chris Ruppel Date: Sun, 27 Jan 2013 14:12:25 -0600 Subject: [PATCH 5/7] Add checkpoint to logojs() and move back to it after finishing logo. --- src/main/javascript/drone/logo.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/javascript/drone/logo.js b/src/main/javascript/drone/logo.js index fe75f6f..216b923 100644 --- a/src/main/javascript/drone/logo.js +++ b/src/main/javascript/drone/logo.js @@ -18,7 +18,8 @@ Drone.extend('logojs', function(fg, bg) { bg = 41; // Draw the sqaure - this.up() + this.chkpt('logojs-start') + .up() .box(bg, 100, 100, 1); // Draw the J, starting with the hook @@ -175,6 +176,8 @@ Drone.extend('logojs', function(fg, bg) { .box(fg, 1, 3, 1) .right().up() .box(fg); + + this.move('logojs-start') }); // // Makes a cube of JS logos! From 284c2da586d8b538db40a5cb82a4c6bffe994092 Mon Sep 17 00:00:00 2001 From: Chris Ruppel Date: Sun, 27 Jan 2013 14:16:37 -0600 Subject: [PATCH 6/7] Both functions return this. They can now be chained. --- src/main/javascript/drone/logo.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/javascript/drone/logo.js b/src/main/javascript/drone/logo.js index 216b923..7f129f7 100644 --- a/src/main/javascript/drone/logo.js +++ b/src/main/javascript/drone/logo.js @@ -178,6 +178,8 @@ Drone.extend('logojs', function(fg, bg) { .box(fg); this.move('logojs-start') + + return this; }); // // Makes a cube of JS logos! @@ -211,4 +213,6 @@ Drone.extend('logojscube', function(fg, bg) { .right(100) .turn(3) .logojs(fg, bg); + + return this; }); From 53b0b64016ad929bcfc12f6f5ad44937724444f9 Mon Sep 17 00:00:00 2001 From: Chris Ruppel Date: Sun, 27 Jan 2013 14:23:39 -0600 Subject: [PATCH 7/7] missed a semi --- src/main/javascript/drone/logo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/javascript/drone/logo.js b/src/main/javascript/drone/logo.js index 7f129f7..47e7114 100644 --- a/src/main/javascript/drone/logo.js +++ b/src/main/javascript/drone/logo.js @@ -177,7 +177,7 @@ Drone.extend('logojs', function(fg, bg) { .right().up() .box(fg); - this.move('logojs-start') + this.move('logojs-start'); return this; });