Babsan Difference Check
How do I make an babsan difference check?
What is a babsan difference check? How do you make a babsan difference check? This script and codes were developed by Carl Calderon on 30 July 2022, Saturday.
Babsan Difference Check - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Babsan Difference Check</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Babsan Difference Check</h1>
<div id="visuals"> A <canvas id="source" width="320" height="240"></canvas> B <canvas id="comparison" width="320" height="240"></canvas> C
</div>
<p id="score"></p>
<p id="result"></p> <script src="js/index.js"></script>
</body>
</html>
Babsan Difference Check - Script Codes CSS Codes
body { font: 16px/20px Helvectica, Arial, sans-serif; text-align: center;
}
h1 { font-size: 30px; margin: 30px;
}
canvas { border: 1px solid lightgrey; margin: 10px;
}
#result { font: 12px monospace;
}
#score { font-size: 50px; margin: 30px;
}
sub { font-size: 0.5em;
}
#visuals > * { vertical-align: middle;
}
Babsan Difference Check - Script Codes JS Codes
'use strict';
var getDifferenceByCanvas = function getDifferenceByCanvas(source, comparison) { var diffCanvas = document.createElement('canvas'); var diffContext = diffCanvas.getContext('2d'); diffCanvas.width = source.width; diffCanvas.height = source.height; var sourceContext = source.getContext('2d'); var comparisonContext = comparison.getContext('2d'); var sourceImageData = sourceContext.getImageData(0, 0, source.width, source.height).data; var comparisonImageData = comparisonContext.getImageData(0, 0, comparison.width, comparison.height).data; var diffImageData = diffContext.getImageData(0, 0, diffCanvas.width, diffCanvas.height); var pixelDifference = 0; var pixelsWithDifference = 0; var rawDifference = sourceImageData.reduce(function (accumulator, uint, index) { var delta = Math.abs(uint - comparisonImageData[index]); diffImageData.data[index] = 255 - delta; pixelDifference += delta; if (index % 4 === 0) { if (pixelDifference > 0) { pixelsWithDifference++; } pixelDifference = 0; } return accumulator + delta; }, 0); diffContext.putImageData(diffImageData, 0, 0); return { raw: rawDifference, diff: rawDifference / (sourceImageData.length * 255), max: sourceImageData.length * 255, visual: diffCanvas, rawPixels: pixelsWithDifference, diffPixels: pixelsWithDifference / (source.width * source.height), maxPixels: source.width * source.height };
};
// ------------------------------------------------------------------------------------
var source = document.getElementById('source');
var comparison = document.getElementById('comparison');
var sourceContext = source.getContext('2d');
var comparisonContext = comparison.getContext('2d');
var loadImages = function loadImages(source, comparison) { return new Promise(function (resolve, reject) { var sourceImage = new Image(); var comparisonImage = new Image(); sourceImage.crossOrigin = 'Anonymous'; comparisonImage.crossOrigin = 'Anonymous'; sourceImage.src = source; comparisonImage.src = comparison; var count = 0; var handleLoad = function handleLoad() { if (++count == 2) resolve({ source: sourceImage, comparison: comparisonImage }); }; sourceImage.addEventListener('load', handleLoad); comparisonImage.addEventListener('load', handleLoad); });
};
loadImages('https://s3-us-west-2.amazonaws.com/s.cdpn.io/7239/babsan.png', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/7239/babsan-text.png').then(function (_ref) { var source = _ref.source; var comparison = _ref.comparison; sourceContext.drawImage(source, 0, 0); comparisonContext.drawImage(comparison, 0, 0);
}).then(function () { return getDifferenceByCanvas(source, comparison);
}).then(function (_ref2) { var raw = _ref2.raw; var diff = _ref2.diff; var max = _ref2.max; var visual = _ref2.visual; var rawPixels = _ref2.rawPixels; var diffPixels = _ref2.diffPixels; var maxPixels = _ref2.maxPixels; document.getElementById('result').innerHTML = 'raw: ' + raw + ' diff: ' + diff + ' raw pixels: ' + rawPixels + ' diff pixels: ' + diffPixels + ' max pixels: ' + maxPixels; document.getElementById('visuals').appendChild(visual); document.getElementById('score').innerHTML = Number(diffPixels * 100).toFixed(2) + '%<sub>p</sub> (' + Number(diff * 100).toFixed(2) + '%<sub>r</sub>)';
});
Developer | Carl Calderon |
Username | carlcalderon |
Uploaded | July 30, 2022 |
Rating | 3 |
Size | 4,122 Kb |
Views | 66,792 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Project Euler - Problem 2 | 2,507 Kb |
Foldable list with Chuck Norris facts | 5,984 Kb |
Floyd-Steinberg dithering | 145,855 Kb |
Single Element CSS Stickers | 2,690 Kb |
Subway - Red Line | 5,580 Kb |
Almost Magic Mouse | 4,567 Kb |
Flat Adobe Icons | 5,714 Kb |
Bayer ordered dithering | 146,053 Kb |
Paper login form | 121,232 Kb |
Motion | 4,015 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Drawing a Terminal with CSS | Lachlanjc | 3,185 Kb |
STIKHOI | Denmch | 7,122 Kb |
Google Chrome Icon using Pure CSS in one DIV | Grssam | 3,627 Kb |
Force Counter | Kenlauguico | 2,732 Kb |
Loading animation - freedom purchase | Rocbear | 2,567 Kb |
JQuery Validate checkbox group | Lunaman | 2,466 Kb |
Spin | Elalemanyo | 8,262 Kb |
Simple checkbox style | Vncnz | 2,628 Kb |
Sort the Knowlege | Eprouver | 3,915 Kb |
SVG Text Masking | JMChristensen | 2,141 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!