fix
This commit is contained in:
parent
bb0036ae22
commit
b01c22c647
|
@ -31,23 +31,10 @@ let loaded = $ref(false);
|
||||||
let width = $ref(props.width);
|
let width = $ref(props.width);
|
||||||
let height = $ref(props.height);
|
let height = $ref(props.height);
|
||||||
|
|
||||||
function draw() {
|
|
||||||
if (props.hash == null) return;
|
|
||||||
const pixels = decode(props.hash, props.width, props.height);
|
|
||||||
const ctx = canvas.getContext('2d');
|
|
||||||
const imageData = ctx!.createImageData(props.width, props.height);
|
|
||||||
imageData.data.set(pixels);
|
|
||||||
ctx!.putImageData(imageData, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => props.hash, () => {
|
|
||||||
draw();
|
|
||||||
});
|
|
||||||
|
|
||||||
watch([() => props.width, () => props.height], () => {
|
watch([() => props.width, () => props.height], () => {
|
||||||
const ratio = props.width / props.height;
|
const ratio = props.width / props.height;
|
||||||
if (ratio > 1) {
|
if (ratio > 1) {
|
||||||
|
@ -61,6 +48,19 @@ watch([() => props.width, () => props.height], () => {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
if (props.hash == null) return;
|
||||||
|
const pixels = decode(props.hash, width, height);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
const imageData = ctx!.createImageData(props.width, props.height);
|
||||||
|
imageData.data.set(pixels);
|
||||||
|
ctx!.putImageData(imageData, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => props.hash, () => {
|
||||||
|
draw();
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
draw();
|
draw();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue