diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-12-31 20:28:51 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-12-31 20:28:51 +0100 |
commit | ebfae920c46678eddb2425e1f73ec965a15fbc0b (patch) | |
tree | ae3f718623bc677ddbd2eae07aeaf6b0831aaeb9 | |
download | circles-ebfae920c46678eddb2425e1f73ec965a15fbc0b.tar.xz |
-rw-r--r-- | LICENSE | 16 | ||||
-rw-r--r-- | README.md | 5 | ||||
-rwxr-xr-x | index.html | 209 |
3 files changed, 230 insertions, 0 deletions
@@ -0,0 +1,16 @@ + + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..7035046 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Circles +Watch some randomly moving Circles + +## Context +I made this a few years ago and it was one of the first pieces of code I wrote, so please be gentle when reading the code. diff --git a/index.html b/index.html new file mode 100755 index 0000000..d5863bc --- /dev/null +++ b/index.html @@ -0,0 +1,209 @@ +<!DOCTYPE html> +<html> +<head> + <title>CIRCLES</title> + <script> + mode=true; + stop=false; + var sh=document.querySelector('html').clientHeight; + var sw=document.querySelector('html').clientWidth; + function blubb(){ + var div=document.getElementsByTagName("div")[0]; + if(mode){ + if(parseInt(div.style.width.replace(/px/,''))-5<=0){ + mode=false; + } + div.style.width=Math.abs(parseInt(div.style.width.replace(/px/,''))-5)+"px"; + } + else{ + if(parseInt(div.style.width.replace(/px/,''))-5>=290){ + //stop=true; + mode=true; + } + + div.style.width=Math.abs(parseInt(div.style.width.replace(/px/,''))+5)+"px"; + } + if(!stop){ + setTimeout(blubb,10); +} + } + </script> +</head> +<body bgcolor="grey"> + <center><div onclick=""style="border-radius:50%;background-color:black;width:300px;height:300px;"></div></center> + <div onclick="" style="border-radius:50%;background-color:green;width:100px;height:100px;position:absolute;top:500px;left:500px"></div> + <div style="border-radius:50%;background-color:red;width:200px;height:200px;position:absolute;top:400px;left:900px"></div> + <div style="border-radius:50%;background-color:yellow;width:150px;height:150px;position:absolute;top:200px;left:300px"></div> + <div style="border-radius:50%;background-color:blue;width:50px;height:50px;position:absolute;top:200px;left:1000px"></div> + <div style="border-radius:50%;background-color:white;width:25px;height:25px;position:absolute;top:50px;left:70px"></div> + <div style="border-radius:50%;background-color:orange;width:250px;height:250px;position:absolute;top:500px;right:50px"></div> + <script> + clocklock(); + blubb(); + psd=false; + dir="down"; + hdir=-1; + vdir=1; + hdir2=1; + vdir2=1; + hi(); + better(); + good(); + function clocklock(){ + var div=document.getElementsByTagName("div")[1]; + var nettop=(parseInt(div.style.top.replace(/px/,''))+Math.floor(Math.random()*7)-3); + if(nettop>0&&nettop+100<sh){ + div.style.top=nettop+"px"; + } + var netleft=(parseInt(div.style.left.replace(/px/,''))+Math.floor(Math.random()*7)-3); + if(netleft>0&&netleft+100<sw){ + div.style.left=netleft+"px"; + } + setTimeout(clocklock,5); + } + function hi(){ + var div=document.getElementsByTagName("div")[2]; + if(!psd){ + div.style.left=parseInt(div.style.left.replace(/px/,''))+10+"px"; + div.style.top=parseInt(div.style.top.replace(/px/,''))+10+"px"; + div.style.width=parseInt(div.style.width.replace(/px/,''))-20+"px"; + div.style.height=parseInt(div.style.height.replace(/px/,''))-20+"px"; + } + else{ + div.style.left=parseInt(div.style.left.replace(/px/,''))-10+"px"; + div.style.top=parseInt(div.style.top.replace(/px/,''))-10+"px"; + div.style.width=parseInt(div.style.width.replace(/px/,''))+20+"px"; + div.style.height=parseInt(div.style.height.replace(/px/,''))+20+"px"; + } + psd=!psd; + setTimeout(hi,175); + } + function better(){ + var div=document.getElementsByTagName("div")[3]; + if(Math.floor(Math.random()*21)===0){ + dir=["up","down","left","right"][Math.floor(Math.random()*5)]; + } + if(dir==="down"){ + nettop=parseInt(div.style.top.replace(/px/,''))+5; + if(nettop+150<sh){ + div.style.top=nettop+"px"; + } + else{ + dir="up"; + better(); + return 0; + } + } + else if(dir==="up"){ + nettop=parseInt(div.style.top.replace(/px/,''))-5; + if(nettop>0){ + div.style.top=nettop+"px"; + } + else{ + dir="down"; + better(); + return 0; + } + } + else if(dir==="right"){ + nettop=parseInt(div.style.left.replace(/px/,''))-5; + if(nettop>0){ + div.style.left=nettop+"px"; + } + else{ + dir="left"; + better(); + return 0; + } + } + else if(dir==="left"){ + nettop=parseInt(div.style.left.replace(/px/,''))+5; + if(nettop+150<sw){ + div.style.left=nettop+"px"; + } + else{ + dir="right"; + better(); + return 0; + } + + } + setTimeout(better,10); + } + function good(){ + var div=document.getElementsByTagName("div")[4]; + rar=50; + brak=false; + step=3; + if(Math.floor(Math.random()*rar)===0){ + hdir=hdir*(-1); + } + if(Math.floor(Math.random()*rar)===0){ + vdir=vdir*(-1); + } + netleft=parseInt(div.style.left.replace(/px/,''))+step*hdir; + nettop=parseInt(div.style.top.replace(/px/,''))+step*vdir; + if(netleft>0&&netleft+50<sw){ + div.style.left=netleft+"px"; + } + else{ + hdir=hdir*(-1); + brak=true; + } + if(nettop>0&&nettop+50<sh){ + div.style.top=nettop+"px"; + } + else{ + vdir=vdir*(-1); + brak=true; + } + if(brak){ + good(); + } + else{ + setTimeout(good,10); + } + } + function golf(){ + var div=document.getElementsByTagName("div")[5]; + brak=false; + step=5; + netleft=parseInt(div.style.left.replace(/px/,''))+step*hdir2; + nettop=parseInt(div.style.top.replace(/px/,''))+step*vdir2; + if(netleft>0&&netleft+25<sw){ + div.style.left=netleft+"px"; + } + else{ + hdir2=hdir2*(-1); + brak=true; + } + if(nettop>0&&nettop+25<sh){ + div.style.top=nettop+"px"; + } + else{ + vdir2=vdir2*(-1); + brak=true; + } + if(brak){ + golf(); + } + else{ + setTimeout(golf,10); + } + } + golf(); + var isk=1; + quadraturDesKreises(); + function quadraturDesKreises(){ + var div=document.getElementsByTagName("div")[6]; + step=1; + var net=parseInt(div.style.borderRadius.replace(/%/,''))-step*isk; + div.style.borderRadius=net+"%"; + if(net===0||net===100){ + isk=isk*(-1); + } + setTimeout(quadraturDesKreises,10); + } + </script> +</body> +</html> |