Telegram Web K with changes to work inside I2P
https://web.telegram.i2p/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
806 B
35 lines
806 B
![]()
4 years ago
|
import fastBlur from '../vendor/fastBlur';
|
||
|
import { fastRaf } from './schedulers';
|
||
|
|
||
|
const RADIUS = 2;
|
||
|
const ITERATIONS = 2;
|
||
|
|
||
|
export default function blur(dataUri: string, delay?: number) {
|
||
|
return new Promise<string>((resolve) => {
|
||
|
fastRaf(() => {
|
||
|
const img = new Image();
|
||
|
|
||
|
img.onload = () => {
|
||
|
const canvas = document.createElement('canvas');
|
||
|
canvas.width = img.width;
|
||
|
canvas.height = img.height;
|
||
|
|
||
|
const ctx = canvas.getContext('2d')!;
|
||
|
|
||
|
ctx.drawImage(img, 0, 0);
|
||
|
fastBlur(ctx, 0, 0, canvas.width, canvas.height, RADIUS, ITERATIONS);
|
||
|
|
||
|
resolve(canvas.toDataURL());
|
||
|
};
|
||
|
|
||
|
if(delay) {
|
||
|
setTimeout(() => {
|
||
|
img.src = dataUri;
|
||
|
}, delay);
|
||
|
} else {
|
||
|
img.src = dataUri;
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|