Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel committed Feb 11, 2024
1 parent 261b49b commit 39ed39e
Showing 1 changed file with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@
This file was generated by the Surface compiler.
*/


import { decodeBlurHash } from 'fast-blurhash';

export default {
mounted() {
// const canvas = document.createElement('canvas');
const canvas = this.el.getElementsByTagName('canvas')[0];
console.log(canvas)
const w = canvas.width || 40
const h = canvas.height || 40
const default_hash = 'LEHV6nWB2yk8pyo0adR*.7kCMdnj'
const hash = this.el.dataset.hash
console.log(hash)
// decode blurHash image
const pixels = decodeBlurHash(hash || default_hash, w, h);
console.log(pixels)
mounted() {
// const canvas = document.createElement('canvas');
const canvas = this.el.getElementsByTagName('canvas')[0];
// console.log(canvas)
const w = canvas.width || 40
const h = canvas.height || 40
const default_hash = 'LEHV6nWB2yk8pyo0adR*.7kCMdnj'
const hash = this.el.dataset.hash
// console.log(hash)

// decode blurHash image
const pixels = decodeBlurHash(hash || default_hash, w, h);
// console.log(pixels)

// draw it on canvas
const ctx = canvas.getContext('2d');
const imageData = ctx.createImageData(w, h);
// draw it on canvas
const ctx = canvas.getContext('2d');
const imageData = ctx.createImageData(w, h);

imageData.data.set(pixels);
console.log(imageData)
ctx.putImageData(imageData, 0, 0);
// document.body.append(canvas);
}
imageData.data.set(pixels);
// console.log(imageData)
ctx.putImageData(imageData, 0, 0);
// document.body.append(canvas);
}
}

0 comments on commit 39ed39e

Please sign in to comment.