From ed9d3b42125a8fb6f54b6e6521f067ec7e7d8b62 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Wed, 8 Jan 2020 21:10:04 -0500 Subject: added clear.js --- examples/clear.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/clear.js (limited to 'examples') diff --git a/examples/clear.js b/examples/clear.js new file mode 100644 index 0000000..e845c55 --- /dev/null +++ b/examples/clear.js @@ -0,0 +1,28 @@ +// Demonstrates large-scale changes using tools/queue.js; pastes a character (once) over a large area + +// This demo puts a bunch of z's on yourworldoftext.com/zworld (scroll up because it's a big area) +const Socket = require('../socket.js'); +const Space = require('../space.js'); +const Queue = require('../tools/queue.js'); + +let width = 801; +let height = 801; +let sends = width*height; + +let copyspace = new Space(); +copyspace.loc = [-400,-400]; + +let row = 'z'.repeat(width)+'\n'; +let tot = row.repeat(height); +copyspace.adhoc(tot); + +let main = new Socket('zworld'); +let writect = 0; +let writes = new Queue(1000, 200, w => { + main.write(w); + writect += 200; + console.log(writect + '/' + sends)}); + +writes.enqueue(copyspace.towrite()); + +main.on('open',()=>{writes.enable(); console.log('enabled');}); -- cgit