Skip to content

Instantly share code, notes, and snippets.

View RezaAmd's full-sized avatar
🎯
Focusing...

Reza Ahmadi RezaAmd

🎯
Focusing...
View GitHub Profile
// 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);
@RezaAmd
RezaAmd / two_points-angle.js
Last active September 23, 2023 10:47
Calculate two points angle degree in 2D graph
// JavaScript:
const angleCalculator = function(ax, ay, bx, by)
{
return Math.atan2(by - ay, bx - ax) * 180 / Math.PI
}
@RezaAmd
RezaAmd / Parallax.js
Created January 22, 2022 21:51
Javascript parallax library on mouse move.
// js:
class Parallax {
constructor(
parallax,
depthAttribute = "data-depth",
isSameDirectionAttribute = "data-same-direction"
) {
Array.from(parallax.querySelectorAll("[" + depthAttribute + "]")).forEach(
function (element) {
parallax.addEventListener(
@RezaAmd
RezaAmd / average-color.js
Created August 20, 2019 16:37 — forked from fuzzyfox/average-color.js
JavaScript: image average color
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'),