index.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div class="image-outline">
  3. <ImageRectOutline
  4. v-if="clipShape.type === 'rect'"
  5. :width="elementInfo.width"
  6. :height="elementInfo.height"
  7. :radius="clipShape.radius"
  8. :outline="elementInfo.outline"
  9. />
  10. <ImageEllipseOutline
  11. v-else-if="clipShape.type === 'ellipse'"
  12. :width="elementInfo.width"
  13. :height="elementInfo.height"
  14. :outline="elementInfo.outline"
  15. />
  16. <ImagePolygonOutline
  17. v-else-if="clipShape.type === 'polygon'"
  18. :width="elementInfo.width"
  19. :height="elementInfo.height"
  20. :outline="elementInfo.outline"
  21. :createPath="clipShape.createPath"
  22. />
  23. </div>
  24. </template>
  25. <script lang="ts">
  26. import { computed, defineComponent, PropType } from 'vue'
  27. import { PPTImageElement } from '@/types/slides'
  28. import useClipImage from '../useClipImage'
  29. import ImageRectOutline from './ImageRectOutline.vue'
  30. import ImageEllipseOutline from './ImageEllipseOutline.vue'
  31. import ImagePolygonOutline from './ImagePolygonOutline.vue'
  32. export default defineComponent({
  33. name: 'image-outline',
  34. components: {
  35. ImageRectOutline,
  36. ImageEllipseOutline,
  37. ImagePolygonOutline,
  38. },
  39. props: {
  40. elementInfo: {
  41. type: Object as PropType<PPTImageElement>,
  42. required: true,
  43. },
  44. },
  45. setup(props) {
  46. const clip = computed(() => props.elementInfo.clip)
  47. const { clipShape } = useClipImage(clip)
  48. return {
  49. clipShape,
  50. }
  51. },
  52. })
  53. </script>