ShadeFace.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <script setup lang="ts">
  2. import { SVGPathData, SVGPathDataTransformer } from 'svg-pathdata';
  3. const Shade: SVGPathData[] = [
  4. 'M0 183A136 183 0 11272 183 136 183 0 110 183Z',
  5. ].map(d => new SVGPathData(d));
  6. const {
  7. translateX = 0, translateY = 0,
  8. scaleX = 1, scaleY = 1,
  9. } = defineProps<{
  10. translateX?: number; translateY?: number;
  11. scaleX?: number; scaleY?: number
  12. }>();
  13. const paths = ref<string[]>([]);
  14. watchEffect(() => {
  15. paths.value = Shade.map(data => data
  16. .transform(SVGPathDataTransformer.TRANSLATE(translateX, translateY))
  17. .transform(SVGPathDataTransformer.SCALE(scaleX, scaleY))
  18. .encode(),
  19. );
  20. });
  21. </script>
  22. <template>
  23. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 272 366">
  24. <clipPath id="shade">
  25. <path v-for="(d,i) in paths" :id="'outline-'+i" stroke="#fefefe" stroke-width="2" fill="none" :d="d" />
  26. </clipPath>
  27. <path
  28. id="face"
  29. stroke="#fefefe"
  30. stroke-width="2"
  31. fill="none"
  32. d="M0 183A136 183 0 11272 183 136 183 0 110 183Z"
  33. />
  34. </svg>
  35. </template>
  36. <style scoped lang="scss">
  37. svg { opacity: 0.85; }
  38. </style>