JSFiddle - React, Tailwind, and code Playground
JavaScript
var
rgbToHex = function(r, g, b) {
return ((r << 16) | (g << 8) | b).toString(16);
},
isOkey = function(datanf,index, lineSize, circleSize){
var i = 0, tmpIndex = 0, hx0 = "000000", isBad = function(datanf, tmpIndex){
return ((parseInt(datanf[tmpIndex]) <50 && parseInt(datanf[tmpIndex+1]) <50 && parseInt(datanf[tmpIndex+2]) <50 ))?true:false;
};
rowPixelSize = lineSize * 4, test = 0;
while (i <= circleSize){
tmpIndex = index + ((i++)*4);
if (!isBad(datanf, tmpIndex)) { ++test; break; }
};
i = 0;
while (i <= circleSize){
tmpIndex = index + ((i++)*rowPixelSize);
if (!isBad(datanf, tmpIndex)) { ++test; break; }
};
i = 0, index += (circleSize*4);
while (i <= circleSize){
tmpIndex = index + ((i++)*rowPixelSize);
if (!isBad(datanf, tmpIndex)) { ++test; break; }
};
i = 0, index = tmpIndex - (circleSize*4);
while (i <= circleSize){
tmpIndex = index + ((i++)*4);
if (!isBad(datanf, tmpIndex)) { ++test; break; }
};
console.log(test);
return (test > 1) ? false : true;
}, ColorSquare = function(data, index, lineSize, circleSize, isOkey){
var i = 0, tmpIndex = 0, colorPix = function(data, tmpIndex){
data[tmpIndex] = (!isOkey)?255:0, data[tmpIndex+1] = (!isOkey)?0:255, data[tmpIndex+2] = 0;
return data;
},
rowPixelSize = lineSize * 4; while (i <= circleSize) tmpIndex = index + ((i++)*4), data = colorPix(data, tmpIndex);
i = 0; while (i <= circleSize) tmpIndex = index + ((i++)*rowPixelSize), data = colorPix(data, tmpIndex);
i = 0, index += (circleSize*4); while (i <= circleSize) tmpIndex = index + ((i++)*rowPixelSize), data = colorPix(data, tmpIndex);
i = 0, index = tmpIndex - (circleSize*4); while (i <= circleSize) tmpIndex = index + ((i++)*4), data =...