konvajs / vue-konva

Vue & Canvas - JavaScript library for drawing complex canvas graphics using Vue.
https://konvajs.github.io/docs/vue/
MIT License
1.18k stars 131 forks source link

useImage hook #253

Open lavrton opened 4 days ago

lavrton commented 4 days ago

I just released a new version with a little useImage hook. Usage:

<template>
  <v-stage :config="stageSize">
    <v-layer>
      <v-image :config="imageConfig" />
    </v-layer>
  </v-stage>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { useImage } from 'vue-konva';

const stageSize = {
  width: window.innerWidth,
  height: window.innerHeight
};

const [image] = useImage('https://konvajs.org/assets/darth-vader.jpg');
const imageConfig = ref({
  x: 50,
  y: 50,
  image,
  width: 100,
  height: 100
});
</script>

If you read this, and interested in vue-konva. Try it. Let me know how it works for you.

rsaleri commented 3 days ago

Tried on nuxt: image

It doesn't like it... image

lavrton commented 3 days ago

Is it the last version of vue-konva?

rsaleri commented 3 days ago

Yes, 3.2.0, I made sure to update before trying it. It's strange, because Webstorm recognize it, but then nuxt die badly.

Oh, well, I finished working for today, I'll try again on monday. Have a nice weekend ;)