diff --git a/gyrio/README.md b/gyrio/README.md new file mode 100644 index 0000000..d87c00f --- /dev/null +++ b/gyrio/README.md @@ -0,0 +1,8 @@ +# gyrio +Web Oscilloscope viewer + +## History +Gyrio was originally created at GrizzHacks, a hackathon which took place September 30, 2017 + +## Components +There are 3 major parts to gyrio. First, there is the oscilloscope mode, which converts the data to binary digits and then displays these in a similar method to an oscilloscope. The next mode is an attempt to represent the data in a sound format. To achieve this, the data was converted to a base-8 form and then mapped to a set of 8 tones, which were then outputted. Lastly, the final mode is an attempt to display the data as a whole. The data was converted to hexadecimal and then displayed in an image form, resulting in a picture similar to a colorful QR code. diff --git a/gyrio/index.css b/gyrio/index.css new file mode 100644 index 0000000..6bd0065 --- /dev/null +++ b/gyrio/index.css @@ -0,0 +1,183 @@ +@import url('https://fonts.googleapis.com/css?family=Raleway'); + +html { + font-family: 'Raleway'; + /*background-color: #15171B;*/ +} + +body { + margin: 0; +} +canvas, img { + image-rendering: optimizeSpeed; + image-rendering: -moz-crisp-edges; + image-rendering: -webkit-optimize-contrast; + image-rendering: optimize-contrast; + image-rendering: pixelated; + -ms-interpolation-mode: nearest-neighbor; +} + +#DAText { + font-weight: 100; + color: white; + font-size: 500%; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + +#imagecode { + width: 35%; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + +header { + height: 7vh; + width: 100%; + position: absolute; + top: 0; + background-color: rgba(255,255,255,0.05); +} + +#title { + margin: 0; + padding-left: 2%; + padding-right: 2%; + font-family: "Raleway"; + line-height: 5vh; + color: white; + font-weight: 100; + display:inline-block; + position: relative; + top: 50%; + transform: translateY(-50%); + float: left; +} + +#urlInput { + padding: 2%; + height: 100%; + width: 30%; + background-color: rgba(255,255,255,0.05); + border: 0; + border-radius: 3px; + display: inline-block; + position: relative; + top: 50%; + font-family: "Raleway"; + transform: translateY(-50%); + outline: none; + color: white; + font-size: 110%; + float: left; +} + +.fa-search, .fa-cog, .fa-bars { + color: white; + float: left; + font-size: 140%; + display: inline-block; + height: 7vh; + width: 7vh; + line-height: 7vh !important; + text-align: center; + cursor: pointer; + background-color: rgba(255,255,255,0); + transition: background-color 0.2s ease; +} + +.fa-search:hover, .fa-cog:hover, .fa-bars:hover { + background-color: rgba(255,255,255,0.1); +} + +.fa-bars { + float: right; +} + +#settings { + position: absolute; + background-color: rgba(255,255,255,0.5); +} + +.dropdown { + position: relative; + display: inline-block; +} + +.dropdown h1 { + width: 100%; + font-size: 80%; + text-align: center; + line-height: none; + padding: 0; + font-family: "Raleway"; + font-weight: 100; + font-size: 120%; + color: white; +} + +#speedContainer div { + width: 80%; + margin: auto; +} + +.dropdown input { + width: 100%; + cursor: pointer; + -webkit-appearance: none; + background-color: rgba(255,255,255, 0.1); + transition: background-color 0.2s ease; + outline: none; +} + +.dropdown input:hover { + background-color: rgba(255,255,255, 0.12); +} + +.dropdown input::-webkit-slider-thumb { + background: rgba(255,255,255,0.2); + -webkit-appearance: none; + height: 30%; + width: 10%; +} + +#speedContainer { + display: none; + position: absolute; + top: 100%; + background-color: rgba(255,255,255,0.1); + width: 300%; + height: 150%; +} + +#modeContainer { + display: none; + position: absolute; + top: 100%; + background-color: rgba(255,255,255,0.1); + right: 0; + width: 350%; +} + +#modeContainer p { + cursor: pointer; + margin: 0; + padding: 10% 0 10% 0; + color: white; + font-weight: 100; + text-align: center; + background-color:rgba(0,0,0,0); + transition: background-color 0.2s ease; +} + +#modeContainer p:hover { + background-color: rgba(0,0,0,0.1); +} + +.show { + display: block !important; +} diff --git a/gyrio/index.html b/gyrio/index.html new file mode 100644 index 0000000..6afe8e0 --- /dev/null +++ b/gyrio/index.html @@ -0,0 +1,40 @@ + + + + + Gyrio + + + + +
+

Gyrio

+ + + + + +
+

+ + + + + diff --git a/gyrio/index.js b/gyrio/index.js new file mode 100644 index 0000000..27ec9a3 --- /dev/null +++ b/gyrio/index.js @@ -0,0 +1,364 @@ +function randInt(min,max) { + return Math.floor(Math.random() * (max - min + 1)) + min; +} + +function hexToRGB(hex) { + var r = parseInt(hex.slice(0, 2), 16), + g = parseInt(hex.slice(2, 4), 16), + b = parseInt(hex.slice(4, 6), 16); + + return [r,g,b]; +} + +function convertData(text, base){ + // if(text.length < 150) { + // website = ""; + // return; + // } + var output = ""; + for (var i = 0; i < text.length; i++) + { + var letter = text[i].charCodeAt(0).toString(base); + output += letter; + } + return output; +} + +function generateString() { + var final = ""; + var length = randInt(50,100); + for(var i = 0; i < length; i++) { + final += randInt(0,1); + } + return final; +} + +var canvas = document.getElementById("canvas"); +var visualCtx = canvas.getContext("2d"); + + +var audioCtx = new window.AudioContext(); +var doAnimate = true; +var freq = [261.63, 293.66, 329.63, 349.23, 392.00, 440.00, 493.88, 523.25]; + +canvas.width = window.innerWidth; +canvas.height = window.innerHeight; + +visualCtx.fillStyle = "#000"; +visualCtx.fillRect(0,0, canvas.width, canvas.height); +function generateFrames(frame, string, width, height, rate) { + // Rate is in bits per second + // 30 frames per second + var bitsPerSection = Math.ceil(canvas.width/width)+2; + var shift = canvas.width-rate*width*frame/30; + var bitsToCalc = Math.ceil(rate*width*frame/(width*30)); + var output = []; + for(var i = bitsToCalc-bitsPerSection; i < bitsToCalc; i++) { + try { + var x = i*width; + if(parseInt(string[i])) { + output.push([x+shift, -height+canvas.height/2]); + output.push([x+width+shift, -height+canvas.height/2]); + if(string[i-1] === 0) { + output.push([x+width+shift, canvas.height/2]); + } + } else { + output.push([x+shift, canvas.height/2]); + output.push([x+width+shift,canvas.height/2]); + } + } catch(err) {} + } + return output; +} + +function drawFrame(frame ,input) { + visualCtx.fillRect(0,0, canvas.width, canvas.height); + visualCtx.beginPath(); + var frame1 = generateFrames(frame, input, 100, 100, speed); + visualCtx.moveTo(0,(canvas.height/2)-100); + for(var i = 1; i < frame1.length; i++) { + visualCtx.lineTo(frame1[i][0],frame1[i][1]); + } + visualCtx.strokeStyle="#006064"; + visualCtx.stroke(); +} + +function drawFrame2(frame ,input) { + visualCtx.fillRect(0,0, canvas.width, canvas.height); + var ColorList = ["006064"/*,"00838F","0097A7","00ACC1","00B8D4","00E5FF","18FFFF","84FFFF"*/]; + + for(var j=0;j