This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// At first you should download "cwebp.exe". | |
// The latest source tree is available at: | |
// https://chromium.googlesource.com/webm/libwebp | |
byte[] ConvertJpgToWebP(byte[] jpgBytes, string fileName, string extension) | |
{ | |
string jpgFilePath = $"images//{fileName}.{extension}"; | |
string webpFilePath = $"images//{fileName}.webp"; | |
// Write the JPG byte[] to a file | |
File.WriteAllBytes(jpgFilePath, jpgBytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript: | |
const angleCalculator = function(ax, ay, bx, by) | |
{ | |
return Math.atan2(by - ay, bx - ax) * 180 / Math.PI | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// js: | |
class Parallax { | |
constructor( | |
parallax, | |
depthAttribute = "data-depth", | |
isSameDirectionAttribute = "data-same-direction" | |
) { | |
Array.from(parallax.querySelectorAll("[" + depthAttribute + "]")).forEach( | |
function (element) { | |
parallax.addEventListener( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getAverageColor = (function(window, document, undefined){ | |
return function(imageURL, options}){ | |
options = { | |
// image split into blocks of x pixels wide, 1 high | |
blocksize: options.blocksize || 5, | |
fallbackColor: options.fallbackColor || '#000' | |
}; | |
var img = document.createElement('img'), | |
canvas = document.createElement('canvas'), |