added lochkartengenerator

This commit is contained in:
Victor Giers
2019-06-08 18:03:23 +02:00
parent 5ba73e402a
commit fa316ec443
12 changed files with 1111 additions and 150 deletions

View File

@@ -1,7 +1,5 @@
'use strict';
/* __V3D_TEMPLATE__ - template-based file; delete this line to prevent this file from being updated */
window.addEventListener('load', function() {
(function() {
@@ -166,30 +164,61 @@ function initFullScreen() {
}
function prepareExternalInterface(app) {
app.ExternalInterface.HSVtoRGB = function(h, s, v) {
var r, g, b, i, f, p, q, t;
i = Math.floor(h * 6);
f = h * 6 - i;
p = v * (1 - s);
q = v * (1 - f * s);
t = v * (1 - (1 - f) * s);
switch (i % 6) {
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;
case 5: r = v, g = p, b = q; break;
}
app.ExternalInterface.setRGB(r, g, b);
var r, g, b, i, f, p, q, t;
i = Math.floor(h * 6);
f = h * 6 - i;
p = v * (1 - s);
q = v * (1 - f * s);
t = v * (1 - (1 - f) * s);
switch (i % 6) {
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;
case 5: r = v, g = p, b = q; break;
}
app.ExternalInterface.setRGB(r, g, b);
}
let bid = 0;
let qid = 0;
app.ExternalInterface.addBit = function(state) {
$("#lochkarte").append("<span class='dot' id='b"+ bid +"'></span>");
$("#b" + bid).css("background-color","rgb("+255*state+", "+255*state+", "+255*state+")")
bid++;
}
app.ExternalInterface.addQubit = function(stateR, stateG, stateB) {
$("#lochkarte").append("<span class='dot' id='q"+ qid +"'></span>");
$("#q" + qid).css("background-color","rgb("+255*stateR+", "+255*stateG+", "+255*stateB+")")
qid++;
}
/*
app.ExternalInterface.setDivWidth = function(d) {
console.log(d);
$( "#lochkarte" ).width = d;
}
function reportWindowSize() {
app.ExternalInterface.rs();
}
window.onresize = reportWindowSize;
*/
}
function runCode(app) {
// add your code here, e.g. console.log('Hello, World!');
//window.onresize = app.ExternalInterface.setDivWidth;
}
});