Journal #5761

Posted 15 years ago2009-04-21 13:14:51 UTC
Oskar Potatis Oskar Potatis🦔
JavaScript fun!
javascript:var size="40px",opacity=0.25,off=20,color=0,mouseIsDown=false;function set(){size=Number(prompt("size (px)",size.substr(0,size.length-2)));if(isNaN(size)||size<0.5)size=40;else size=Math.round(size);off=Math.floor(size/2);size+="px";opacity=Number(prompt("transparency (\%)",Math.round((1-opacity)*100)));if(isNaN(opacity)||opacity<0||opacity>=99.5)opacity=1;else opacity=1-(opacity/100);};set();alert("Hold down the left mouse button while moving your mouse to paint.\nTo change settings press the right mouse button.\n\nCoded by potatis_invalido.");document.addEventListener("mouseup",function( e){mouseIsDown=false;e.stopPropagation();e.preventDefault();if(e.button==2)setTimeout(set,0);},false);document.addEventListener("mousedown",function( e){if(!e.button)mouseIsDown=true;e.stopPropagation();e.preventDefault();},false);document.addEventListener("mousemove",function( e){if(!mouseIsDown)return;var el=document.createElement("div");el.style.position="absolute";el.style.width=el.style.height=size;el.style.zIndex="99999";if(++color==360)color=0;el.style.opacity=opacity;el.style.background="hsl("+color+",100%,50%)";el.style.left=(e.pageX-off)+"px";el.style.top=(e.pageY-off)+"px";document.body.appendChild(el);},false);

Copy it to your browser's address bar. Doesn't work in IE.
This is what I do in school when I'm bored.

12 Comments

Commented 15 years ago2009-04-21 13:17:39 UTC Comment #58986
Go to the TWHL homepage and punch this into the address bar >_>

javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',50); void(0);
Commented 15 years ago2009-04-21 13:20:39 UTC Comment #58991
Haha that's awesome
Commented 15 years ago2009-04-21 13:31:02 UTC Comment #58984
Go to the TWHL homepage and punch this into the address bar and edit away!

javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

You cannot save any changes that you've made, obviously.
Commented 15 years ago2009-04-21 13:33:59 UTC Comment #58987
Also nice ;o
Commented 15 years ago2009-04-21 14:51:12 UTC Comment #58990
where do you get these codes ?
Commented 15 years ago2009-04-21 15:04:05 UTC Comment #58992
I wrote mine. I think I recognize TheGrimReafer's code and The Might Atom's code can be found in various places.
Commented 15 years ago2009-04-21 15:22:37 UTC Comment #58988
Hah. All I can see on my phone is code. It's like The Matrix.

[Edit]
Damnit. The same thing happens on my laptop as well. D:
Commented 15 years ago2009-04-21 16:45:16 UTC Comment #58993
What are you talking about? I posted code, so you should see code.
Or do you mean when you try to run the code?
Commented 15 years ago2009-04-21 16:48:56 UTC Comment #58989
Ahh. I hadn't read the bit at the bottom. I'd assumed it was like the last one you posted that shows up on the page: "Hello, TJB!"
Commented 15 years ago2009-04-21 16:53:55 UTC Comment #58994
Oh, that was just a picture, really. The server generates it using a script but what is sent to the client is a PNG picture.
Commented 15 years ago2009-04-21 17:14:55 UTC Comment #58985
I like Muzz's the best.
Commented 1 week ago2024-10-01 15:23:10 UTC Comment #106426
I still write JavaScript (well, TypeScript to be more precise) when I'm bored: https://www.npmjs.com/package/cmath-js

You must log in to post a comment. You can login or register a new account.