Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var armSize = 50;
- var posX = 0;
- var posY = 0;
- var stopSpams = false;
- var current = 0;
- function drawArm()
- {
- if(stopSpams)
- return;
- var send = [];
- if(current == 0)
- { // upper left
- send.push({x: posX + 0, y: posY + 0});
- send.push({x: posX + 0, y: posY + armSize});
- send.push({x: posX + armSize, y: posY + armSize});
- }
- if(current == 1)
- { // upper right
- send.push({x: posX + armSize * 2, y: posY + 0});
- send.push({x: posX + armSize, y: posY + 0});
- send.push({x: posX + armSize, y: posY + armSize});
- }
- if(current == 2)
- { // lower right
- send.push({x: posX + armSize * 2, y: posY + armSize * 2});
- send.push({x: posX + armSize * 2, y: posY + armSize});
- send.push({x: posX + armSize, y: posY + armSize});
- }
- if(current == 3)
- { // lower left
- send.push({x: posX + 0, y: posY + armSize * 2});
- send.push({x: posX + armSize, y: posY + armSize * 2});
- send.push({x: posX + armSize, y: posY + armSize});
- }
- if(current == 4)
- {
- // randomize posX, posY, set timeout and return
- posX = Math.floor(Math.random() * 1200);
- posY = Math.floor(Math.random() * 700);
- current = 0;
- setTimeout(drawArm, 100);
- return;
- }
- socket.emit('update', { points: send, color: color, id: 1 });
- current++;
- drawArm();
- }
- function chaim()
- {
- if(stopSpams)
- return;
- var send = [];
- if(current == 0)
- { // top triangle
- send.push({x: posX + armSize * 2, y: posY + 0}); // top point
- send.push({x: posX + 0, y: posY + armSize * 4}); // left point
- send.push({x: posX + armSize * 4, y: posY + armSize * 4}); // right point
- send.push({x: posX + armSize * 2, y: posY + 0}); // back to top
- }
- if(current == 1)
- { // bottom triangle
- send.push({x: posX + armSize * 2, y: posY + armSize * 5}); // bottom point
- send.push({x: posX + 0, y: posY + armSize * 1}); // left point
- send.push({x: posX + armSize * 4, y: posY + armSize * 1}); // right point
- send.push({x: posX + armSize * 2, y: posY + armSize * 5}); // bottom point
- }
- if(current == 2)
- {
- // randomize posX, posY, set timeout and return
- posX = Math.floor(Math.random() * 1200);
- posY = Math.floor(Math.random() * 700);
- current = 0;
- setTimeout(chaim, 100);
- return;
- }
- socket.emit('update', { points: send, color: color, id: 1 });
- current++;
- chaim();
- }
- function chunk (arr, len) {
- var chunks = [],
- i = 0,
- n = arr.length;
- while (i < n) {
- chunks.push(arr.slice(i, i += len));
- }
- return chunks;
- }
- recording = [];
- function startDrawing(start) {
- newPoints = [ start ];
- $(canvas).mousemove(function (event) {
- var next = getMousePos(canvas, event);
- if (getDist(start, next) >= MIN_POINT_DIST) {
- if (!isDrawing || isDirty) {
- newPath(start, color);
- isDrawing = true;
- isDirty = false;
- }
- ctx.lineTo(next.x, next.y);
- ctx.stroke();
- newPoints.push(next);
- start = next;
- if (newPoints.length >= MIN_UPDATE_POINTS) {
- sendUpdate(newPoints);
- newPoints = [ newPoints[newPoints.length - 1] ];
- }
- }
- });
- }
- $(canvas).unbind('mousedown');
- $(canvas).mousedown(function (event) {
- startDrawing(getMousePos(canvas, event));
- });
- function chunkSend(p){
- p.forEach(function(a)
- {
- sendUpdateOld (a);
- });
- }
- var sendUpdateOld = function(p){
- socket.emit('update', { points: p, color: color, id: 1 });
- }
- sendUpdate = function(p){
- recording.push(p);
- sendUpdateOld(p);
- }
- function randColor(){
- var chr = "0123456789abcdef";
- function r(){
- return chr[Math.round(Math.random()*chr.length)-1];
- }
- return '#' + r() +r() +r() +r() +r() +r();
- }
- var spamtimer;
- $('body').append($('<button>reset</button>').click(function(){ recording = []; }));
- $('body').append($('<button>send</button>').click(function(){ chunkSend(recording); }));
- $('body').append($('<button>spam</button>').click(function(){ spamtimer = setInterval(function(){ chunkSend(recording); color = randColor(); }, 100); }));
- $('body').append($('<button>stop</button>').click(function(){ stopSpams = true; current = 0; clearInterval(spamtimer); }));
- $('body').append($('<button>swastika</button>').click(function(){ stopSpams = false; current = 0; drawArm(); }));
- $('body').append($('<button>david star</button>').click(function(){ stopSpams = false; current = 0; chaim(); }));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement