Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Borgen_tiles_script
- // @namespace http://www.reddit.com/user/NewCompte
- // @description ask Borgen and brioche
- // @include http://*.koalabeast.com:*
- // @license GPL
- // @author NewCompte, modified by brioche
- // @version 1
- // ==/UserScript==
- function myRotatingBallsScript() {
- tagpro.ready(function(){
- //This is important.
- if(tagpro.events.drawPlayer)
- return;
- // Test for oltp
- var BorgenBallsInside = new Image();
- BorgenBallsInside.src = "http://i.imgur.com/foW9vMF.png";
- var BorgenBallsLighting = new Image();
- BorgenBallsLighting.src = "http://i.imgur.com/TChUSRB.png";
- var BorgenBallsBorders = new Image();
- BorgenBallsBorders.src = "http://i.imgur.com/FQbe57J.png";
- // Borgen texture pack:
- document.getElementById("tiles").src = "http://i.imgur.com/j9dgpUQ.png";
- document.getElementById("splats").src = "http://i.imgur.com/3m8yX7z.png";
- document.getElementById("speedpad").src = "http://i.imgur.com/q1Jylmv.png";
- document.getElementById("speedpadred").src = "http://i.imgur.com/IoAJ7Tj.png";
- document.getElementById("speedpadblue").src = "http://i.imgur.com/Ycxcudc.png";
- document.getElementById("portal").src = "http://i.imgur.com/qDUaiqD.png";
- //Wait 1 second then redraw textures
- setTimeout(tagpro.api.redrawBackground,1000);
- function componentToHex(c) {
- var hex = c.toString(16);
- return hex.length == 1 ? "0" + hex : hex;
- }
- function rgbToHex(r, g, b) {
- return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
- }
- /**
- * HSV to RGB color conversion
- *
- * H runs from 0 to 360 degrees
- * S and V run from 0 to 100
- *
- * Ported from the excellent java algorithm by Eugene Vishnevsky at:
- * http://www.cs.rit.edu/~ncs/color/t_convert.html
- */
- function hsvToRgb(h, s, v) {
- var r, g, b;
- var i;
- var f, p, q, t;
- // Make sure our arguments stay in-range
- h = Math.max(0, Math.min(360, h));
- s = Math.max(0, Math.min(100, s));
- v = Math.max(0, Math.min(100, v));
- // We accept saturation and value arguments from 0 to 100 because that's
- // how Photoshop represents those values. Internally, however, the
- // saturation and value are calculated from a range of 0 to 1. We make
- // That conversion here.
- s /= 100;
- v /= 100;
- if(s == 0) {
- // Achromatic (grey)
- r = g = b = v;
- return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
- }
- h /= 60; // sector 0 to 5
- i = Math.floor(h);
- f = h - i; // factorial part of h
- p = v * (1 - s);
- q = v * (1 - s * f);
- t = v * (1 - s * (1 - f));
- switch(i) {
- case 0:
- r = v;
- g = t;
- b = p;
- break;
- case 1:
- r = q;
- g = v;
- b = p;
- break;
- case 2:
- r = p;
- g = v;
- b = t;
- break;
- case 3:
- r = p;
- g = q;
- b = v;
- break;
- case 4:
- r = t;
- g = p;
- b = v;
- break;
- default: // case 5:
- r = v;
- g = p;
- b = q;
- }
- return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
- }
- if (tagpro.events.drawPlayer) {return;}
- tagpro.events.register({
- drawPlayer: function(player, context, drawPos, TILESIZE) {
- // Draw rotating inside
- context.save();
- context.globalAlpha = 0.7; // Here is transparency
- context.translate(drawPos.x + (TILESIZE / 2) * (1 / tagpro.zoom), drawPos.y + (TILESIZE / 2) * (1 / tagpro.zoom));
- context.rotate(player.angle);
- context.translate(-drawPos.x - (TILESIZE / 2) * (1 / tagpro.zoom), -drawPos.y - (TILESIZE / 2) * (1 / tagpro.zoom));
- if (player.team == 1)
- context.drawImage(BorgenBallsInside, 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
- if (player.team == 2)
- context.drawImage(BorgenBallsInside, 0, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
- context.restore();
- // Draw muscle cup lighting
- context.save();
- context.globalAlpha = 0.7; // Here is transparency
- context.drawImage(BorgenBallsLighting, 0, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
- context.restore();
- // Draw rotating border
- context.save();
- context.globalAlpha = 1; // Here is transparency
- context.translate(drawPos.x + (TILESIZE / 2) * (1 / tagpro.zoom), drawPos.y + (TILESIZE / 2) * (1 / tagpro.zoom));
- context.rotate(player.angle);
- context.translate(-drawPos.x - (TILESIZE / 2) * (1 / tagpro.zoom), -drawPos.y - (TILESIZE / 2) * (1 / tagpro.zoom));
- context.drawImage(BorgenBallsBorders, 40, 0, 40, 40, drawPos.x, drawPos.y, 40 / tagpro.zoom, 40 / tagpro.zoom);
- context.restore();
- // Draw pixel perfect rolling bomb
- if (player.bomb && Math.round(Math.random() * 4) == 1) {
- context.fillStyle = "rgba(255, 255, 0, .60)";
- context.beginPath();
- context.arc(drawPos.x + (TILESIZE / 2) * (1 / tagpro.zoom), drawPos.y + (TILESIZE / 2) * (1 / tagpro.zoom), 17 * (1 / tagpro.zoom), 0, Math.PI*2, true);
- context.closePath();
- context.fill();
- };
- // Draw pixel perfect tagpro
- if (player.tagpro) {
- var curr = new Date();
- var tagpro360 = Math.round((new Date).getTime()/1000*360*3) % 360 ;
- var tagproRGB = hsvToRgb(tagpro360, 100, 100) ;
- var tagproHex = rgbToHex(tagproRGB[0],tagproRGB[1],tagproRGB[2]) ;
- context.strokeStyle = tagproHex ;
- var tagproString = tagproRGB.toString() ;
- context.fillStyle = "rgba(" + tagproString + ", .00)";
- context.lineWidth = 2 * (1 / tagpro.zoom);
- context.beginPath();
- context.arc(drawPos.x + (TILESIZE / 2) * (1 / tagpro.zoom), drawPos.y + (TILESIZE / 2) * (1 / tagpro.zoom), 16 * (1 / tagpro.zoom), 0, Math.PI*2, true);
- context.closePath();
- if (!player.bomb)
- context.fill();
- context.stroke();
- }
- }
- });
- });
- }
- var source = "("+ myRotatingBallsScript + ")()";
- var script = document.createElement('script');
- script.setAttribute("type", "application/javascript");
- script.textContent = source;
- document.body.appendChild(script);
Add Comment
Please, Sign In to add comment